public void GatewayTest()
        {
            INetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();

            Assert.IsTrue(interfaces.Length > 0, "No interfaces available to test");

            // make sure DHCP is not enabled
            bool wasDhcpEnabled = interfaces[0].GetIPProperties().GetIPv4Properties().IsDhcpEnabled;

            if (wasDhcpEnabled)
            {
                interfaces[0].GetIPProperties().GetIPv4Properties().IsDhcpEnabled = false;
                interfaces[0].Rebind();
            }

            GatewayIPAddressInformationCollection gateways = interfaces[0].GetIPProperties().GatewayAddresses;

            if (gateways.Count == 0)
            {
                gateways.Add(IPAddress.Parse("10.1.1.1"));
                interfaces[0].Rebind();
            }

            IPAddress oldGateway = gateways[0].Address;
            IPAddress newGateway = IPAddress.Parse("10.0.0.0");

            // make sure it's new
            if (newGateway.Equals(oldGateway))
            {
                newGateway = IPAddress.Parse("10.1.1.1");
            }

            gateways[0].Address = newGateway;
            interfaces[0].Rebind();

            // no exception == pass

            // read
            gateways = interfaces[0].GetIPProperties().GatewayAddresses;

            Assert.IsTrue(newGateway.Equals(gateways[0].Address), string.Format("Gateway read back ({0}) did not match what we wrote in ({1})", gateways[0].Address, newGateway.Address));

            // restore
            if (wasDhcpEnabled)
            {
                interfaces[0].GetIPProperties().GetIPv4Properties().IsDhcpEnabled = true;
            }
            else
            {
                gateways[0].Address = oldGateway;
                interfaces[0].Rebind();
            }
        }