Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 124   Methods: 1
NCLOC: 96 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Tests.Extension.DataSets\Impl\XlsReaderTest1.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 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   using IDataReader = Seasar.Extension.DataSets.IDataReader;
28  
29   namespace Seasar.Tests.Extension.DataSets.Impl
30   {
31   [TestFixture]
32   public class XlsReaderTest1 : S2TestCase
33   {
34   private const string PATH = "Seasar.Tests.Extension.DataSets.Impl.XlsReaderTest1.xls";
35  
36 1 [Test]
37   public void TestRead()
38   {
39 1 using (Stream stream = ResourceUtil.GetResourceAsStream(PATH, Assembly.GetExecutingAssembly()))
40   {
41 1 IDataReader reader = new XlsReader(stream);
42 1 DataSet dataSet = reader.Read();
43  
44 1 Assert.AreEqual(1, dataSet.Tables.Count);
45  
46   // type valid
47 1 Assert.AreEqual(6, dataSet.Tables["Type"].Columns.Count);
48 1 Assert.AreEqual(4, dataSet.Tables["Type"].Rows.Count);
49  
50 1 Assert.AreEqual(typeof(string), dataSet.Tables["Type"].Columns["stringValue"].DataType);
51 1 Assert.AreEqual(typeof(double), dataSet.Tables["Type"].Columns["intValue"].DataType);
52 1 Assert.AreEqual(typeof(double), dataSet.Tables["Type"].Columns["longValue"].DataType);
53 1 Assert.AreEqual(typeof(double), dataSet.Tables["Type"].Columns["decimalValue"].DataType);
54 1 Assert.AreEqual(typeof(double), dataSet.Tables["Type"].Columns["floatValue"].DataType);
55 1 Assert.AreEqual(typeof(DateTime), dataSet.Tables["Type"].Columns["dateTimeValue"].DataType);
56  
57 1 Assert.AreEqual("stringValue", dataSet.Tables["Type"].Columns["stringValue"].ColumnName);
58 1 Assert.AreEqual("intValue", dataSet.Tables["Type"].Columns["intValue"].ColumnName);
59 1 Assert.AreEqual("longValue", dataSet.Tables["Type"].Columns["longValue"].ColumnName);
60 1 Assert.AreEqual("decimalValue", dataSet.Tables["Type"].Columns["decimalValue"].ColumnName);
61 1 Assert.AreEqual("floatValue", dataSet.Tables["Type"].Columns["floatValue"].ColumnName);
62 1 Assert.AreEqual("dateTimeValue", dataSet.Tables["Type"].Columns["dateTimeValue"].ColumnName);
63  
64 1 Assert.AreEqual("a", dataSet.Tables["Type"].Rows[0]["stringValue"]);
65 1 Assert.AreEqual(int.MinValue, dataSet.Tables["Type"].Rows[0]["intValue"]);
66 1 Assert.AreEqual(
67   -999999999999999,
68   dataSet.Tables["Type"].Rows[0]["longValue"],
69   "Excelの有効桁数(15桁)まで認識すれば、とりあえずOK。指数の場合は、保留。"
70   );
71 1 Assert.AreEqual(
72   -999999999999999m,
73   dataSet.Tables["Type"].Rows[0]["decimalValue"],
74   "Excelの有効桁数(15桁)まで認識すれば、とりあえずOK。指数の場合は、保留。"
75   );
76 1 Assert.AreEqual(float.MinValue, dataSet.Tables["Type"].Rows[0]["floatValue"]);
77 1 Assert.AreEqual(
78   new DateTime(1900, 1, 1, 0, 0, 0),
79   dataSet.Tables["Type"].Rows[0]["dateTimeValue"],
80   "Excelの計算で使用できる最も古い日付。"
81   );
82  
83 1 Assert.AreEqual("日本語~", dataSet.Tables["Type"].Rows[1]["stringValue"]);
84 1 Assert.AreEqual(0, dataSet.Tables["Type"].Rows[1]["intValue"]);
85 1 Assert.AreEqual(0, dataSet.Tables["Type"].Rows[1]["longValue"]);
86 1 Assert.AreEqual(0m, dataSet.Tables["Type"].Rows[1]["decimalValue"]);
87 1 Assert.AreEqual(0f, dataSet.Tables["Type"].Rows[1]["floatValue"]);
88 1 Assert.AreEqual(
89   new DateTime(1999, 12, 31, 23, 59, 59),
90   dataSet.Tables["Type"].Rows[1]["dateTimeValue"]
91   );
92  
93 1 Assert.AreEqual(DBNull.Value, dataSet.Tables["Type"].Rows[2]["stringValue"]);
94 1 Assert.AreEqual(DBNull.Value, dataSet.Tables["Type"].Rows[2]["intValue"]);
95 1 Assert.AreEqual(DBNull.Value, dataSet.Tables["Type"].Rows[2]["longValue"]);
96 1 Assert.AreEqual(DBNull.Value, dataSet.Tables["Type"].Rows[2]["decimalValue"]);
97 1 Assert.AreEqual(DBNull.Value, dataSet.Tables["Type"].Rows[2]["floatValue"]);
98 1 Assert.AreEqual(DBNull.Value, dataSet.Tables["Type"].Rows[2]["dateTimeValue"]);
99  
100 1 Assert.AreEqual(
101   string.Empty.PadLeft(32767, '*'),
102   dataSet.Tables["Type"].Rows[3]["stringValue"],
103   "セルに入力できる最大文字数は、32767文字。※表示できるのは1024文字。"
104   );
105 1 Assert.AreEqual(int.MaxValue, dataSet.Tables["Type"].Rows[3]["intValue"]);
106 1 Assert.AreEqual(
107   999999999999999,
108   dataSet.Tables["Type"].Rows[3]["longValue"]
109   );
110 1 Assert.AreEqual(
111   999999999999999m,
112   dataSet.Tables["Type"].Rows[3]["decimalValue"]
113   );
114 1 Assert.AreEqual(float.MaxValue, dataSet.Tables["Type"].Rows[3]["floatValue"]);
115 1 Assert.AreEqual(
116   new DateTime(9999, 12, 31, 23, 59, 59),
117   dataSet.Tables["Type"].Rows[3]["dateTimeValue"],
118   "Excelの計算で使用できる最も新しい日付。"
119   );
120   }
121   }
122   }
123   }
124