public void DisposeTest() { var target = new UDPSocket(); target.Dispose(); Assert.IsNull(target.Udpsock); Assert.IsNull(target.UdpsocketOnlineSignal); GC.WaitForPendingFinalizers(); Assert.IsNotNull(target); }
public void InitTest() { var target = new UDPSocket(); var port = 8080; const bool expected = true; var actual = target.Init(port); Assert.AreEqual(expected, actual); target = new UDPSocket(); port = -8080; Assert.IsFalse(target.Init(port)); target.Dispose(); }
public void IPAddressIsValidTest() { var target = new UDPSocket(); var address = new IPAddress(0x2414188f); bool actual = target.IPAddressIsValid(address); Assert.AreEqual(false, actual); address = Dns.GetHostAddresses("localhost")[0]; actual = target.IPAddressIsValid(address); Assert.AreEqual(true, actual); address = IPAddress.Parse("192.168.1.112"); actual = target.IPAddressIsValid(address); Assert.AreEqual(false, actual); target.Dispose(); }
public void UDPSockTest() { var expected = new UDPSocket { RemoteIPendpoint = new IPEndPoint(IPAddress.Parse("192.168.1.100"), 9999), Udpsock = new UdpClient(9999), UDPSocketIsInit = false }; Globals.UdpSock = null; var actual = Globals.UdpSock; Assert.IsNotNull(actual); Globals.UdpSock = expected; actual = Globals.UdpSock; Assert.AreEqual(expected, actual); expected.Dispose(); }
public void UDPSocketConstructorTest() { var target = new UDPSocket(); Assert.AreEqual(target.Udpsock.GetType(), typeof(UdpClient)); Assert.AreEqual(target.UdpsocketOnlineSignal.GetType(), typeof(UdpClient)); target.Dispose(); }