public void ConfigurationRequestIllegalParameters()
        {
            Assert.Throws <ArgumentNullException>(
                delegate
            {
                ConfigurationRequest request = new ConfigurationRequest(null, "bla");
            },
                "no exception thrown if no configuration parameters set");

            Assert.Throws <ArgumentException>(
                delegate
            {
                ConfigurationDevice device        = new ConfigurationDevice("0009E5001231");
                ConfigurationNetSettings settings = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp));
                ConfigurationParams parameters    = new ConfigurationParams(device, settings);
                ConfigurationRequest request      = new ConfigurationRequest(parameters, null);
            },
                "no exception thrown if no query ID given");

            Assert.Throws <ArgumentException>(
                delegate
            {
                ConfigurationDevice device        = new ConfigurationDevice("0009E5001231");
                ConfigurationNetSettings settings = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp));
                ConfigurationParams parameters    = new ConfigurationParams(device, settings);
                ConfigurationRequest request      = new ConfigurationRequest(parameters, string.Empty);
            },
                "no exception thrown if empty query ID given");
        }
Exemple #2
0
 public void SendConfigurationTestNoIpGateway()
 {
     Assert.Throws <ArgumentException>(
         delegate
     {
         DefaultGateway gateway            = new DefaultGateway();
         ConfigurationNetSettings settings = new ConfigurationNetSettings(gateway);
     },
         "no exception if neither IPv4 nor IPv6 address set");
 }
Exemple #3
0
        public void SendConfigurationTestDhcp()
        {
            ConfigurationService service = new ConfigurationService(this.parser, this);

            ConfigurationDevice      device     = new ConfigurationDevice("0009E5001231");
            ConfigurationNetSettings settings   = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp));
            ConfigurationParams      parameters = new ConfigurationParams(device, settings);

            service.SendConfiguration(parameters, this, 1000);
            Assert.True(this.gotSuccessResponse && !this.gotErrorResponse && !this.gotTimeout, "got timeout or error for correct configuration response");
        }
Exemple #4
0
        public void SendConfigurationErrorResponse()
        {
            this.response = ResponseType.responseError;
            ConfigurationService service = new ConfigurationService(this.parser, this);

            ConfigurationDevice      device     = new ConfigurationDevice("0009E5001231");
            ConfigurationNetSettings settings   = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp));
            ConfigurationParams      parameters = new ConfigurationParams(device, settings);

            service.SendConfiguration(parameters, this, 1000);
            Assert.True(!this.gotSuccessResponse && this.gotErrorResponse && !this.gotTimeout, "got no error callback if error response was sent");
        }
Exemple #5
0
        public void CloseWhileSendingConfiguration()
        {
            this.response = ResponseType.noResponse;
            ConfigurationService service = new ConfigurationService(this.parser, this);

            ConfigurationDevice      device     = new ConfigurationDevice("0009E5001231");
            ConfigurationNetSettings settings   = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp));
            ConfigurationParams      parameters = new ConfigurationParams(device, settings);

            service.SendConfiguration(parameters, this, 1000);
            service.Close();
            Assert.True(!this.gotSuccessResponse && !this.gotErrorResponse && !this.gotTimeout, "got callbacks after closing the service");
        }
Exemple #6
0
        public void SendConfigurationNoErrorNoResultResponse()
        {
            this.response = ResponseType.responseNoErrorNoResult;
            ConfigurationService service = new ConfigurationService(this.parser, this);

            ConfigurationDevice      device     = new ConfigurationDevice("0009E5001231");
            ConfigurationNetSettings settings   = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp));
            ConfigurationParams      parameters = new ConfigurationParams(device, settings);

            service.SendConfiguration(parameters, this, 10);
            Thread.Sleep(100);
            Assert.True(!this.gotSuccessResponse && !this.gotErrorResponse && this.gotTimeout, "got no timeout if response with no result/error was sent");
        }
Exemple #7
0
        public void SendConfigurationTestIPv6Gateway()
        {
            ConfigurationService service = new ConfigurationService(this.parser, this);

            ConfigurationDevice device  = new ConfigurationDevice("0009E5001231");
            DefaultGateway      gateway = new DefaultGateway();

            gateway.InternetProtocolV6Address = "2001:db8:85a3::8a2e:370:7334";
            ConfigurationNetSettings settings   = new ConfigurationNetSettings(gateway);
            ConfigurationParams      parameters = new ConfigurationParams(device, settings);

            service.SendConfiguration(parameters, this, 1000);
            Assert.True(this.gotSuccessResponse && !this.gotErrorResponse && !this.gotTimeout, "got timeout or error for correct configuration response");
        }
        public void ConfigurationNetSettingsInstantiation()
        {
            Assert.Throws <ArgumentNullException>(
                delegate
            {
                ConfigurationNetSettings settings = new ConfigurationNetSettings(null, null);
            },
                "no exception if both gateway and configuration interface are null");

            Assert.Throws <ArgumentNullException>(
                delegate
            {
                ConfigurationNetSettings settings = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp), null);
            },
                "no exception if gateway is null");

            Assert.Throws <ArgumentNullException>(
                delegate
            {
                ConfigurationNetSettings settings = new ConfigurationNetSettings((ConfigurationInterface)null);
            },
                "no exception if configuration interface is null");

            Assert.Throws <ArgumentNullException>(
                delegate
            {
                ConfigurationNetSettings settings = new ConfigurationNetSettings((DefaultGateway)null);
            },
                "no exception if gateway is null");

            Assert.DoesNotThrow(
                delegate
            {
                DefaultGateway gateway            = new DefaultGateway();
                gateway.InternetProtocolV4Address = "172.19.1.1";
                ConfigurationNetSettings settings = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp), gateway);
            },
                "exception thrown for correct instantiation");

            Assert.Throws <ArgumentException>(
                delegate
            {
                DefaultGateway gateway            = new DefaultGateway();
                ConfigurationNetSettings settings = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp), gateway);
            },
                "no exception if gateway IP is null or empty ");
        }
Exemple #9
0
        public void IllegalParamatersTest()
        {
            ConfigurationService service = new ConfigurationService(this.parser, this);

            Assert.Throws <ArgumentNullException>(
                delegate
            {
                service.SendConfiguration(null, "bla", this, 1000);
            },
                "no exception thrown if no configuration parameter given");

            ConfigurationDevice      device     = new ConfigurationDevice("0009E5001231");
            ConfigurationNetSettings settings   = new ConfigurationNetSettings(new ConfigurationInterface("eth0", ConfigurationInterface.Method.Dhcp));
            ConfigurationParams      parameters = new ConfigurationParams(device, settings);

            Assert.Throws <ArgumentException>(
                delegate
            {
                service.SendConfiguration(parameters, null, this, 1000);
            },
                "no exception thrown if no query ID given");

            Assert.Throws <ArgumentNullException>(
                delegate
            {
                service.SendConfiguration(parameters, "foo", null, 1000);
            },
                "no exception thrown if no callbacks given");

            Assert.Throws <ArgumentException>(
                delegate
            {
                service.SendConfiguration(parameters, "foo", this, -10);
            },
                "no exception thrown if negative timeout given");
        }
Exemple #10
0
 public ConfigurationParams(ConfigurationDevice device, ConfigurationNetSettings cns)
 {
     this.Device      = device;
     this.NetSettings = cns;
     this.Ttl         = 1;
 }