Skip to content

Commit

Permalink
more type converter test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Aug 26, 2024
1 parent 2479246 commit 7a5aca9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions UnitTests/InternetAddressTypeConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

using System.ComponentModel;

using NUnit.Framework;

using MimeKit;

namespace UnitTests {
Expand All @@ -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 (""));
}
}
Expand Down

0 comments on commit 7a5aca9

Please sign in to comment.