Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 139   Methods: 7
NCLOC: 99 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Extension.Tx\Impl\LocalNotSupportedInterceptorTest.cs - 94.1% 100.0% 95.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   using System.Data;
21   using System.IO;
22   using System.Reflection;
23  
24   using Seasar.Extension.Tx;
25  
26   using Seasar.Framework.Container;
27   using Seasar.Framework.Container.Factory;
28  
29   using log4net;
30   using log4net.Config;
31   using log4net.Util;
32  
33   using NUnit.Framework;
34  
35   namespace Seasar.Tests.Extension.Tx.Impl
36   {
37   /// <summary>
38   /// LocalNotSupportedInterceptorTest の概要の説明です。
39   /// </summary>
40   [TestFixture]
41   public class LocalNotSupportedInterceptorTest
42   {
43   private const string path = "Seasar/Tests/Extension/Tx/Impl/LocalNotSupportedInterceptorTest.dicon";
44  
45 1 public LocalNotSupportedInterceptorTest()
46   {
47 1 FileInfo info = new FileInfo(SystemInfo.AssemblyFileName(
48   Assembly.GetExecutingAssembly()) + ".config");
49 1 XmlConfigurator.Configure(LogManager.GetRepository(), info);
50   }
51  
52   private IS2Container container = null;
53  
54   private ILocalTxTest tester = null;
55   private ITransactionContext context = null;
56  
57 3 [SetUp]
58   public void SetUp()
59   {
60 3 container = S2ContainerFactory.Create(path);
61 3 container.Init();
62 3 tester = container.GetComponent(typeof(ILocalTxTest)) as ILocalTxTest;
63 3 context = container.GetComponent(typeof(ITransactionContext)) as ITransactionContext;
64  
65   }
66  
67 3 [TearDown]
68   public void TearDown()
69   {
70 3 container.Destroy();
71   }
72  
73 1 [Test]
74   public void TestProceed()
75   {
76 1 Assert.IsFalse(tester.IsInTransaction());
77 1 Assert.IsFalse(context.Current.IsInTransaction);
78   }
79  
80 1 [Test]
81   public void TestProceedInTx()
82   {
83 1 using(ITransactionContext ctx = this.context.Create())
84   {
85 1 ctx.Begin();
86 1 this.context.Current = ctx;
87  
88 1 Assert.IsFalse(tester.IsInTransaction());
89  
90 1 IDbConnection con = tester.GetConnection();
91 1 Assert.IsFalse(Object.ReferenceEquals(ctx.Connection, con));
92 1 Assert.IsFalse(canStartTx(con));
93 1 ctx.Rollback();
94   }
95   }
96  
97 2 protected bool canStartTx(IDbConnection con)
98   {
99 2 Assert.IsNotNull(con);
100 2 try
101   {
102 2 con.BeginTransaction();
103 0 return true;
104   }
105   catch
106   {
107 2 return false;
108   }
109  
110   }
111  
112 1 [Test]
113   public void TestProceedExceptionInTx()
114   {
115 1 using(ITransactionContext ctx = this.context.Create())
116   {
117 1 ctx.Begin();
118 1 this.context.Current = ctx;
119  
120 1 try
121   {
122 1 tester.throwException();
123 0 Assert.Fail();
124   }
125   catch(Exception e)
126   {
127 1 Assert.IsTrue(e is NotSupportedException);
128 1 Assert.IsTrue(context.Current.IsInTransaction);
129   }
130 1 IDbConnection con = tester.GetConnection();
131 1 Assert.IsFalse(Object.ReferenceEquals(ctx.Connection, con));
132 1 Assert.IsFalse(canStartTx(con));
133 1 ctx.Rollback();
134   }
135  
136   }
137   }
138   }
139