-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
14 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 |
---|---|---|
|
@@ -26,8 +26,6 @@ | |
|
||
using System.ComponentModel; | ||
|
||
using NUnit.Framework; | ||
|
||
using MimeKit; | ||
|
||
namespace UnitTests { | ||
|
@@ -37,39 +35,41 @@ public class InternetAddressTypeConverterTests | |
[Test] | ||
public void TestCanConvert () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof(InternetAddress)); | ||
Assert.True (converter.CanConvertFrom (typeof(string))); | ||
Assert.True (converter.CanConvertTo (typeof(string))); | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); | ||
Assert.That (converter.CanConvertFrom(typeof (string)), Is.True); | ||
Assert.That (converter.CanConvertTo (typeof (string)), Is.True); | ||
} | ||
|
||
[Test] | ||
public void TestIsValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof(InternetAddress)); | ||
Assert.True (converter.IsValid ("Jeffrey Stedfast <[email protected]>")); | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); | ||
Assert.That (converter.IsValid ("Jeffrey Stedfast <[email protected]>"), Is.True); | ||
} | ||
|
||
[Test] | ||
public void TestConvertFromValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof(InternetAddress)); | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); | ||
var result = converter.ConvertFrom ("Jeffrey Stedfast <[email protected]>"); | ||
Assert.IsInstanceOf<MailboxAddress> (result); | ||
Assert.AreEqual ("Jeffrey Stedfast", ((MailboxAddress)result).Name); | ||
Assert.AreEqual ("[email protected]", ((MailboxAddress)result).Address); | ||
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]")); | ||
} | ||
|
||
[Test] | ||
public void TestIsNotValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof(InternetAddress)); | ||
Assert.False (converter.IsValid ("")); | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); | ||
Assert.That (converter.IsValid (""), Is.False); | ||
} | ||
|
||
[Test] | ||
public void TestConvertFromNotValid () | ||
{ | ||
var converter = TypeDescriptor.GetConverter (typeof(InternetAddress)); | ||
var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); | ||
Assert.Throws<ParseException> (() => converter.ConvertFrom ("")); | ||
} | ||
} | ||
|