@@ -44,33 +44,38 @@ public void TestCanConvert ()
44
44
public void TestIsValid ( )
45
45
{
46
46
var converter = TypeDescriptor . GetConverter ( typeof ( InternetAddress ) ) ;
47
- Assert . That ( converter . IsValid ( "Jeffrey Stedfast <[email protected] >" ) , Is . True ) ;
47
+ Assert . That ( converter . IsValid ( "Unit Tests <[email protected] >" ) , Is . True ) ;
48
48
}
49
49
50
50
[ Test ]
51
- public void TestConvertFromValid ( )
51
+ public void TestConvertValid ( )
52
52
{
53
53
var converter = TypeDescriptor . GetConverter ( typeof ( InternetAddress ) ) ;
54
- var result = converter . ConvertFrom ( "Jeffrey Stedfast <[email protected] >" ) ;
54
+ var result = converter . ConvertFrom ( "Unit Tests <[email protected] >" ) ;
55
55
Assert . That ( result , Is . InstanceOf ( typeof ( MailboxAddress ) ) ) ;
56
56
57
57
var mailbox = ( MailboxAddress ) result ;
58
- Assert . That ( mailbox . Name , Is . EqualTo ( "Jeffrey Stedfast" ) ) ;
59
- Assert . That ( mailbox . Address , Is . EqualTo ( "[email protected] " ) ) ;
58
+ Assert . That ( mailbox . Name , Is . EqualTo ( "Unit Tests" ) ) ;
59
+ Assert . That ( mailbox . Address , Is . EqualTo ( "[email protected] " ) ) ;
60
+
61
+ var text = converter . ConvertTo ( mailbox , typeof ( string ) ) ;
62
+ Assert . That ( text , Is . EqualTo ( "\" Unit Tests\" <[email protected] >" ) ) ;
60
63
}
61
64
62
65
[ Test ]
63
- public void TestIsNotValid ( )
66
+ public void TestConvertNotValid ( )
64
67
{
65
68
var converter = TypeDescriptor . GetConverter ( typeof ( InternetAddress ) ) ;
66
- Assert . That ( converter . IsValid ( "" ) , Is . False ) ;
69
+ Assert . Throws < ParseException > ( ( ) => converter . ConvertFrom ( "" ) ) ;
70
+ Assert . Throws < NotSupportedException > ( ( ) => converter . ConvertFrom ( 5 ) ) ;
71
+ Assert . Throws < NotSupportedException > ( ( ) => converter . ConvertTo ( new MailboxAddress ( "Unit Tests" , "[email protected] " ) , typeof ( int ) ) ) ;
67
72
}
68
73
69
74
[ Test ]
70
- public void TestConvertFromNotValid ( )
75
+ public void TestIsNotValid ( )
71
76
{
72
77
var converter = TypeDescriptor . GetConverter ( typeof ( InternetAddress ) ) ;
73
- Assert . Throws < ParseException > ( ( ) => converter . ConvertFrom ( "" ) ) ;
78
+ Assert . That ( converter . IsValid ( "" ) , Is . False ) ;
74
79
}
75
80
}
76
81
}
0 commit comments