Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 87   Methods: 5
NCLOC: 60 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Extension.Unit\DictionaryReader.cs 100.0% 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.Collections;
21   using System.Data;
22   using Seasar.Framework.Util;
23  
24   namespace Seasar.Extension.Unit
25   {
26   public class DictionaryReader : Seasar.Extension.DataSets.IDataReader
27   {
28   private DataSet dataSet_;
29  
30   private DataTable table_;
31  
32 2 public DictionaryReader() : this(null)
33   {
34   }
35  
36 9 public DictionaryReader(IDictionary dictionary)
37   {
38 9 dataSet_ = new DataSet();
39 9 table_ = dataSet_.Tables.Add("Map");
40  
41 9 if (dictionary != null)
42   {
43 7 SetupColumns(dictionary);
44 7 SetupRow(dictionary);
45   }
46   }
47  
48 9 protected void SetupColumns(IDictionary dictionary)
49   {
50 9 foreach (string key in dictionary.Keys)
51   {
52 74 object value = dictionary[key];
53 74 if (value != null)
54   {
55 73 Type type = PropertyUtil.GetPrimitiveType(value.GetType());
56 73 table_.Columns.Add(key, type);
57   }
58   else
59   {
60 1 table_.Columns.Add(key);
61   }
62   }
63   }
64  
65 9 protected void SetupRow(IDictionary dictionary)
66   {
67 9 DataRow row = table_.NewRow();
68 9 foreach (DataColumn column in table_.Columns)
69   {
70 74 object value = dictionary[column.ColumnName];
71 74 row[column.ColumnName] = PropertyUtil.GetPrimitiveValue(value);
72   }
73 9 table_.Rows.Add(row);
74 9 row.AcceptChanges();
75   }
76  
77   #region IDataReader メンバ
78  
79 9 public DataSet Read()
80   {
81 9 return dataSet_;
82   }
83  
84   #endregion
85   }
86   }
87