Clover.NET coverage report - Coverage for s2dao.net

Coverage timestamp: 2006年5月18日 15:09:15

File Stats: LOC: 114   Methods: 3
NCLOC: 72 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Dao.Tests.Impl\DeleteAutoStaticCommandTest.cs - 97.0% 100.0% 97.2%
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 Seasar.Dao;
21   using Seasar.Dao.Impl;
22   using Seasar.Extension.ADO;
23   using Seasar.Extension.ADO.Impl;
24   using Seasar.Framework.Container;
25   using Seasar.Framework.Container.Factory;
26   using Seasar.Framework.Util;
27   using NUnit.Framework;
28  
29   namespace Seasar.Dao.Tests.Impl
30   {
31   /// <summary>
32   /// DeleteAutoStaticCommandTest の概要の説明です。
33   /// </summary>
34   [TestFixture]
35   public class DeleteAutoStaticCommandTest
36   {
37  
38   private const string PATH = "Tests.dicon";
39  
40 1 [Test]
41   public void TestExecuteTx()
42   {
43 1 IS2Container container = S2ContainerFactory.Create(PATH);
44 1 IDataSource dataSource = (IDataSource) container.GetComponent(typeof(IDataSource));
45  
46 1 IDaoMetaData dmd = new DaoMetaDataImpl(typeof(EmployeeAutoDao),
47   dataSource, BasicCommandFactory.INSTANCE,
48   BasicDataReaderFactory.INSTANCE,new DatabaseMetaDataImpl(dataSource));
49 1 ISqlCommand cmd = dmd.GetSqlCommand("Delete");
50  
51 1 ISqlCommand cmd2 = dmd.GetSqlCommand("GetEmployee");
52 1 Employee emp = (Employee) cmd2.Execute(new Object[] { 7788 });
53 1 int count = (int) cmd.Execute(new Object[] { emp });
54 1 Assert.AreEqual(1, count, "1");
55  
56   //消したデータを入れておく
57 1 string cmdText = "INSERT INTO [dbo].[EMP] VALUES(7788,'SCOTT','ANALYST',7566,CONVERT(datetime,'1982-12-09'),3000.0,NULL,20,CONVERT(datetime,'2005-01-18 13:09:32.213'))";
58 1 System.Data.IDbConnection cn = DataSourceUtil.GetConnection(dataSource);
59 1 System.Data.IDbCommand dbcmd = dataSource.GetCommand(cmdText,cn);
60 1 CommandUtil.ExecuteNonQuery(dataSource,dbcmd);
61  
62   }
63  
64 1 [Test]
65   public void TestExecute2Tx()
66   {
67 1 IS2Container container = S2ContainerFactory.Create(PATH);
68 1 IDataSource dataSource = (IDataSource) container.GetComponent(typeof(IDataSource));
69  
70 1 IDaoMetaData dmd = new DaoMetaDataImpl(typeof(DepartmentAutoDao),
71   dataSource, BasicCommandFactory.INSTANCE,
72   BasicDataReaderFactory.INSTANCE, new DatabaseMetaDataImpl(dataSource));
73 1 ISqlCommand cmd = dmd.GetSqlCommand("Delete");
74 1 Department dept = new Department();
75 1 dept.Deptno = 10;
76 1 int count = (int) cmd.Execute(new Object[] { dept });
77 1 Assert.AreEqual(1, count, "1");
78  
79   //消したデータを入れておく
80 1 string cmdText = "INSERT INTO [dbo].[DEPT] VALUES(10,'ACCOUNTING','NEW YORK',0,1)";
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   //[ExpectedException(typeof(UpdateFailureRuntimeException))]でなくてよい?
87 1 [Test]
88   [ExpectedException(typeof(NotSingleRowUpdatedRuntimeException))]
89   public void TestExecute3Tx()
90   {
91 1 IS2Container container = S2ContainerFactory.Create(PATH);
92 1 IDataSource dataSource = (IDataSource) container.GetComponent(typeof(IDataSource));
93  
94 1 IDaoMetaData dmd = new DaoMetaDataImpl(typeof(DepartmentAutoDao),
95   dataSource, BasicCommandFactory.INSTANCE,
96   BasicDataReaderFactory.INSTANCE, new DatabaseMetaDataImpl(dataSource));
97 1 DeleteAutoStaticCommand cmd = (DeleteAutoStaticCommand) dmd
98   .GetSqlCommand("Delete");
99 1 Department dept = new Department();
100 1 dept.Deptno = 10;
101 1 dept.VersionNo = -1;
102   // try
103   // {
104 1 cmd.Execute(new Object[] { dept });
105 0 Assert.Fail("1");
106   // }
107   // catch (UpdateFailureRuntimeException ex)
108   // {
109   // //System.out.println(ex);
110   // }
111   }
112   }
113   }
114