Пример #1
0
        public void PortValidation(int port1, int port2, bool sameProtocol, bool allowed)
        {
            // Arrange
            var protocol = new DummyProtocol(7);

            PortMap.Register(IPAddress.Parse("192.168.0.42"), port1, protocol);

            // Act
            var success = PortMap.Register(IPAddress.Parse("192.168.0.42"), port2, new DummyProtocol(sameProtocol ? 7 : 9));

            // Assert
            if (allowed)
            {
                Assert.IsTrue(success, "Failed to register despite different address");
            }
            else
            {
                Assert.IsFalse(success, "Should not allow registration");
            }
        }
Пример #2
0
        public void AddressValidation(string address1, string address2, bool sameProtocol, bool allowed)
        {
            // Arrange
            var protocol = new DummyProtocol(7);

            PortMap.Register(IPAddress.Parse(address1), 42, protocol);

            // Act
            var success = PortMap.Register(IPAddress.Parse(address2), 42, new DummyProtocol(sameProtocol ? 7 : 9));

            // Assert
            if (allowed)
            {
                Assert.IsTrue(success, "Failed to register despite different address");
            }
            else
            {
                Assert.IsFalse(success, "Should not allow registration");
            }
        }