1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 19:48:46 +00:00

[ci skip] Use more meaningful test names for EndPointTests

This commit is contained in:
Oliver Booth 2022-04-25 10:34:36 +01:00
parent 9a089a9ae2
commit 907687a883
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634

View File

@ -8,63 +8,63 @@ namespace X10D.Tests.Net;
public class EndPointTests
{
[TestMethod]
public void GetHostNullShouldThrow()
{
Assert.ThrowsException<ArgumentNullException>(() => ((IPEndPoint?)null)!.GetHost());
Assert.ThrowsException<ArgumentNullException>(() => ((DnsEndPoint?)null)!.GetHost());
}
[TestMethod]
public void GetPortNullShouldThrow()
{
Assert.ThrowsException<ArgumentNullException>(() => ((IPEndPoint?)null)!.GetPort());
Assert.ThrowsException<ArgumentNullException>(() => ((DnsEndPoint?)null)!.GetPort());
}
[TestMethod]
public void DnsEndPointGetHostShouldBeLocalhost()
public void GetHost_ShouldBeLocalhost_GivenLocalhostDnsEndPoint()
{
var endPoint = new DnsEndPoint("localhost", 1234);
Assert.AreEqual("localhost", endPoint.GetHost());
}
[TestMethod]
public void DnsEndPointGetPortShouldBe1234()
{
var endPoint = new DnsEndPoint("localhost", 1234);
Assert.AreEqual(1234, endPoint.GetPort());
}
[TestMethod]
public void IPEndPointIPv4LoopbackGetHostShouldBe127_0_0_1()
public void GetHost_ShouldBe127001_GivenLoopbackIPEndPoint()
{
var endPoint = new IPEndPoint(IPAddress.Loopback, 1234);
Assert.AreEqual("127.0.0.1", endPoint.GetHost());
}
[TestMethod]
public void IPEndPointIPv6LoopbackGetHostShouldBeColonColon1()
public void GetHost_ShouldBeColonColon1_GivenIPv6LoopBackIPEndPoint()
{
var endPoint = new IPEndPoint(IPAddress.IPv6Loopback, 1234);
Assert.AreEqual("::1", endPoint.GetHost());
}
[TestMethod]
public void IPEndPointGetPortShouldBe1234()
public void GetHost_ShouldThrow_GivenNull()
{
Assert.ThrowsException<ArgumentNullException>(() => ((IPEndPoint?)null)!.GetHost());
Assert.ThrowsException<ArgumentNullException>(() => ((DnsEndPoint?)null)!.GetHost());
}
[TestMethod]
public void GetPort_ShouldBe1234_Given1234IPEndPoint()
{
var endPoint = new IPEndPoint(IPAddress.Loopback, 1234);
Assert.AreEqual(1234, endPoint.GetPort());
}
[TestMethod]
public void DummyEndPointGetHostShouldBeEmptyString()
public void GetPort_ShouldBe1234_Given1234DnsEndPoint()
{
var endPoint = new DnsEndPoint("localhost", 1234);
Assert.AreEqual(1234, endPoint.GetPort());
}
[TestMethod]
public void GetPort_ShouldThrow_GivenNull()
{
Assert.ThrowsException<ArgumentNullException>(() => ((IPEndPoint?)null)!.GetPort());
Assert.ThrowsException<ArgumentNullException>(() => ((DnsEndPoint?)null)!.GetPort());
}
[TestMethod]
public void GetHost_ShouldBeEmpty_GivenInvalidEndPoint()
{
var endPoint = new DummyEndPoint();
Assert.AreEqual(string.Empty, endPoint.GetHost());
}
[TestMethod]
public void DummyEndPointGetPortShouldBe0()
public void GetPort_ShouldBe0_GivenInvalidEndPoint()
{
var endPoint = new DummyEndPoint();
Assert.AreEqual(0, endPoint.GetPort());