Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 185   Methods: 16
NCLOC: 143 Classes: 10
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Framework.Container\Impl\ArgDefImplTest.cs - 90.0% 68.8% 84.8%
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 NUnit.Framework;
21   using Seasar.Framework.Container;
22   using Seasar.Framework.Container.Impl;
23  
24   namespace Seasar.Tests.Framework.Container.Impl
25   {
26   /// <summary>
27   /// ArgDefImplTest の概要の説明です。
28   /// </summary>
29   [TestFixture]
30   public class ArgDefImplTest
31   {
32 1 [Test]
33   public void TestSetExpression()
34   {
35 1 IS2Container container = new S2ContainerImpl();
36 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
37 1 IArgDef ad = new ArgDefImpl();
38 1 ad.Expression = "hoge";
39 1 cd.AddArgDef(ad);
40 1 container.Register(cd);
41 1 ComponentDefImpl cd2 = new ComponentDefImpl(typeof(B), "hoge");
42 1 container.Register(cd2);
43 1 container.Register(typeof(C));
44 1 A a = (A) container.GetComponent(typeof(A));
45 1 Assert.AreEqual("B", a.HogeName);
46   }
47  
48 1 [Test]
49   public void TestSetChildComponentDef()
50   {
51 1 IS2Container container = new S2ContainerImpl();
52 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
53 1 IArgDef ad = new ArgDefImpl();
54 1 ComponentDefImpl cd2 = new ComponentDefImpl(typeof(B));
55 1 ad.ChildComponentDef = cd2;
56 1 cd.AddArgDef(ad);
57 1 container.Register(cd);
58 1 container.Register(typeof(C));
59 1 A a = (A) container.GetComponent(typeof(A));
60 1 Assert.AreEqual("B", a.HogeName);
61   }
62  
63 1 [Test]
64   public void TestPrototype()
65   {
66 1 IS2Container container = new S2ContainerImpl();
67 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(StrHolderImpl), "foo");
68 1 cd.InstanceMode = "prototype";
69 1 ComponentDefImpl cd2 = new ComponentDefImpl(typeof(StrFacadeImpl));
70 1 cd2.InstanceMode = "prototype";
71 1 IArgDef ad = new ArgDefImpl();
72 1 ad.Expression = "foo";
73 1 cd2.AddArgDef(ad);
74 1 container.Register(cd);
75 1 container.Register(cd2);
76 1 IStrFacade facade1 = (IStrFacade) container.GetComponent(typeof(IStrFacade));
77 1 IStrFacade facade2 = (IStrFacade) container.GetComponent(typeof(IStrFacade));
78 1 facade1.Str = "aaa";
79 1 facade2.Str = "bbb";
80 1 Assert.AreEqual("aaa", facade1.Str);
81 1 Assert.AreEqual("bbb", facade2.Str);
82   }
83  
84   public class A
85   {
86   private IHoge hoge_;
87  
88 2 public A(IHoge hoge)
89   {
90 2 hoge_ = hoge;
91   }
92  
93   public string HogeName
94   {
95 2 get { return hoge_.Name; }
96   }
97   }
98  
99   public class A2
100   {
101   private IHoge hoge_;
102  
103 0 public IHoge Hoge
104   {
105   set { hoge_ = value; }
106   }
107  
108 0 public string HogeName
109   {
110   get { return hoge_.Name; }
111   }
112   }
113  
114   public interface IHoge
115   {
116   string Name { get; }
117   }
118  
119   public class B : IHoge
120   {
121   public string Name
122   {
123 2 get { return "B"; }
124   }
125   }
126  
127   public class C : IHoge
128   {
129   private A2 a2_;
130  
131 0 public A2 A2
132   {
133   set { a2_ = value; }
134   }
135  
136 0 public string Name
137   {
138   get { return "C"; }
139   }
140  
141 0 public string HogeName
142   {
143   get { return a2_.HogeName; }
144   }
145   }
146  
147   public interface IStrHolder
148   {
149   string Str { set; get; }
150   }
151  
152   public class StrHolderImpl : IStrHolder
153   {
154   private string str_;
155  
156   public string Str
157   {
158 2 set { str_ = value; }
159 2 get { return str_; }
160   }
161   }
162  
163   public interface IStrFacade
164   {
165   string Str { set; get; }
166   }
167  
168   public class StrFacadeImpl : IStrFacade
169   {
170   private IStrHolder strHolder_;
171  
172 2 public StrFacadeImpl(IStrHolder strHolder)
173   {
174 2 strHolder_ = strHolder;
175   }
176  
177   public string Str
178   {
179 2 set { strHolder_.Str = value; }
180 2 get { return strHolder_.Str; }
181   }
182   }
183   }
184   }
185