diff --git a/X10D.Tests/src/Net/EndPointTests.cs b/X10D.Tests/src/Net/EndPointTests.cs index b335dfe..8b508d9 100644 --- a/X10D.Tests/src/Net/EndPointTests.cs +++ b/X10D.Tests/src/Net/EndPointTests.cs @@ -8,63 +8,63 @@ namespace X10D.Tests.Net; public class EndPointTests { [TestMethod] - public void GetHostNullShouldThrow() - { - Assert.ThrowsException(() => ((IPEndPoint?)null)!.GetHost()); - Assert.ThrowsException(() => ((DnsEndPoint?)null)!.GetHost()); - } - - [TestMethod] - public void GetPortNullShouldThrow() - { - Assert.ThrowsException(() => ((IPEndPoint?)null)!.GetPort()); - Assert.ThrowsException(() => ((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(() => ((IPEndPoint?)null)!.GetHost()); + Assert.ThrowsException(() => ((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(() => ((IPEndPoint?)null)!.GetPort()); + Assert.ThrowsException(() => ((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());