-
-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more InternetAddress[List]TypeConverter tests
- Loading branch information
Showing
2 changed files
with
24 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ public void TestIsValid () | |
} | ||
|
||
[Test] | ||
public void TestConvertFromValid () | ||
public void TestConvertValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddressList)); | ||
var result = converter.ConvertFrom ("Skye <[email protected]>, Leo Fitz <[email protected]>, Melinda May <[email protected]>"); | ||
|
@@ -60,20 +60,25 @@ public void TestConvertFromValid () | |
Assert.That (list[0].Name, Is.EqualTo ("Skye")); | ||
Assert.That (list[1].Name, Is.EqualTo ("Leo Fitz")); | ||
Assert.That (list[2].Name, Is.EqualTo ("Melinda May")); | ||
|
||
var text = converter.ConvertTo (list, typeof (string)); | ||
Assert.That (text, Is.EqualTo ("\"Skye\" <[email protected]>, \"Leo Fitz\" <[email protected]>, \"Melinda May\" <[email protected]>")); | ||
} | ||
|
||
[Test] | ||
public void TestIsNotValid () | ||
public void TestConvertNotValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddressList)); | ||
Assert.That (converter.IsValid (""), Is.False); | ||
Assert.Throws<ParseException> (() => converter.ConvertFrom ("")); | ||
Assert.Throws<NotSupportedException> (() => converter.ConvertFrom (5)); | ||
Assert.Throws<NotSupportedException> (() => converter.ConvertTo (new InternetAddressList (), typeof (int))); | ||
} | ||
|
||
[Test] | ||
public void TestConvertFromNotValid () | ||
public void TestIsNotValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddressList)); | ||
Assert.Throws<ParseException> (() => converter.ConvertFrom ("")); | ||
Assert.That (converter.IsValid (""), Is.False); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,33 +44,38 @@ public void TestCanConvert () | |
public void TestIsValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); | ||
Assert.That (converter.IsValid ("Jeffrey Stedfast <[email protected]>"), Is.True); | ||
Assert.That (converter.IsValid ("Unit Tests <[email protected]>"), Is.True); | ||
} | ||
|
||
[Test] | ||
public void TestConvertFromValid () | ||
public void TestConvertValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); | ||
var result = converter.ConvertFrom ("Jeffrey Stedfast <[email protected]>"); | ||
var result = converter.ConvertFrom ("Unit Tests <[email protected]>"); | ||
Assert.That (result, Is.InstanceOf (typeof (MailboxAddress))); | ||
|
||
var mailbox = (MailboxAddress) result; | ||
Assert.That (mailbox.Name, Is.EqualTo ("Jeffrey Stedfast")); | ||
Assert.That (mailbox.Address, Is.EqualTo ("[email protected]")); | ||
Assert.That (mailbox.Name, Is.EqualTo ("Unit Tests")); | ||
Assert.That (mailbox.Address, Is.EqualTo ("[email protected]")); | ||
|
||
var text = converter.ConvertTo (mailbox, typeof (string)); | ||
Assert.That (text, Is.EqualTo ("\"Unit Tests\" <[email protected]>")); | ||
} | ||
|
||
[Test] | ||
public void TestIsNotValid () | ||
public void TestConvertNotValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); | ||
Assert.That (converter.IsValid (""), Is.False); | ||
Assert.Throws<ParseException> (() => converter.ConvertFrom ("")); | ||
Assert.Throws<NotSupportedException> (() => converter.ConvertFrom (5)); | ||
Assert.Throws<NotSupportedException> (() => converter.ConvertTo (new MailboxAddress ("Unit Tests", "[email protected]"), typeof (int))); | ||
} | ||
|
||
[Test] | ||
public void TestConvertFromNotValid () | ||
public void TestIsNotValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); | ||
Assert.Throws<ParseException> (() => converter.ConvertFrom ("")); | ||
Assert.That (converter.IsValid (""), Is.False); | ||
} | ||
} | ||
} |