public void Constructor_Failed_AddressNotNetwork(String rawNetwork, String rawMask) { IPv4Address address = IPv4Address.FromString(rawNetwork); IPv4SubnetMask mask = IPv4SubnetMask.FromString(rawMask); Assert.ThrowsAny <Exception>(() => new IPv4Route(address, mask)); }
public void IPv4SubnetMask_IsIPAdressANetworkAddress(String subnetMaskInput, String addressInput, Boolean expectedResult) { IPv4SubnetMask mask = IPv4SubnetMask.FromString(subnetMaskInput); IPv4Address address = IPv4Address.FromString(addressInput); Boolean actual = mask.IsIPAdressANetworkAddress(address); Assert.Equal(expectedResult, actual); }
public void Constructor(String rawNetwork, String rawMask) { IPv4Address address = IPv4Address.FromString(rawNetwork); IPv4SubnetMask mask = IPv4SubnetMask.FromString(rawMask); IPv4Route route = new IPv4Route(address, mask); Assert.Equal(mask, route.SubnetMask); Assert.Equal(address, route.Network); }
public void DHCPv4RelayAgentSubnetResolver_PacketMeetsConditions2( String networkAddressInput, String maskInput, String relayAgentAddressInput, Boolean shouldPass ) { Random random = new Random(); IPv4SubnetMask mask = IPv4SubnetMask.FromString(maskInput); IPv4Address networkAddress = IPv4Address.FromString(networkAddressInput); String inputAddressValue = random.GetAlphanumericString(10); String inputMaskValue = random.GetAlphanumericString(10); Mock <ISerializer> serializer = new Mock <ISerializer>(MockBehavior.Strict); serializer.Setup(x => x.Deserialze <String>(mask.GetSlashNotation().ToString())).Returns(mask.GetSlashNotation().ToString()); serializer.Setup(x => x.Deserialze <String>(networkAddress.ToString())).Returns(networkAddress.ToString()); DHCPv4RelayAgentSubnetResolver resolver = new DHCPv4RelayAgentSubnetResolver(); Dictionary <String, String> values = new Dictionary <String, String>() { { nameof(DHCPv4RelayAgentSubnetResolver.NetworkAddress), networkAddress.ToString() }, { nameof(DHCPv4RelayAgentSubnetResolver.Mask), mask.GetSlashNotation().ToString() }, }; resolver.ApplyValues(values, serializer.Object); IPv4Address gwAddress = IPv4Address.FromString(relayAgentAddressInput); DHCPv4Packet packet = new DHCPv4Packet( new IPv4HeaderInformation(random.GetIPv4Address(), random.GetIPv4Address()), random.NextBytes(6), (UInt32)random.Next(), IPv4Address.Empty, gwAddress, IPv4Address.Empty ); Boolean actual = resolver.PacketMeetsCondition(packet); Assert.Equal(shouldPass, actual); }