Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 80   Methods: 5
NCLOC: 53 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Extension.Unit\BeanReader.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.Data;
21   using System.Reflection;
22   using Seasar.Framework.Util;
23  
24   namespace Seasar.Extension.Unit
25   {
26   public class BeanReader : Seasar.Extension.DataSets.IDataReader
27   {
28   private DataSet dataSet_;
29  
30   private DataTable table_;
31  
32 1 protected BeanReader() : this(null)
33   {
34   }
35  
36 14 public BeanReader(object bean)
37   {
38 14 dataSet_ = new DataSet();
39 14 table_ = dataSet_.Tables.Add("Bean");
40  
41 14 if (bean != null)
42   {
43 13 Type beanType = bean.GetType();
44 13 SetupColumns(beanType);
45 13 SetupRow(beanType, bean);
46   }
47   }
48  
49 14 protected void SetupColumns(Type beanType)
50   {
51 14 foreach (PropertyInfo pi in beanType.GetProperties())
52   {
53 106 Type propertyType = PropertyUtil.GetPrimitiveType(pi.PropertyType);
54 106 table_.Columns.Add(pi.Name, propertyType);
55   }
56   }
57  
58 14 protected void SetupRow(Type beanType, object bean)
59   {
60 14 DataRow row = table_.NewRow();
61 14 foreach (PropertyInfo pi in beanType.GetProperties())
62   {
63 106 object value = pi.GetValue(bean, null);
64 106 row[pi.Name] = PropertyUtil.GetPrimitiveValue(value);
65   }
66 14 table_.Rows.Add(row);
67 14 row.AcceptChanges();
68   }
69  
70   #region IDataReader メンバ
71  
72 14 public DataSet Read()
73   {
74 14 return dataSet_;
75   }
76  
77   #endregion
78   }
79   }
80