예제 #1
0
 public void DisposeTest()
 {
     var target = new UDPSocket();
     target.Dispose();
     Assert.IsNull(target.Udpsock);
     Assert.IsNull(target.UdpsocketOnlineSignal);
     GC.WaitForPendingFinalizers();
     Assert.IsNotNull(target);
 }
예제 #2
0
 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();
 }
예제 #3
0
 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();
 }
예제 #4
0
        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();
        }
예제 #5
0
 public void UDPSocketConstructorTest()
 {
     var target = new UDPSocket();
     Assert.AreEqual(target.Udpsock.GetType(), typeof(UdpClient));
     Assert.AreEqual(target.UdpsocketOnlineSignal.GetType(), typeof(UdpClient));
     target.Dispose();
 }