Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 163   Methods: 9
NCLOC: 127 Classes: 5
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Framework.Container\Assembler\ManualConstructorAssemblerTest.cs - 97.9% 100.0% 98.2%
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 System.IO;
21   using System.Runtime.Remoting;
22   using System.Reflection;
23   using Seasar.Framework.Aop.Interceptors;
24   using Seasar.Framework.Container;
25   using Seasar.Framework.Container.Assembler;
26   using Seasar.Framework.Container.Impl;
27   using Seasar.Framework.Exceptions;
28   using NUnit.Framework;
29   using log4net;
30   using log4net.Config;
31   using log4net.Util;
32  
33   namespace Seasar.Tests.Framework.Container.Assembler
34   {
35   /// <summary>
36   /// ManualConstructorAssemblerTest の概要の説明です。
37   /// </summary>
38   [TestFixture]
39   public class ManualConstructorAssemblerTest
40   {
41 4 [SetUp]
42   public void SetUp()
43   {
44 4 FileInfo info = new FileInfo(SystemInfo.AssemblyFileName(
45   Assembly.GetExecutingAssembly()) + ".config");
46 4 XmlConfigurator.Configure(LogManager.GetRepository(), info);
47   }
48  
49 1 [Test]
50   public void TestAssemble()
51   {
52 1 IS2Container container = new S2ContainerImpl();
53 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
54 1 IArgDef argDef = new ArgDefImpl(new B());
55 1 cd.AddArgDef(argDef);
56 1 container.Register(cd);
57 1 IConstructorAssembler assembler = new ManualConstructorAssembler(cd);
58 1 A a = (A) assembler.Assemble();
59 1 Assert.AreEqual("B", a.HogeName);
60   }
61  
62 1 [Test]
63   public void TestAssembleAspect()
64   {
65 1 IS2Container container = new S2ContainerImpl();
66 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
67 1 cd.AddAspeceDef(new AspectDefImpl(new TraceInterceptor()));
68 1 IArgDef argDef = new ArgDefImpl(new B());
69 1 cd.AddArgDef(argDef);
70 1 container.Register(cd);
71 1 IConstructorAssembler assembler = new ManualConstructorAssembler(cd);
72 1 A a = (A) assembler.Assemble();
73 1 Assert.AreEqual("B",a.HogeName);
74   }
75  
76 1 [Test]
77   public void TestAssembleIllegalConstructorArgument()
78   {
79 1 IS2Container container = new S2ContainerImpl();
80 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
81 1 IArgDef argDef = new ArgDefImpl();
82 1 argDef.Expression = "hoge";
83 1 cd.AddArgDef(argDef);
84 1 container.Register(cd);
85 1 IConstructorAssembler assembler = new ManualConstructorAssembler(cd);
86 1 try
87   {
88 1 assembler.Assemble();
89 0 Assert.Fail();
90   }
91   catch(JScriptEvaluateRuntimeException ex)
92   {
93 1 Console.WriteLine(ex);
94   }
95   }
96  
97 1 [Test]
98   public void TestAssembleWithAspect()
99   {
100 1 IS2Container container = new S2ContainerImpl();
101 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
102 1 ComponentDefImpl cdB = new ComponentDefImpl(typeof(B), "B");
103 1 IArgDef argDef = new ArgDefImpl();
104 1 argDef.Expression = "B";
105 1 cd.AddArgDef(argDef);
106 1 container.Register(cd);
107 1 AspectDefImpl ad = new AspectDefImpl(new TraceInterceptor());
108 1 cdB.AddAspeceDef(ad);
109 1 container.Register(cdB);
110 1 IConstructorAssembler assembler = new ManualConstructorAssembler(cd);
111 1 A a = (A)assembler.Assemble();
112 1 Assert.AreEqual("B", a.HogeName, "1");
113 1 Assert.IsTrue(RemotingServices.IsTransparentProxy(a.Hoge), "2");
114   }
115  
116   public interface IFoo
117   {
118   string HogeName { get; }
119   }
120  
121   public class A : MarshalByRefObject, IFoo
122   {
123   private IHoge hoge_;
124  
125 3 public A(IHoge hoge)
126   {
127 3 hoge_ = hoge;
128   }
129  
130   public IHoge Hoge
131   {
132 1 get { return hoge_; }
133   }
134  
135   public string HogeName
136   {
137 3 get
138   {
139 3 return hoge_.Name;
140   }
141   }
142   }
143  
144   public interface IHoge
145   {
146   string Name { get; }
147   }
148  
149   public class B : IHoge
150   {
151   public string Name
152   {
153 3 get
154   {
155 3 return "B";
156   }
157   }
158   }
159  
160  
161   }
162   }
163