public void Setup()
        {
            Setup("fakemac", true);
            ExecutableProcessQueue.Expect(x => x.Go()).Repeat.Once();

            SetNetworkInterface = new SetNetworkInterface(ExecutableProcessQueue, WmiMacNetworkNameGetter, Logger, new IPFinder());
        }
 public void should_configure_interface_with_the_dns_servers_as_dhcp()
 {
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
     ExecutableProcessQueue.AssertWasCalled(
         x => x.Enqueue("netsh", "interface ip set dns name=\"Lan1\" source=dhcp", new[] { "0", "1" }));
 }
 public void should_set_interface_name()
 {
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
     ExecutableProcessQueue.AssertWasCalled(
         x => x.Enqueue("netsh", "interface set interface name=\"Lan1\" newname=\"Front End0\""));
 }
 public void should_set_the_interface_for_dhcp_first_before_configuring_it()
 {
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
     ExecutableProcessQueue.AssertWasCalled(
         x => x.Enqueue("netsh", "interface ip set address name=\"Lan1\" source=dhcp", new[] { "0", "1" }));
 }
 public void should_call_enable_on_disabled_interfaces_whose_macs_are_absent()
 {
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
     ExecutableProcessQueue.AssertWasCalled(
         x => x.Enqueue("netsh", "interface set interface name=\"Lan2\" admin=ENABLED"));
 }
 public void should_handle_ip6s_being_null()
 {
     NetworkInterface.ip6s = null;
     ExecutableProcessQueue.Expect(queue => queue.Enqueue(Arg <string> .Is.Equal("netsh"), Arg <string> .Is.Anything)).WhenCalled(ShouldNotHaveIpv6SubCommand).Repeat.Any().Return(null);
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
 }
 public void should_try_to_diff_name_if_set_interface_name_fails()
 {
     ExecutableProcessQueue.Expect(x => x.Go()).Throw(new UnsuccessfulCommandExecutionException("something", new ExecutableResult()));
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
     ExecutableProcessQueue.AssertWasCalled(
         x => x.Enqueue("netsh", "interface set interface name=\"Lan1\" newname=\"Front End1\""));
 }
        public void should_not_set_the_same_label_again()
        {
            NetworkInterface.label = "Lan1";
            SetNetworkInterface.Execute(new List <NetworkInterface> {
                NetworkInterface
            });

            ExecutableProcessQueue.AssertWasNotCalled(x => x.Enqueue("netsh", "interface set interface name=\"Lan1\" newname=\"Lan1\""));
        }
        public void Setup()
        {
            Setup("fakemac");
            ExecutableProcessQueue.Expect(x => x.Go()).Repeat.Twice();

            SetNetworkInterface = new SetNetworkInterface(ExecutableProcessQueue, WmiMacNetworkNameGetter, Logger, new IPFinder());
            SetNetworkInterface.Execute(new List <NetworkInterface> {
                NetworkInterface
            });
        }
 public void should_configure_interface_with_all_the_present_dns_servers()
 {
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
     ExecutableProcessQueue.AssertWasCalled(
         x => x.Enqueue("netsh", "interface ip add dns name=\"Lan1\" addr=192.168.1.3 index=1"));
     ExecutableProcessQueue.AssertWasCalled(
         x => x.Enqueue("netsh", "interface ip add dns name=\"Lan1\" addr=192.168.1.4 index=2"));
 }
 public void should_configure_the_interface_correctly_with_the_gateway()
 {
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
     ExecutableProcessQueue.AssertWasCalled(
         x =>
         x.Enqueue("netsh",
                   "interface ip add address name=\"Lan1\" addr=192.168.1.110 mask=255.255.255.0 gateway=192.168.1.1 gwmetric=2"));
 }
Exemplo n.º 12
0
        public void Setup()
        {
            Setup("fakemac", false, false, true);
            ExecutableProcessQueue.Expect(x => x.Go()).Repeat.Once();

            SetNetworkInterface = new SetNetworkInterface(ExecutableProcessQueue, WmiMacNetworkNameGetter, Logger);
            SetNetworkInterface.Execute(new List <NetworkInterface> {
                NetworkInterface
            });
        }
 public void should_configure_the_interface_correctly_for_both_ips_without_the_gateway()
 {
     NetworkInterface.gateway = null;
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
     ExecutableProcessQueue.AssertWasCalled(
         x => x.Enqueue("netsh", "interface ip add address name=\"Lan1\" addr=192.168.1.110 mask=255.255.255.0"));
     ExecutableProcessQueue.AssertWasCalled(
         x => x.Enqueue("netsh", "interface ip add address name=\"Lan1\" addr=1.2.2.2 mask=255.255.0.0"));
 }
        public void Setup()
        {
            Setup("fakemac");
            var ip6s = new[] { new Ipv6Tuple {
                                   enabled = "1", ip = "2001:4801:787F:202:278E:89D8:FF06:B476", netmask = "96", gateway = "fe80::def"
                               } };

            NetworkInterface = new NetworkInterfaceBuilder().withIp6s(ip6s).withMacAddress("fakemac").
                               withIps(new Ipv4Tuple[] { }).build();
            SetNetworkInterface = new SetNetworkInterface(ExecutableProcessQueue, WmiMacNetworkNameGetter, Logger, _mockIPFinder);
        }
        public void should_not_set_diff_name_if_set_interface_name_fails_for_more_than_retry_attempts()
        {
            const int noOfRetries = SetNetworkInterface.NO_OF_RETRIES_FOR_SETTING_INTERFACE_NAME;

            ExecutableProcessQueue.Expect(x => x.Go()).Throw(new UnsuccessfulCommandExecutionException("something", new ExecutableResult())).Repeat.Times(noOfRetries + 1);
            SetNetworkInterface.Execute(new List <NetworkInterface> {
                NetworkInterface
            });
            ExecutableProcessQueue.AssertWasNotCalled(
                x => x.Enqueue("netsh", string.Format("interface set interface name=\"Lan1\" newname=\"Front End{0}\"", noOfRetries + 1)));
        }
 public void should_set_ipv6_addresses()
 {
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
     ExecutableProcessQueue.AssertWasCalled(
         x =>
         x.Enqueue("netsh",
                   "interface ipv6 add address interface=\"Lan1\" address=2001:4801:787F:202:278E:89D8:FF06:B476/96"));
     ExecutableProcessQueue.AssertWasCalled(
         x =>
         x.Enqueue("netsh",
                   "interface ipv6 add route prefix=::/0 interface=\"Lan1\" nexthop=fe80::def publish=Yes"));
 }
        public void should_reset_ipv6_address_and_route_before_setting_ipv6_addresses()
        {
            _mockIPFinder.findIpv6Addresses("Lan1").Add(IPAddress.Parse("2001:4801:787F:202:278E:89D8:FF06:B476"));
            SetNetworkInterface.Execute(new List <NetworkInterface> {
                NetworkInterface
            });
            ExecutableProcessQueue.AssertWasCalled(
                x =>
                x.Enqueue("netsh",
                          "interface ipv6 delete address interface=\"Lan1\" address=2001:4801:787F:202:278E:89D8:FF06:B476"));


            ExecutableProcessQueue.AssertWasCalled(
                x => x.Enqueue("netsh", "interface ipv6 delete route ::/0 \"Lan1\"", new[] { "0", "1" }));
        }
 public void ApplicationException_should_be_thrown()
 {
     SetNetworkInterface.Execute(new List <NetworkInterface> {
         NetworkInterface
     });
 }
Exemplo n.º 19
0
 public void Setup()
 {
     Setup("some_mac_not_found");
     ExecutableProcessQueue.Expect(x => x.Go()).Repeat.Once();
     SetNetworkInterface = new SetNetworkInterface(ExecutableProcessQueue, WmiMacNetworkNameGetter, Logger);
 }