示例#1
0
        public void IsPortInUse_With135_ReturnsTrue()
        {
            /* This is a really crappy test and only works on Windows environments -- my apologies. */

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                Assert.True(PortAvailability.IsPortBeingUsed(135));
            }
            else
            {
                Assert.True(true);
            }
        }
示例#2
0
 public void IsPortInUse_OutsideOfRange_ReturnsTrue()
 {
     Assert.True(PortAvailability.IsPortBeingUsed(IPEndPoint.MinPort - 1));
     Assert.True(PortAvailability.IsPortBeingUsed(IPEndPoint.MaxPort + 1));
 }
示例#3
0
        public void FindRandomOpenPort_ReturnsPort()
        {
            var port = PortAvailability.FindRandomOpenPort();

            Assert.NotEqual(-1, port);
        }
示例#4
0
        public void FindRandomOpenPort_FindsValidPort()
        {
            var port = PortAvailability.FindRandomOpenPort();

            Assert.False(IsPortInUse(port));
        }
 public TcpStumpsServer()
 {
     this.ListeningPort = PortAvailability.FindRandomOpenPort();
 }