Skip to content

Commit c8ca5b7

Browse files
committed
Add new unit tests that are meant to throw
1 parent fdc2c67 commit c8ca5b7

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Tests/HttpUnitTests/WebHeaderCollectionTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55

66
using nanoFramework.TestFramework;
7+
using System;
78
using System.Net;
89

910
namespace HttpUnitTests
@@ -68,5 +69,33 @@ public void Add_Authorization_ColonWithSpaceOnly()
6869
string value = headers["Authorization"];
6970
Assert.AreEqual(string.Empty, value);
7071
}
72+
73+
[TestMethod]
74+
public void Add_NullHeader_ThrowsArgumentNullException()
75+
{
76+
var headers = new WebHeaderCollection();
77+
Assert.ThrowsException(typeof(ArgumentNullException), () => headers.Add(null));
78+
}
79+
80+
[TestMethod]
81+
public void Add_EmptyHeader_ThrowsArgumentNullException()
82+
{
83+
var headers = new WebHeaderCollection();
84+
Assert.ThrowsException(typeof(ArgumentNullException), () => headers.Add(string.Empty));
85+
}
86+
87+
[TestMethod]
88+
public void Add_HeaderWithNoColon_ThrowsArgumentException()
89+
{
90+
var headers = new WebHeaderCollection();
91+
Assert.ThrowsException(typeof(ArgumentException), () => headers.Add("Authorization"));
92+
}
93+
94+
[TestMethod]
95+
public void Add_HeaderNameWithSpace_ThrowsArgumentException()
96+
{
97+
var headers = new WebHeaderCollection();
98+
Assert.ThrowsException(typeof(ArgumentException), () => headers.Add("My Header: value"));
99+
}
71100
}
72101
}

0 commit comments

Comments
 (0)