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");
        }
Beispiel #2
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");
        }
Beispiel #3
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");
        }
Beispiel #4
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");
        }
Beispiel #5
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");
        }
Beispiel #6
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");
        }
        internal ConfigurationRequest(ConfigurationParams parameters, string queryId) : this()
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (string.IsNullOrEmpty(queryId))
            {
                throw new ArgumentException("queryId");
            }

            this.QueryId    = queryId;
            this.parameters = parameters;
        }
Beispiel #8
0
        public void SendConfiguration(ConfigurationParams parameters, string queryId, IConfigurationCallback callbacks, double timeoutMs)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (callbacks == null)
            {
                throw new ArgumentNullException("callbacks");
            }

            if (timeoutMs <= 0)
            {
                throw new ArgumentException("timeout");
            }

            if (string.IsNullOrEmpty(queryId))
            {
                throw new ArgumentException("queryId");
            }

            ConfigurationRequest request = new ConfigurationRequest(parameters, queryId);
            ConfigurationTimer   timer   = new ConfigurationTimer(timeoutMs, request);
            ConfigQuery          query   = new ConfigQuery(request, callbacks, timer);

            lock (this.awaitingResponses)
            {
                this.awaitingResponses.Add(queryId, query);
                timer.AutoReset = false;
                timer.Elapsed  += new ElapsedEventHandler(this.OnTimedEvent);
                timer.Start();
            }

            this.sender.SendMessage(this.serializer.Serialize(request));
        }
Beispiel #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");
        }
Beispiel #10
0
        public void SendConfiguration(ConfigurationParams parameters, IConfigurationCallback callbacks, double timeoutMs)
        {
            Guid queryId = System.Guid.NewGuid();

            this.SendConfiguration(parameters, queryId.ToString(), callbacks, timeoutMs);
        }