diff --git a/UnitTests/InternetAddressListTypeConverterTests.cs b/UnitTests/InternetAddressListTypeConverterTests.cs index c43529e93d..0785871332 100644 --- a/UnitTests/InternetAddressListTypeConverterTests.cs +++ b/UnitTests/InternetAddressListTypeConverterTests.cs @@ -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 , Leo Fitz , Melinda May "); @@ -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\" , \"Leo Fitz\" , \"Melinda May\" ")); } [Test] - public void TestIsNotValid () + public void TestConvertNotValid () { var converter = TypeDescriptor.GetConverter (typeof (InternetAddressList)); - Assert.That (converter.IsValid (""), Is.False); + Assert.Throws (() => converter.ConvertFrom ("")); + Assert.Throws (() => converter.ConvertFrom (5)); + Assert.Throws (() => converter.ConvertTo (new InternetAddressList (), typeof (int))); } [Test] - public void TestConvertFromNotValid () + public void TestIsNotValid () { var converter = TypeDescriptor.GetConverter (typeof (InternetAddressList)); - Assert.Throws (() => converter.ConvertFrom ("")); + Assert.That (converter.IsValid (""), Is.False); } } } diff --git a/UnitTests/InternetAddressTypeConverterTests.cs b/UnitTests/InternetAddressTypeConverterTests.cs index 13a9fcaac1..deb77dfa63 100644 --- a/UnitTests/InternetAddressTypeConverterTests.cs +++ b/UnitTests/InternetAddressTypeConverterTests.cs @@ -44,33 +44,38 @@ public void TestCanConvert () public void TestIsValid () { var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); - Assert.That (converter.IsValid ("Jeffrey Stedfast "), Is.True); + Assert.That (converter.IsValid ("Unit Tests "), Is.True); } [Test] - public void TestConvertFromValid () + public void TestConvertValid () { var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); - var result = converter.ConvertFrom ("Jeffrey Stedfast "); + var result = converter.ConvertFrom ("Unit Tests "); 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 ("jestedfa@microsoft.com")); + Assert.That (mailbox.Name, Is.EqualTo ("Unit Tests")); + Assert.That (mailbox.Address, Is.EqualTo ("tests@mimekit.net")); + + var text = converter.ConvertTo (mailbox, typeof (string)); + Assert.That (text, Is.EqualTo ("\"Unit Tests\" ")); } [Test] - public void TestIsNotValid () + public void TestConvertNotValid () { var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); - Assert.That (converter.IsValid (""), Is.False); + Assert.Throws (() => converter.ConvertFrom ("")); + Assert.Throws (() => converter.ConvertFrom (5)); + Assert.Throws (() => converter.ConvertTo (new MailboxAddress ("Unit Tests", "tests@mimekit.net"), typeof (int))); } [Test] - public void TestConvertFromNotValid () + public void TestIsNotValid () { var converter = TypeDescriptor.GetConverter (typeof (InternetAddress)); - Assert.Throws (() => converter.ConvertFrom ("")); + Assert.That (converter.IsValid (""), Is.False); } } }