public void ConfigurationInterfaceInstantiation() { const string InterfaceName = "eth0"; const string Ipv4Address = "172.19.3.4"; const string Netmask = "255.255.255.0"; ConfigurationInterface iface = new ConfigurationInterface(InterfaceName, Ipv4Address, Netmask); Assert.AreEqual(InterfaceName, iface.Name, "interface name not set"); Assert.AreEqual(Ipv4Address, iface.InternetProtocolV4.ManualAddress, "IP address not set"); Assert.AreEqual(Netmask, iface.InternetProtocolV4.ManualNetMask, "netmask not set"); Assert.AreEqual(ConfigurationInterface.Method.Manual, iface.ConfigurationMethod, "configuration method not set to manual"); Assert.AreEqual("manual", iface.ConfigurationMethodString, "configuration method not \"manual\""); Assert.Throws <ArgumentException>( delegate { iface = new ConfigurationInterface("eth0", ConfigurationInterface.Method.Manual); }, "setting \"manual\" without providing ip address and netmask is not allowed"); Assert.Throws <ArgumentException>( delegate { iface = new ConfigurationInterface(null, ConfigurationInterface.Method.Dhcp); }, "setting \"manual\" without providing ip address and netmask is not allowed"); }
public ConfigurationNetSettings(ConfigurationInterface configurationInterface) { if (configurationInterface == null) { throw new ArgumentNullException("configurationInterface"); } this.ConfigurationInterface = configurationInterface; }
public ConfigurationNetSettings(ConfigurationInterface configurationInterface, DefaultGateway gateway) { if (configurationInterface == null) { throw new ArgumentNullException("configurationInterface"); } if (gateway == null) { throw new ArgumentNullException("gateway"); } if (string.IsNullOrEmpty(gateway.InternetProtocolV4Address) && string.IsNullOrEmpty(gateway.InternetProtocolV6Address)) { throw new ArgumentException("gateway"); } this.ConfigurationInterface = configurationInterface; this.DefaultGateway = gateway; }