Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 87   Methods: 3
NCLOC: 67 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Util\DecimalConversionUtil.cs 68.2% 70.8% 66.7% 69.4%
coverage 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  
21   namespace Seasar.Framework.Util
22   {
23   public sealed class DecimalConversionUtil
24   {
25 0 private DecimalConversionUtil()
26   {
27   }
28  
29 165 public static decimal ToDecimal(object o)
30   {
31 165 return ToDecimal(o, null);
32   }
33  
34 165 public static decimal ToDecimal(object o, string pattern)
35   {
36 165 if (o == null || o == DBNull.Value)
37   {
38 0 throw new ArgumentNullException("o");
39   }
40 165 else if (o is decimal)
41   {
42 145 return (decimal) o;
43   }
44 20 else if (o is bool)
45   {
46 0 return Convert.ToDecimal((bool) o);
47   }
48 20 else if (o is byte)
49   {
50 0 return Convert.ToDecimal((byte) o);
51   }
52 20 else if (o is string)
53   {
54 0 return Convert.ToDecimal((string) o);
55   }
56 20 else if (o is double)
57   {
58 10 return Convert.ToDecimal((double) o);
59   }
60 10 else if (o is int)
61   {
62 7 return Convert.ToDecimal((int) o);
63   }
64 3 else if (o is long)
65   {
66 2 return Convert.ToDecimal((long) o);
67   }
68 1 else if (o is short)
69   {
70 0 return Convert.ToDecimal((short) o);
71   }
72 1 else if (o is float)
73   {
74 0 return Convert.ToDecimal((float) o);
75   }
76 1 else if (o is DateTime)
77   {
78 0 return Convert.ToDecimal(((DateTime) o).Ticks);
79   }
80   else
81   {
82 1 return Convert.ToDecimal(o.ToString());
83   }
84   }
85   }
86   }
87