@@ -14,10 +14,8 @@ public void Can_Convert_DateTimeOffsets()
14
14
var dto = new DateTimeOffset ( new DateTime ( 2002 , 2 , 2 ) , TimeSpan . FromHours ( 4 ) ) ;
15
15
string formattedString = dto . ToString ( "O" ) ;
16
16
17
- var typeConverter = new RuntimeTypeConverter ( ) ;
18
-
19
17
// Act
20
- object result = typeConverter . ConvertType ( formattedString , typeof ( DateTimeOffset ) ) ;
18
+ object result = RuntimeTypeConverter . ConvertType ( formattedString , typeof ( DateTimeOffset ) ) ;
21
19
22
20
// Assert
23
21
Assert . Equal ( dto , result ) ;
@@ -29,10 +27,8 @@ public void Bad_DateTimeOffset_String_Throws()
29
27
// Arrange
30
28
const string formattedString = "this_is_not_a_valid_dto" ;
31
29
32
- var typeConverter = new RuntimeTypeConverter ( ) ;
33
-
34
30
// Act
35
- Action action = ( ) => typeConverter . ConvertType ( formattedString , typeof ( DateTimeOffset ) ) ;
31
+ Action action = ( ) => RuntimeTypeConverter . ConvertType ( formattedString , typeof ( DateTimeOffset ) ) ;
36
32
37
33
// Assert
38
34
Assert . Throws < FormatException > ( action ) ;
@@ -44,10 +40,8 @@ public void Can_Convert_Enums()
44
40
// Arrange
45
41
const string formattedString = "1" ;
46
42
47
- var typeConverter = new RuntimeTypeConverter ( ) ;
48
-
49
43
// Act
50
- object result = typeConverter . ConvertType ( formattedString , typeof ( TestEnum ) ) ;
44
+ object result = RuntimeTypeConverter . ConvertType ( formattedString , typeof ( TestEnum ) ) ;
51
45
52
46
// Assert
53
47
Assert . Equal ( TestEnum . Test , result ) ;
@@ -60,10 +54,8 @@ public void ConvertType_Returns_Value_If_Type_Is_Same()
60
54
var val = new ComplexType ( ) ;
61
55
Type type = val . GetType ( ) ;
62
56
63
- var typeConverter = new RuntimeTypeConverter ( ) ;
64
-
65
57
// Act
66
- object result = typeConverter . ConvertType ( val , type ) ;
58
+ object result = RuntimeTypeConverter . ConvertType ( val , type ) ;
67
59
68
60
// Assert
69
61
Assert . Equal ( val , result ) ;
@@ -78,11 +70,9 @@ public void ConvertType_Returns_Value_If_Type_Is_Assignable()
78
70
Type baseType = typeof ( BaseType ) ;
79
71
Type iType = typeof ( IType ) ;
80
72
81
- var typeConverter = new RuntimeTypeConverter ( ) ;
82
-
83
73
// Act
84
- object baseResult = typeConverter . ConvertType ( val , baseType ) ;
85
- object iResult = typeConverter . ConvertType ( val , iType ) ;
74
+ object baseResult = RuntimeTypeConverter . ConvertType ( val , baseType ) ;
75
+ object iResult = RuntimeTypeConverter . ConvertType ( val , iType ) ;
86
76
87
77
// Assert
88
78
Assert . Equal ( val , baseResult ) ;
@@ -102,12 +92,10 @@ public void ConvertType_Returns_Default_Value_For_Empty_Strings()
102
92
{ typeof ( Guid ) , Guid . Empty }
103
93
} ;
104
94
105
- var typeConverter = new RuntimeTypeConverter ( ) ;
106
-
107
95
foreach ( KeyValuePair < Type , object > pair in data )
108
96
{
109
97
// Act
110
- object result = typeConverter . ConvertType ( string . Empty , pair . Key ) ;
98
+ object result = RuntimeTypeConverter . ConvertType ( string . Empty , pair . Key ) ;
111
99
112
100
// Assert
113
101
Assert . Equal ( pair . Value , result ) ;
@@ -121,10 +109,8 @@ public void Can_Convert_TimeSpans()
121
109
TimeSpan timeSpan = TimeSpan . FromMinutes ( 45 ) ;
122
110
string stringSpan = timeSpan . ToString ( ) ;
123
111
124
- var typeConverter = new RuntimeTypeConverter ( ) ;
125
-
126
112
// Act
127
- object result = typeConverter . ConvertType ( stringSpan , typeof ( TimeSpan ) ) ;
113
+ object result = RuntimeTypeConverter . ConvertType ( stringSpan , typeof ( TimeSpan ) ) ;
128
114
129
115
// Assert
130
116
Assert . Equal ( timeSpan , result ) ;
@@ -136,10 +122,8 @@ public void Bad_TimeSpanString_Throws()
136
122
// Arrange
137
123
const string formattedString = "this_is_not_a_valid_timespan" ;
138
124
139
- var typeConverter = new RuntimeTypeConverter ( ) ;
140
-
141
125
// Act
142
- Action action = ( ) => typeConverter . ConvertType ( formattedString , typeof ( TimeSpan ) ) ;
126
+ Action action = ( ) => RuntimeTypeConverter . ConvertType ( formattedString , typeof ( TimeSpan ) ) ;
143
127
144
128
// Assert
145
129
Assert . Throws < FormatException > ( action ) ;
0 commit comments