Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 165   Methods: 10
NCLOC: 128 Classes: 6
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Framework.Container\Deployer\RequestComponentDeployerTest.cs - 96.7% 80.0% 94.4%
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.Web;
21   using NUnit.Framework;
22   using Seasar.Framework.Aop;
23   using Seasar.Framework.Container;
24   using Seasar.Framework.Container.Deployer;
25   using Seasar.Framework.Container.Impl;
26  
27   namespace Seasar.Tests.Framework.Container.Deployer
28   {
29   [TestFixture]
30   public class RequestComponentDeployerTest
31   {
32   private IS2Container container;
33  
34 4 [SetUp]
35   public void SetUp()
36   {
37 4 HttpRequest request = new HttpRequest("hello.html", "http://localhost/hello.html", "");
38 4 HttpResponse response = new HttpResponse(null);
39 4 HttpContext.Current = new HttpContext(request, response);
40 4 container = new S2ContainerImpl();
41 4 container.HttpContext = HttpContext.Current;
42   }
43  
44 1 [Test]
45   public void TestDeployAutoAutoConstructor()
46   {
47 1 IComponentDef cd = new ComponentDefImpl(typeof(Foo), "foo");
48 1 container.Register(cd);
49 1 IComponentDeployer deployer = new RequestComponentDeployer(cd);
50 1 Foo foo = (Foo) deployer.Deploy(typeof(Foo));
51 1 Assert.AreSame(foo, HttpContext.Current.Items["foo"]);
52 1 Assert.AreSame(foo, deployer.Deploy(typeof(Foo)));
53   }
54  
55 1 [Test]
56   public void TestDeployAspect1()
57   {
58 1 container = new S2ContainerImpl();
59 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(CulcImpl1));
60  
61 1 IAspectDef ad = new AspectDefImpl();
62 1 ad.Expression = "plusOne";
63 1 ad.Container = container;
64 1 cd.AddAspeceDef(ad);
65 1 ComponentDefImpl plusOneCd = new ComponentDefImpl(typeof(PlusOneInterceptor), "plusOne");
66 1 container.Register(plusOneCd);
67 1 container.Register(cd);
68  
69 1 IComponentDeployer deployer = new RequestComponentDeployer(cd);
70 1 ICulc culc = (ICulc) deployer.Deploy(typeof(ICulc));
71 1 PlusOneInterceptor.Count = 0;
72 1 Assert.AreEqual(1, culc.Count());
73   }
74  
75 1 [Test]
76   public void TestDeployAspect2()
77   {
78 1 container = new S2ContainerImpl();
79 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(CulcImpl2));
80  
81 1 IAspectDef ad = new AspectDefImpl();
82 1 ad.Expression = "plusOne";
83 1 ad.Container = container;
84 1 cd.AddAspeceDef(ad);
85 1 ComponentDefImpl plusOneCd = new ComponentDefImpl(typeof(PlusOneInterceptor), "plusOne");
86 1 container.Register(plusOneCd);
87 1 container.Register(cd);
88  
89 1 IComponentDeployer deployer = new RequestComponentDeployer(cd);
90 1 CulcImpl2 culc = (CulcImpl2) deployer.Deploy(typeof(CulcImpl2));
91 1 PlusOneInterceptor.Count = 0;
92 1 Assert.AreEqual(1, culc.Count());
93   }
94  
95 1 [Test]
96   public void TestDeployAspect3()
97   {
98 1 container = new S2ContainerImpl();
99 1 ComponentDefImpl cd = new ComponentDefImpl(typeof(CulcImpl2));
100  
101 1 IAspectDef ad = new AspectDefImpl();
102 1 ad.Expression = "plusOne";
103 1 ad.Container = container;
104  
105 1 IAspectDef ad2 = new AspectDefImpl();
106 1 ad2.Expression = "plusOne";
107 1 ad2.Container = container;
108  
109 1 cd.AddAspeceDef(ad);
110 1 cd.AddAspeceDef(ad2);
111 1 ComponentDefImpl plusOneCd = new ComponentDefImpl(typeof(PlusOneInterceptor), "plusOne");
112 1 container.Register(plusOneCd);
113 1 container.Register(cd);
114  
115 1 IComponentDeployer deployer = new RequestComponentDeployer(cd);
116 1 CulcImpl2 culc = (CulcImpl2) deployer.Deploy(typeof(CulcImpl2));
117 1 PlusOneInterceptor.Count = 0;
118 1 Assert.AreEqual(2, culc.Count());
119   }
120  
121   public class Foo
122   {
123   private string message_;
124  
125 0 public string Message
126   {
127   set { message_ = value; }
128   get { return message_; }
129   }
130   }
131  
132   public class PlusOneInterceptor : IMethodInterceptor
133   {
134   public static int Count = 0;
135 4 public object Invoke(IMethodInvocation invocation)
136   {
137 4 ++Count;
138 4 invocation.Proceed();
139 4 return Count;
140   }
141   }
142  
143   public interface ICulc
144   {
145   int Count();
146   }
147  
148   public class CulcImpl1 : ICulc
149   {
150 1 public int Count()
151   {
152 1 return 0;
153   }
154   }
155  
156   public class CulcImpl2 : MarshalByRefObject, ICulc
157   {
158 2 public int Count()
159   {
160 2 return 0;
161   }
162   }
163   }
164   }
165