Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 114   Methods: 8
NCLOC: 87 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Extension.Unit\S2TestCaseRunner.cs 88.9% 92.6% 100.0% 92.5%
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.Collections;
21   using MbUnit.Core.Invokers;
22   using Seasar.Extension.ADO;
23   using Seasar.Extension.Tx;
24   using Seasar.Framework.Container;
25   using Seasar.Framework.Unit;
26   using Seasar.Framework.Util;
27  
28   namespace Seasar.Extension.Unit
29   {
30   public class S2TestCaseRunner : S2FrameworkTestCaseRunner
31   {
32   private static readonly String DATASOURCE_NAME = "Ado"
33   + ContainerConstants.NS_SEP + "DataSource";
34  
35   private S2TestCase fixture;
36   private Tx tx;
37   private ITransactionContext tc;
38   private IDataSource dataSource;
39  
40 42 public S2TestCaseRunner()
41   {
42   }
43  
44 42 public object Run(IRunInvoker invoker, object o, IList args, Tx tx)
45   {
46 42 this.tx = tx;
47 42 fixture = o as S2TestCase;
48 42 return this.Run(invoker, o, args);
49   }
50  
51 42 protected override void BeginTransactionContext()
52   {
53 42 if (Tx.NotSupported != tx)
54   {
55 28 tc = (ITransactionContext) this.Container.GetComponent(typeof(ITransactionContext));
56 28 tc.Begin();
57   }
58   }
59  
60 42 protected override void EndTransactionContext()
61   {
62 42 if (tc != null)
63   {
64 28 if (Tx.Commit == tx)
65 1 tc.Commit();
66 28 if (Tx.Rollback == tx)
67 27 tc.Rollback();
68   }
69   }
70  
71 42 protected override void SetUpAfterContainerInit()
72   {
73 42 base.SetUpAfterContainerInit();
74 42 SetupDataSource();
75   }
76  
77 42 protected override void TearDownBeforeContainerDestroy()
78   {
79 42 TearDownDataSource();
80 42 base.TearDownBeforeContainerDestroy();
81   }
82  
83 42 protected void SetupDataSource()
84   {
85 42 if (this.Container.HasComponentDef(DATASOURCE_NAME))
86   {
87 32 dataSource = this.Container.GetComponent(DATASOURCE_NAME) as IDataSource;
88   }
89 10 else if (this.Container.HasComponentDef(typeof(IDataSource)))
90   {
91 2 dataSource = this.Container.GetComponent(typeof(IDataSource)) as IDataSource;
92   }
93 42 if (fixture != null && dataSource != null)
94   {
95 34 fixture.SetDataSource(dataSource);
96   }
97   }
98  
99 42 protected void TearDownDataSource()
100   {
101 42 if (fixture.HasConnection)
102   {
103 0 ConnectionUtil.Close(fixture.Connection);
104 0 fixture.SetConnection(null);
105   }
106 42 if (fixture != null)
107   {
108 42 fixture.SetDataSource(null);
109   }
110 42 dataSource = null;
111   }
112   }
113   }
114