Clover.NET coverage report - Coverage for s2dao.net

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

File Stats: LOC: 137   Methods: 4
NCLOC: 99 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Dao.Tests.Impl\BeanMetaDataDataReaderHandlerTest.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 System.Data;
21   using Seasar.Dao;
22   using Seasar.Dao.Dbms;
23   using Seasar.Dao.Impl;
24   using Seasar.Extension.ADO;
25   using Seasar.Extension.ADO.Impl;
26   using Seasar.Extension.ADO.Types;
27   using Seasar.Framework.Container;
28   using Seasar.Framework.Container.Factory;
29   using Seasar.Framework.Util;
30   using MbUnit.Framework;
31  
32   namespace Seasar.Dao.Tests.Impl
33   {
34   [TestFixture]
35   public class BeanMetaDataDataReaderHandlerTest
36   {
37   private const string PATH = "Tests.dicon";
38   private IBeanMetaData beanMetaData_;
39   private IDataSource dataSource;
40  
41 3 [SetUp]
42   public void SetUp()
43   {
44 3 IS2Container container = S2ContainerFactory.Create(PATH);
45 3 dataSource = (IDataSource) container.GetComponent(typeof(IDataSource));
46  
47 3 IDbConnection cn = DataSourceUtil.GetConnection(dataSource);
48 3 IDbms dbms = new MSSQLServer();
49 3 beanMetaData_ = new BeanMetaDataImpl(typeof(Employee), new DatabaseMetaDataImpl(dataSource), dbms);
50   }
51  
52 1 [Test]
53   public void TestHandle()
54   {
55 1 IDataReaderHandler handler = new BeanMetaDataDataReaderHandler(
56   beanMetaData_);
57 1 String sql = "select emp.*, dept.deptno as deptno_0, dept.dname as dname_0 from emp, dept where empno = 7788 and emp.deptno = dept.deptno";
58 1 IDbConnection cn = DataSourceUtil.GetConnection(dataSource);
59   //PreparedStatement ps = con.prepareStatement(sql);
60 1 IDbCommand cmd = dataSource.GetCommand(sql,cn);
61 1 Employee ret = null;
62 1 try {
63   //ResultSet rs = ps.executeQuery();
64 1 IDataReader rs = cmd.ExecuteReader();
65 1 try {
66 1 ret = (Employee) handler.Handle(rs);
67   } finally {
68   //rs.Close();
69   }
70   } finally {
71   //ps.close();
72   }
73 1 Assert.IsNotNull(ret, "1");
74   //System.out.println(ret.getEmpno() + "," + ret.getEname());
75 1 Department dept = ret.Department;
76 1 Assert.IsNotNull(dept, "2");
77 1 Assert.AreEqual(20, dept.Deptno, "3");
78 1 Assert.AreEqual("RESEARCH", dept.Dname, "4");
79   }
80  
81 1 [Test]
82   public void TestHandle2() {
83 1 IDataReaderHandler handler = new BeanMetaDataDataReaderHandler(
84   beanMetaData_);
85 1 String sql = "select ename, job from emp where empno = 7788";
86 1 IDbConnection cn = DataSourceUtil.GetConnection(dataSource);
87   //PreparedStatement ps = con.prepareStatement(sql);
88 1 IDbCommand cmd = dataSource.GetCommand(sql,cn);
89 1 Employee ret = null;
90 1 try {
91   //ResultSet rs = ps.executeQuery();
92 1 IDataReader rs = cmd.ExecuteReader();
93 1 try
94   {
95 1 ret = (Employee) handler.Handle(rs);
96   } finally {
97   //rs.Close();
98   }
99   } finally {
100   //ps.close();
101   }
102 1 Assert.IsNotNull(ret, "1");
103   //System.out.println(ret.getEmpno() + "," + ret.getEname());
104 1 Department dept = ret.Department;
105 1 Assert.IsNull(dept, "2");
106   }
107  
108 1 [Test]
109   public void TestHandle3() {
110 1 IDataReaderHandler handler = new BeanMetaDataDataReaderHandler(
111   beanMetaData_);
112 1 String sql = "select ename, dept.dname as dname_0 from emp, dept where empno = 7788 and emp.deptno = dept.deptno";
113 1 IDbConnection cn = DataSourceUtil.GetConnection(dataSource);
114   //PreparedStatement ps = con.prepareStatement(sql);
115 1 IDbCommand cmd = dataSource.GetCommand(sql,cn);
116 1 Employee ret = null;
117 1 try {
118   //ResultSet rs = ps.executeQuery();
119 1 IDataReader rs = cmd.ExecuteReader();
120 1 try
121   {
122 1 ret = (Employee) handler.Handle(rs);
123   } finally {
124   //rs.Close();
125   }
126   } finally {
127   //ps.close();
128   }
129 1 Assert.IsNotNull(ret, "1");
130   //System.out.println(ret.getEname());
131 1 Department dept = ret.Department;
132 1 Assert.IsNotNull(dept, "2");
133 1 Assert.AreEqual("RESEARCH", dept.Dname, "3");
134   }
135   }
136   }
137