Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 107   Methods: 6
NCLOC: 75 Classes: 5
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Framework.Aop\Impl\MethodInvocationImplTest.cs - 100.0% 100.0% 100.0%
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.Aop;
21   using Seasar.Framework.Aop.Impl;
22   using Seasar.Framework.Aop.Proxy;
23   using NUnit.Framework;
24  
25   namespace Seasar.Tests.Framework.Aop.Impl
26   {
27   /// <summary>
28   /// MethodInvocationImplTest の概要の説明です。
29   /// </summary>
30   [TestFixture]
31   public class MethodInvocationImplTest
32   {
33 1 public MethodInvocationImplTest()
34   {
35   }
36  
37 1 [Test]
38   public void TestProceed()
39   {
40 1 TestInterceptor interceptor = new TestInterceptor();
41 1 TestInterceptor interceptor2 = new TestInterceptor();
42 1 IPointcut pointcut = new PointcutImpl(new string[] { "Foo" });
43 1 IAspect aspect = new AspectImpl(interceptor,pointcut);
44 1 IAspect aspect2 = new AspectImpl(interceptor2,pointcut);
45  
46 1 Hoge proxy = new HogeImpl();
47 1 AopProxy aopProxy = new AopProxy(typeof(Hoge),new IAspect[] {aspect,aspect2},null,proxy);
48 1 proxy = (Hoge) aopProxy.GetTransparentProxy();
49 1 Console.WriteLine(proxy.Foo());
50 1 Assert.AreEqual(true,interceptor.invoked_);
51 1 Assert.AreEqual(true,interceptor2.invoked_);
52   }
53  
54 1 [Test]
55   public void TestProceedForAbstractMethod()
56   {
57 1 HogeInterceptor interceptor = new HogeInterceptor();
58 1 IAspect aspect = new AspectImpl(interceptor);
59 1 Hoge proxy = new HogeImpl();
60 1 AopProxy aopProxy = new AopProxy(typeof(Hoge),new IAspect[] { aspect },null,proxy);
61 1 proxy = (Hoge) aopProxy.GetTransparentProxy();
62 1 Assert.AreEqual("Hello",proxy.Foo());
63   }
64  
65   public class TestInterceptor : IMethodInterceptor
66   {
67   internal bool invoked_ = false;
68  
69 2 public object Invoke(Seasar.Framework.Aop.IMethodInvocation invocation)
70   {
71 2 invoked_ = true;
72 2 Console.WriteLine("before");
73 2 object ret = invocation.Proceed();
74 2 Console.WriteLine("after");
75 2 return ret;
76   }
77   }
78  
79   public interface Hoge
80   {
81   string Foo();
82   }
83  
84   public class HogeImpl : Hoge
85   {
86   #region Hoge メンバ
87  
88 1 public string Foo()
89   {
90   // TODO: HogeImpl.Foo 実装を追加します。
91 1 Console.WriteLine("Foo");
92 1 return "hogehoge";
93   }
94  
95   #endregion
96   }
97  
98   public class HogeInterceptor : IMethodInterceptor
99   {
100 1 public object Invoke(Seasar.Framework.Aop.IMethodInvocation invocation)
101   {
102 1 return "Hello";
103   }
104   }
105   }
106   }
107