Clover.NET coverage report - Coverage for s2dao.net

Coverage timestamp: 2006年5月30日 11:48:56

File Stats: LOC: 139   Methods: 6
NCLOC: 94 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Dao.Tests.Impl\UpdateAutoStaticCommandTest.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.Dao;
21   using Seasar.Dao.Impl;
22   using Seasar.Extension.ADO;
23   using Seasar.Extension.ADO.Impl;
24   using Seasar.Extension.Unit;
25   using Seasar.Framework.Container;
26   using Seasar.Framework.Container.Factory;
27   using Seasar.Framework.Exceptions;
28   using Seasar.Framework.Util;
29   using NUnit.Framework;
30  
31   namespace Seasar.Dao.Tests.Impl
32   {
33   /// <summary>
34   /// UpdateAutoStaticCommandTest の概要の説明です。
35   /// </summary>
36   [TestFixture]
37   public class UpdateAutoStaticCommandTest : S2TestCase
38   {
39   private const string PATH = "Tests.dicon";
40   private IDataSource dataSource;
41  
42 5 [SetUp]
43   public void SetUp()
44   {
45 5 IS2Container container = S2ContainerFactory.Create(PATH);
46 5 dataSource = (IDataSource) container.GetComponent(typeof(IDataSource));
47   }
48  
49 1 [Test, S2(Tx.Rollback)]
50   public void TestExecuteTx()
51   {
52 1 IDaoMetaData dmd = new DaoMetaDataImpl(typeof(EmployeeAutoDao),
53   dataSource, BasicCommandFactory.INSTANCE,
54   BasicDataReaderFactory.INSTANCE, new DatabaseMetaDataImpl(dataSource));
55  
56 1 ISqlCommand cmd = dmd.GetSqlCommand("Update");
57 1 ISqlCommand cmd2 = dmd.GetSqlCommand("GetEmployee");
58 1 Employee emp = (Employee) cmd2.Execute(new Object[] { 7788 });
59 1 Int32 count = (Int32) cmd.Execute(new Object[] { emp });
60 1 Assert.AreEqual(1, count, "1");
61  
62   }
63  
64 1 [Test, S2(Tx.Rollback)]
65   public void TestExecute2Tx()
66   {
67 1 IDaoMetaData dmd = new DaoMetaDataImpl(typeof(DepartmentAutoDao),
68   dataSource, BasicCommandFactory.INSTANCE,
69   BasicDataReaderFactory.INSTANCE, new DatabaseMetaDataImpl(dataSource));
70  
71 1 ISqlCommand cmd = dmd.GetSqlCommand("Update");
72 1 Department dept = new Department();
73 1 dept.Deptno =10;
74 1 Int32 count = (Int32) cmd.Execute(new Object[] { dept });
75 1 Assert.AreEqual(1, count, "1");
76 1 Assert.AreEqual(1, dept.VersionNo, "2");
77  
78  
79   //更新したVersionNoを戻しておく
80 1 string cmdText = "Update [dbo].[DEPT] SET VERSIONNO = 0 WHERE DEPTNO = 10";
81 1 System.Data.IDbConnection cn = DataSourceUtil.GetConnection(dataSource);
82 1 System.Data.IDbCommand dbcmd = dataSource.GetCommand(cmdText,cn);
83 1 CommandUtil.ExecuteNonQuery(dataSource,dbcmd);
84  
85   }
86  
87 1 [Test, S2(Tx.Rollback)]
88   [ExpectedException(typeof(NotSingleRowUpdatedRuntimeException))]
89   public void TestExecute3Tx()
90   {
91 1 IDaoMetaData dmd = new DaoMetaDataImpl(typeof(DepartmentAutoDao),
92   dataSource, BasicCommandFactory.INSTANCE,
93   BasicDataReaderFactory.INSTANCE, new DatabaseMetaDataImpl(dataSource));
94  
95 1 ISqlCommand cmd = dmd.GetSqlCommand("Update");
96 1 Department dept = new Department();
97 1 dept.Deptno = 10;
98 1 dept.VersionNo = -1;
99   // try
100   // {
101 1 cmd.Execute(new Object[] { dept });
102   // fail("1");
103   // }
104   // catch (UpdateFailureRuntimeException ex)
105   // {
106   // //System.out.println(ex);
107   // }
108   }
109  
110 1 [Test, S2(Tx.Rollback)]
111   public void TestExecute4Tx()
112   {
113 1 IDaoMetaData dmd = new DaoMetaDataImpl(typeof(EmployeeAutoDao),
114   dataSource, BasicCommandFactory.INSTANCE,
115   BasicDataReaderFactory.INSTANCE, new DatabaseMetaDataImpl(dataSource));
116  
117 1 ISqlCommand cmd = dmd.GetSqlCommand("Update2");
118 1 ISqlCommand cmd2 = dmd.GetSqlCommand("GetEmployee");
119 1 Employee emp = (Employee) cmd2.Execute(new Object[] { 7788 });
120 1 Int32 count = (Int32) cmd.Execute(new Object[] { emp });
121 1 Assert.AreEqual(1, count, "1");
122   }
123  
124 1 [Test, S2(Tx.Rollback)]
125   public void TestExecute5Tx()
126   {
127 1 IDaoMetaData dmd = new DaoMetaDataImpl(typeof(EmployeeAutoDao),
128   dataSource, BasicCommandFactory.INSTANCE,
129   BasicDataReaderFactory.INSTANCE, new DatabaseMetaDataImpl(dataSource));
130  
131 1 ISqlCommand cmd = dmd.GetSqlCommand("Update3");
132 1 ISqlCommand cmd2 = dmd.GetSqlCommand("GetEmployee");
133 1 Employee emp = (Employee) cmd2.Execute(new Object[] { 7788 });
134 1 Int32 count = (Int32) cmd.Execute(new Object[] { emp });
135 1 Assert.AreEqual(1, count, "1");
136   }
137   }
138   }
139