Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 138   Methods: 11
NCLOC: 102 Classes: 8
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Framework.Aop\Proxy\AopProxyTest.cs - 80.0% 63.6% 75.0%
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.Aop;
22   using Seasar.Framework.Aop.Impl;
23   using Seasar.Framework.Aop.Proxy;
24   using Seasar.Framework.Aop.Interceptors;
25  
26   namespace Seasar.Tests.Framework.Aop.Proxy
27   {
28   /// <summary>
29   /// AopProxyTest の概要の説明です。
30   /// </summary>
31   [TestFixture]
32   public class AopProxyTest
33   {
34 1 public AopProxyTest()
35   {
36   }
37  
38 1 [Test]
39   public void TestInterface()
40   {
41 1 IPointcut pointcut = new PointcutImpl(new string[] { "Greeting" });
42 1 IAspect aspect = new AspectImpl(new HelloInterceptor(),pointcut);
43 1 AopProxy aopProxy = new AopProxy(typeof(IHello),new IAspect[] { aspect } );
44 1 IHello proxy = (IHello) aopProxy.GetTransparentProxy();
45 1 Assert.AreEqual("Hello",proxy.Greeting());
46   }
47  
48 1 [Test]
49   public void TestCreateForArgs()
50   {
51 1 IAspect aspect = new AspectImpl(new TraceInterceptor());
52 1 AopProxy aopProxy = new AopProxy(typeof(HelloImpl), new IAspect[] { aspect });
53 1 IHello proxy = (IHello) aopProxy.Create(new Type[] { typeof(string) },
54   new object[] { "Hello" });
55 1 Assert.AreEqual("Hello",proxy.Greeting());
56 1 Console.WriteLine(proxy.GetHashCode());
57   }
58  
59 1 [Test]
60   public void TestEquals()
61   {
62 1 IPointcut pointcut = new PointcutImpl(new string[] { "Greeting" });
63 1 IAspect aspect = new AspectImpl(new HelloInterceptor(),pointcut);
64 1 AopProxy aopProxy = new AopProxy(typeof(IHello), new IAspect[] { aspect });
65 1 IHello proxy = (IHello) aopProxy.Create();
66  
67   //Assert.AreEqual(true,proxy.Equals(proxy)); これは駄目
68 1 Assert.AreEqual(true,object.Equals(proxy,proxy));
69 1 Assert.AreEqual(false,object.Equals(proxy,null));
70 1 Assert.AreEqual(false,object.Equals(proxy,"hoge"));
71   }
72  
73   public class TestInvocation : IMethodInterceptor
74   {
75   internal bool invoked_ = false;
76  
77 0 public object Invoke(IMethodInvocation invocation)
78   {
79   invoked_ = true;
80   return invocation.Proceed();
81   }
82   }
83  
84   public class MyInvocation : IMethodInterceptor
85   {
86 0 public object Invoke(IMethodInvocation invocation)
87   {
88   return invocation.Proceed();
89   }
90   }
91  
92   public interface IHello
93   {
94   string Greeting();
95   }
96  
97   [Serializable()]
98   public class HelloImpl : MarshalByRefObject, IHello
99   {
100   private string str_;
101 1 public HelloImpl(string str)
102   {
103 1 str_ = str;
104   }
105  
106 1 public string Greeting()
107   {
108 1 return str_;
109   }
110  
111   }
112  
113   public class Hello2Impl : IHello
114   {
115 0 public string Greeting()
116   {
117   return "Hello2";
118   }
119   }
120  
121   public class HelloImpl3 : IHello
122   {
123 0 public string Greeting()
124   {
125   return "hoge";
126   }
127   }
128  
129   public class HelloInterceptor : IMethodInterceptor
130   {
131 1 public object Invoke(IMethodInvocation invocation)
132   {
133 1 return "Hello";
134   }
135   }
136   }
137   }
138