public void ThrowsExceptionWhenAddingWrongNNetworks() { var address = new IPv4Address("192.168.10.5"); var mask = new IPv4SubnetMask("255.255.252.0"); var network = new IPv4Network(address, mask); Assert.ThrowsAny <Exception>(() => network.AddSubnet(null)); Assert.ThrowsAny <Exception>(() => network.AddSubnet(new IPv4Network(new IPv4Address("1.1.1.1"), new IPv4SubnetMask("0.0.0.0")))); var subnet = new IPv4Network(new IPv4Address("192.168.10.5"), new IPv4SubnetMask("255.255.254.0")); network.AddSubnet(subnet); Assert.ThrowsAny <Exception>(() => network.AddSubnet(subnet)); }
public void CanCalculateAllPossibleAddresses() { var address = new IPv4Address("192.168.10.5"); var mask = new IPv4SubnetMask("255.255.252.0"); var network = new IPv4Network(address, mask); Assert.Equal(1022, network.AllPossibleAddresses.Count()); network.AddAddress(new IPv4Address("192.168.10.7")); network.AddAddress(new IPv4Address("192.168.10.8")); Assert.Equal(1020, network.AllPossibleAddresses.Count()); var subnet = new IPv4Network(new IPv4Address("192.168.10.5"), new IPv4SubnetMask("255.255.254.0")); subnet.AddAddress(new IPv4Address("192.168.11.204")); network.AddSubnet(subnet); Assert.Equal(511, network.AllPossibleAddresses.Count()); }