Clover.NET coverage report - Coverage for s2container.net

Coverage timestamp: 2006年5月30日 11:21:29

File Stats: LOC: 178   Methods: 16
NCLOC: 136 Classes: 7
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Framework.Container\Assembler\AutoPropertyAssemblerTest.cs - 95.7% 87.5% 93.7%
coverage coverage
1   #region Copyright
2   /*
3   * Copyright 2005 the Seasar Foundation and the Others.
4   *
5   * Licensed under the Apache License, Version 2.0 (the "License");
6   * you may not use this file except in compliance with the License.
7   * You may obtain a copy of the License at
8   *
9   * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14   * either express or implied. See the License for the specific language
15   * governing permissions and limitations under the License.
16   */
17   #endregion
18  
19   using System;
20   using Seasar.Framework.Container;
21   using Seasar.Framework.Container.Assembler;
22   using Seasar.Framework.Container.Impl;
23   using NUnit.Framework;
24  
25   namespace Seasar.Tests.Framework.Container.Assembler
26   {
27   /// <summary>
28   /// AutoPropertyAssemblerTest の概要の説明です。
29   /// </summary>
30   [TestFixture]
31   public class AutoPropertyAssemblerTest
32   {
33 1 [Test]
34   public void TestAssemble()
35   {
36 1 IS2Container container = new S2ContainerImpl();
37 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
38 1 container.Register(cd);
39 1 container.Register(typeof(B));
40 1 IPropertyAssembler assembler = new AutoPropertyAssembler(cd);
41 1 A a = new A();
42 1 assembler.Assemble(a);
43 1 Assert.AreEqual("B",a.HogeName);
44   }
45  
46 1 [Test]
47   public void TestAssemble2()
48   {
49 1 IS2Container container = new S2ContainerImpl();
50 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
51 1 cd.AddPropertyDef(new PropertyDefImpl("Message","aaa"));
52 1 container.Register(cd);
53 1 container.Register(typeof(B));
54 1 IPropertyAssembler assembler = new AutoPropertyAssembler(cd);
55 1 A a = new A();
56 1 assembler.Assemble(a);
57 1 Assert.AreEqual("B",a.HogeName);
58 1 Assert.AreEqual("aaa",a.Message);
59   }
60  
61 1 [Test]
62   public void TestAssembleNotInterface()
63   {
64 1 IS2Container container = new S2ContainerImpl();
65 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(DateTime));
66 1 container.Register(cd);
67 1 IPropertyAssembler assembler = new AutoPropertyAssembler(cd);
68 1 DateTime d = new DateTime();
69 1 assembler.Assemble(d);
70   }
71  
72 1 [Test]
73   public void TestSkipIllegalProperty()
74   {
75 1 IS2Container container = new S2ContainerImpl();
76 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
77 1 container.Register(cd);
78 1 IPropertyAssembler assembler = new AutoPropertyAssembler(cd);
79 1 A a = new A();
80 1 assembler.Assemble(a);
81   }
82  
83 1 [Test]
84   public void TestSkipWarning()
85   {
86 1 IS2Container container = new S2ContainerImpl();
87 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A2));
88 1 container.Register(cd);
89 1 IPropertyAssembler assembler = new AutoPropertyAssembler(cd);
90 1 A2 a2 = new A2();
91 1 assembler.Assemble(a2);
92 1 Assert.AreEqual("B",a2.HogeName);
93   }
94  
95   public interface IFoo
96   {
97   string HogeName{ get; }
98   }
99  
100   public class A : IFoo
101   {
102   private IHoge hoge_;
103   private string message_;
104  
105 3 public A()
106   {
107   }
108  
109   public IHoge Hoge
110   {
111 1 get { return hoge_; }
112 2 set { hoge_ = value; }
113   }
114  
115   public string Message
116   {
117 1 get { return message_; }
118 1 set { message_ = value; }
119   }
120  
121   public string HogeName
122   {
123 2 get
124   {
125 2 return hoge_.Name;
126   }
127   }
128   }
129  
130   public class A2 : IFoo
131   {
132   private IHoge hoge_ = new B();
133  
134   public IHoge Hoge
135   {
136 1 get { return hoge_; }
137 0 set { hoge_ = value; }
138   }
139   public string HogeName
140   {
141 1 get
142   {
143 1 return hoge_.Name;
144   }
145   }
146   }
147  
148   public interface IHoge
149   {
150   string Name { get; }
151   }
152  
153   public class B : IHoge
154   {
155   public string Name
156   {
157 3 get
158   {
159 3 return "B";
160   }
161   }
162   }
163  
164   public class C : IHoge
165   {
166 0 public string Name
167   {
168   get
169   {
170   return "C";
171   }
172   }
173   }
174  
175  
176   }
177   }
178