Clover.NET coverage report - Coverage

Coverage timestamp: Friday, May 20, 2005 9:17:00 PM

File Stats: LOC: 113   Methods: 6
NCLOC: 60 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
TypeHandlers\EnumTypeHandler.cs 50.0 % 54.5 % 50.0 % 52.4 %
coverage coverage
1  
2   #region Apache Notice
3   /*****************************************************************************
4   * $Header: $
5   * $Revision: $
6   * $Date: $
7   *
8   * iBATIS.NET Data Mapper
9   * Copyright (C) 2004 - Gilles Bayon
10   *
11   *
12   * Licensed under the Apache License, Version 2.0 (the "License");
13   * you may not use this file except in compliance with the License.
14   * You may obtain a copy of the License at
15   *
16   * http://www.apache.org/licenses/LICENSE-2.0
17   *
18   * Unless required by applicable law or agreed to in writing, software
19   * distributed under the License is distributed on an "AS IS" BASIS,
20   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21   * See the License for the specific language governing permissions and
22   * limitations under the License.
23   *
24   ********************************************************************************/
25   #endregion
26  
27   #region Using
28  
29   using System;
30   using System.Data;
31   using System.Globalization;
32   using System.Reflection;
33   using IBatisNet.Common.Utilities.Objects;
34   using IBatisNet.DataMapper.Configuration.ParameterMapping;
35   using IBatisNet.DataMapper.Configuration.ResultMapping;
36   using IBatisNet.DataMapper.Exceptions;
37   #endregion
38  
39  
40  
41   namespace IBatisNet.DataMapper.TypeHandlers
42   {
43   /// <summary>
44   /// Summary description for EnumTypeHandler.
45   /// </summary>
46   internal class EnumTypeHandler : BaseTypeHandler
47   {
48  
49   /// <summary>
50   /// Sets a parameter on a IDbCommand
51   /// </summary>
52   /// <param name="dataParameter">the parameter</param>
53   /// <param name="parameterValue">the parameter value</param>
54   /// <param name="dbType">the dbType of the parameter</param>
55 5 public override void SetParameter(IDataParameter dataParameter, object parameterValue, string dbType)
56   {
57 5 dataParameter.Value = Convert.ChangeType( parameterValue, Enum.GetUnderlyingType( parameterValue.GetType() ) );;
58   }
59  
60   /// <summary>
61   ///
62   /// </summary>
63   /// <param name="mapping"></param>
64   /// <param name="dataReader"></param>
65   /// <returns></returns>
66 12 public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
67   {
68 12 int index = dataReader.GetOrdinal(mapping.ColumnName);
69  
70 12 if (dataReader.IsDBNull(index) == true)
71   {
72 1 return System.DBNull.Value;
73   }
74   else
75   {
76 11 return Enum.Parse(mapping.PropertyInfo.PropertyType, dataReader.GetValue(index).ToString());
77   }
78   }
79  
80 0 public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
81   {
82   if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
83   {
84   return System.DBNull.Value;
85   }
86   else
87   {
88   return Enum.Parse(mapping.PropertyInfo.PropertyType, dataReader.GetValue(mapping.ColumnIndex).ToString());
89   }
90   }
91  
92  
93 3 public override object ValueOf(Type type, string s)
94   {
95 3 return Enum.Parse(type, s);
96   }
97  
98 0 public override object GetDataBaseValue(object outputValue, Type parameterType )
99   {
100   return Enum.Parse(parameterType, outputValue.ToString());
101   }
102  
103  
104 0 public override bool IsSimpleType
105   {
106   get
107   {
108   return true;
109   }
110   }
111   }
112   }
113