Clover.NET coverage report - Coverage

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

File Stats: LOC: 141   Methods: 8
NCLOC: 82 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
TypeHandlers\UnknownTypeHandler.cs 50.0 % 65.0 % 62.5 % 61.1 %
coverage coverage
1   #region Apache Notice
2   /*****************************************************************************
3   * $Header: $
4   * $Revision: $
5   * $Date: $
6   *
7   * iBATIS.NET Data Mapper
8   * Copyright (C) 2004 - Gilles Bayon
9   *
10   *
11   * Licensed under the Apache License, Version 2.0 (the "License");
12   * you may not use this file except in compliance with the License.
13   * You may obtain a copy of the License at
14   *
15   * http://www.apache.org/licenses/LICENSE-2.0
16   *
17   * Unless required by applicable law or agreed to in writing, software
18   * distributed under the License is distributed on an "AS IS" BASIS,
19   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   * See the License for the specific language governing permissions and
21   * limitations under the License.
22   *
23   ********************************************************************************/
24   #endregion
25  
26   #region Using
27  
28   using System;
29   using System.Data;
30   using IBatisNet.DataMapper.Configuration.ParameterMapping;
31   using IBatisNet.DataMapper.Configuration.ResultMapping;
32  
33   #endregion
34  
35   namespace IBatisNet.DataMapper.TypeHandlers
36   {
37   /// <summary>
38   /// Implementation of TypeHandler for dealing with unknown types
39   /// </summary>
40   internal class UnknownTypeHandler : BaseTypeHandler
41   {
42  
43   private TypeHandlerFactory _factory = null;
44  
45   /// <summary>
46   /// Constructor to create via a factory
47   /// </summary>
48   /// <param name="factory">the factory to associate this with</param>
49 170 public UnknownTypeHandler(TypeHandlerFactory factory)
50   {
51 170 _factory = factory;
52   }
53   /// <summary>
54   /// Performs processing on a value before it is used to set
55   /// the parameter of a IDbCommand.
56   /// </summary>
57   /// <param name="dataParameter"></param>
58   /// <param name="parameterValue">The value to be set</param>
59   /// <param name="dbType">Data base type</param>
60 435 public override void SetParameter(IDataParameter dataParameter, object parameterValue, string dbType)
61   {
62 435 if (parameterValue!=null)
63   {
64 435 ITypeHandler handler = _factory.GetTypeHandler( parameterValue.GetType(), dbType );
65 435 handler.SetParameter(dataParameter, parameterValue, dbType);
66   }
67   else
68   {
69   // When sending a null parameter value to the server,
70   // the user must specify DBNull, not null.
71 0 dataParameter.Value = System.DBNull.Value;
72   }
73   }
74  
75 24 public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
76   {
77 24 int index = dataReader.GetOrdinal(mapping.ColumnName);
78  
79 24 if (dataReader.IsDBNull(index) == true)
80   {
81 2 return System.DBNull.Value;
82   }
83   else
84   {
85 22 return dataReader.GetValue(index);
86   }
87   }
88  
89 0 public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
90   {
91   if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
92   {
93   return System.DBNull.Value;
94   }
95   else
96   {
97   return dataReader.GetValue(mapping.ColumnIndex);
98   }
99   }
100  
101 0 public override object ValueOf(Type type, string s)
102   {
103   return s;
104   }
105  
106 5 public override object GetDataBaseValue(object outputValue, Type parameterType)
107   {
108 5 return outputValue;
109   }
110  
111  
112 0 public override bool IsSimpleType
113   {
114   get
115   {
116   return true;
117   }
118   }
119  
120   /// <summary>
121   /// Compares two values (that this handler deals with) for equality
122   /// </summary>
123   /// <param name="obj">one of the objects</param>
124   /// <param name="str">the other object as a String</param>
125   /// <returns>true if they are equal</returns>
126 39 public override bool Equals(object obj, string str)
127   {
128 39 if (obj == null || str == null)
129   {
130 0 return obj == str;
131   }
132   else
133   {
134 39 ITypeHandler handler = _factory.GetTypeHandler(obj.GetType());
135 39 object castedObject = handler.ValueOf(obj.GetType(), str);
136 39 return obj.Equals(castedObject);
137   }
138   }
139   }
140   }
141