Skip to content

Commit

Permalink
Added a few more tests for HeaderList
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Jun 22, 2024
1 parent 9e11593 commit 863881c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion UnitTests/HeaderListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
//

using System.Text;
using System.Collections;

using MimeKit;

Expand Down Expand Up @@ -163,6 +164,24 @@ public void TestArgumentExceptions ()
Assert.Throws<ArgumentNullException> (() => list[0] = null);
}

[Test]
public void TestGetEnumerator ()
{
var headers = new HeaderList {
new Header ("From", "Joe Schmoe <joe.schmoe@example.com>"),
new Header ("To", "Jane Doe <jane@example.com>"),
new Header ("Subject", "Hello, World!"),
new Header ("Date", "Wed, 17 Jul 2019 16:00:00 -0400")
};
var copied = new Header[headers.Count];
int i = 0;

headers.CopyTo (copied, 0);

foreach (Header header in (IEnumerable) headers)
Assert.That (header, Is.EqualTo (copied[i++]));
}

[Test]
public void TestRemovingHeaders ()
{
Expand Down Expand Up @@ -296,7 +315,8 @@ public void TestSetHeaderAtIndex ()
changedCount++;
};

// setting the same header should not trigger a change eventheaders[index] = subject;
// setting the same header should not trigger a change event
headers[index] = subject;
Assert.That (changedCount, Is.EqualTo (0), "Setting the same header at an index should not raise a Changed event");

// setting a header with the same field name/id
Expand Down

0 comments on commit 863881c

Please sign in to comment.