test: cover null input for IsIPv4 and IsIPv6

This commit is contained in:
Oliver Booth 2023-04-02 21:59:35 +01:00
parent 3523ca5468
commit 4fc0d01670
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
1 changed files with 14 additions and 0 deletions

View File

@ -29,6 +29,13 @@ public class IPAddressTests
Assert.IsFalse(_ipv6Address.IsIPv4()); Assert.IsFalse(_ipv6Address.IsIPv4());
} }
[TestMethod]
public void IsIPv4_ShouldThrowArgumentNullException_GivenNullAddress()
{
IPAddress address = null!;
Assert.ThrowsException<ArgumentNullException>(() => address.IsIPv4());
}
[TestMethod] [TestMethod]
public void IsIPv6_ShouldBeFalse_GivenIPv4() public void IsIPv6_ShouldBeFalse_GivenIPv4()
{ {
@ -40,4 +47,11 @@ public class IPAddressTests
{ {
Assert.IsTrue(_ipv6Address.IsIPv6()); Assert.IsTrue(_ipv6Address.IsIPv6());
} }
[TestMethod]
public void IsIPv6_ShouldThrowArgumentNullException_GivenNullAddress()
{
IPAddress address = null!;
Assert.ThrowsException<ArgumentNullException>(() => address.IsIPv6());
}
} }