Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 116   Methods: 6
NCLOC: 81 Classes: 3
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Framework.Aop\Interceptors\MockInterceptorTest.cs - 96.4% 100.0% 97.1%
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  
21   using Seasar.Framework.Aop;
22   using Seasar.Framework.Aop.Impl;
23   using Seasar.Framework.Aop.Interceptors;
24   using Seasar.Framework.Aop.Proxy;
25  
26   using NUnit.Framework;
27  
28  
29   namespace Seasar.Tests.Framework.Aop.Interceptors
30   {
31   /// <summary>
32   /// MockInterceptorTest の概要の説明です。
33   /// </summary>
34   [TestFixture]
35   public class MockInterceptorTest
36   {
37   private const string MSG = "hello";
38   private const string ECHO = "echo";
39   private MockInterceptor target = null;
40  
41 4 public static object CreateProxy(IMethodInterceptor interceptor,Type proxyType)
42   {
43 4 IAspect aspect = new AspectImpl(interceptor, null);
44 4 return new AopProxy(proxyType, new IAspect[] { aspect }).GetTransparentProxy();
45   }
46  
47 4 [SetUp]
48   public void SetUp()
49   {
50 4 target = new MockInterceptor(MSG);
51   }
52  
53 1 [Test]
54   public void TestInvoke()
55   {
56 1 Hello hello = CreateProxy(target, typeof(Hello)) as Hello;
57 1 Assert.AreEqual(MSG, hello.Greeting());
58   }
59  
60 1 [Test]
61   public void TestInvoke2()
62   {
63 1 target.SetReturnValue("Greeting", MSG);
64 1 target.SetReturnValue("Echo", ECHO);
65 1 SayHello hello = CreateProxy(target, typeof(SayHello)) as SayHello;
66  
67 1 string message = "hoge";
68  
69 1 Assert.AreEqual(ECHO, hello.Echo(message));
70 1 Assert.IsTrue(target.IsInvoked("Echo"));
71 1 Assert.IsFalse(target.IsInvoked("Greeting"));
72 1 Assert.AreEqual(message, target.GetArgs("Echo")[0]);
73   }
74  
75 1 [Test]
76   public void TestInvoke3()
77   {
78 1 target.SetReturnValue("Greeting", MSG);
79 1 target.SetReturnValue("Echo", ECHO);
80 1 SayHello hello = CreateProxy(target, typeof(SayHello)) as SayHello;
81  
82 1 string message = "hoge";
83 1 Assert.AreEqual(MSG, hello.Greeting());
84 1 Assert.AreEqual(ECHO, hello.Echo(message));
85 1 Assert.IsTrue(target.IsInvoked("Greeting"));
86 1 Assert.IsTrue(target.IsInvoked("Echo"));
87   }
88  
89 1 [Test]
90   public void TestInvokeThrowException()
91   {
92 1 Exception ex = new ApplicationException();
93 1 target.SetThrowable("Greeting", ex);
94 1 Hello hello = CreateProxy(target, typeof(Hello)) as Hello;
95 1 try
96   {
97 1 hello.Greeting();
98 0 Assert.Fail();
99   } catch(ApplicationException exception)
100   {
101 1 Assert.AreEqual(ex, exception);
102   }
103   }
104   }
105  
106   public interface Hello
107   {
108   string Greeting();
109   }
110  
111   public interface SayHello : Hello
112   {
113   string Echo(string msg);
114   }
115   }
116