Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 124   Methods: 7
NCLOC: 97 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Extension.DataSets\Impl\XlsReaderTest.cs 100.0% 88.5% 85.7% 89.7%
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   using MbUnit.Framework;
24   using Seasar.Extension.DataSets.Impl;
25   using Seasar.Extension.Unit;
26   using Seasar.Framework.Util;
27  
28   namespace Seasar.Tests.Extension.DataSets.Impl
29   {
30   [TestFixture]
31   public class XlsReaderTest : S2TestCase
32   {
33   private const string PATH = "Seasar.Tests.Extension.DataSets.Impl.XlsReaderImplTest.xls";
34  
35   private DataSet dataSet_;
36  
37 5 [SetUp]
38   public void SetUp()
39   {
40 5 using (Stream stream = ResourceUtil.GetResourceAsStream(PATH, Assembly.GetExecutingAssembly()))
41   {
42 5 dataSet_ = new XlsReader(stream).Read();
43   }
44   }
45  
46 1 [Test]
47   public void TestCreateTable()
48   {
49 1 Assert.AreEqual(4, dataSet_.Tables.Count, "1");
50 1 DataSetInspector.OutWriteLine(dataSet_);
51   }
52  
53 1 [Test]
54   public void TestSetupColumns()
55   {
56   // Java版と違い、テーブル順でソートされている?ので、indexではなく、nameで取得。
57 1 DataTable table = dataSet_.Tables["TEST_TABLE"];
58 1 Assert.AreEqual(4, table.Columns.Count, "1");
59 5 for (int i = 0; i < table.Columns.Count; ++i)
60   {
61 4 Assert.AreEqual("COLUMN" + i, table.Columns[i].ColumnName, "2");
62   }
63   }
64  
65 1 [Test]
66   public void TestSetupRows()
67   {
68 1 DataTable table = dataSet_.Tables["TEST_TABLE"];
69 1 Assert.AreEqual(12, table.Rows.Count, "1");
70 13 for (int i = 0; i < table.Rows.Count; ++i)
71   {
72 12 DataRow row = table.Rows[i];
73 60 for (int j = 0; j < table.Columns.Count; ++j)
74   {
75 48 Assert.AreEqual("row " + i + " col " + j, row[j], "2");
76   }
77   }
78 1 DataTable table2 = dataSet_.Tables["EMPTY_TABLE"];
79 1 Assert.AreEqual(0, table2.Rows.Count, "3");
80   }
81  
82 1 [Test]
83   public void TestGetValue()
84   {
85 1 DataTable table = dataSet_.Tables["あ"];
86 1 DataRow row = table.Rows[0];
87 1 Assert.AreEqual(
88   new DateTime(2004, 3, 22),
89   row[0],
90   "1"
91   );
92 1 Assert.AreEqual(
93   123m,
94   row[1],
95   "2"
96   );
97 1 Assert.AreEqual(
98   "\u3042",
99   row[2],
100   "3"
101   );
102   }
103  
104 0 [Ignore("BASE64_FORMAT未対応のため")]
105   public void TestGetValueIgnore()
106   {
107   DataTable table = dataSet_.Tables["あ"];
108   DataRow row = table.Rows[0];
109   Assert.AreEqual(
110   "YWJj",
111   Convert.ToBase64String((byte[]) row[3]),
112   "4"
113   );
114   }
115  
116 1 [Test]
117   public void TestDataRowState()
118   {
119 1 DataTable ret = dataSet_.Tables["TEST_TABLE"];
120 1 Assert.AreEqual(DataRowState.Added, ret.Rows[0].RowState);
121   }
122   }
123   }
124