public void SetNetMaskTest()
        {
            NetworkAddressIPv4 test = new NetworkAddressIPv4();

            test.SetNetMask(255, 255, 255, 0);
            Assert.AreEqual(24, test.GetNetmask());

            test.SetNetMask(128, 0, 0, 0);
            Assert.AreEqual(1, test.GetNetmask());

            test.SetNetMask(255, 128, 0, 0);
            Assert.AreEqual(9, test.GetNetmask());

            test.SetNetMask("255.255.255.0");
            Assert.AreEqual(24, test.GetNetmask());

            test.SetNetMask("128.0.0.0");
            Assert.AreEqual(1, test.GetNetmask());

            test.SetNetMask("255.128.0.0");
            Assert.AreEqual(9, test.GetNetmask());

            try
            {
                test.SetNetMask(127, 0, 0, 0);
                test.SetNetMask(128, 1, 0, 0);
                test.SetNetMask(255, 128, 4, 0);
                test.SetNetMask(255, 255, 3, 0);

                Assert.Fail();
            }
            catch (IPAddressNotValid)
            {
            }
        }
예제 #2
0
 public void SetNetMaskTest(
     [PexAssumeUnderTest] NetworkAddressIPv4 target,
     int a,
     int b,
     int c,
     int d
     )
 {
     target.SetNetMask(a, b, c, d);
     // TODO: add assertions to method NetworkAddressIPv4Test.SetNetMaskTest(NetworkAddressIPv4, Int32, Int32, Int32, Int32)
 }
예제 #3
0
        public void SetIPv4Address(string address, string gateway = null, int netMask = 0)
        {
            if (this.IPv4Address == null)
            {
                this.IPv4Address = new NetworkAddressIPv4();
            }

            this.IPv4Address.SetAddress(address);

            if (gateway != null)
            {
                this.IPv4Address.SetGateway(gateway);
            }

            if (netMask != 0)
            {
                this.IPv4Address.SetNetMask(netMask);
            }
        }
예제 #4
0
 public void SetIPV4Address(NetworkAddressIPv4 ip)
 {
     this.IPv4Address = ip;
 }