Пример #1
0
        public async Task AddDevice_CanExecuteAsync()
        {
            var url = "adddevice2.htm?name_=device&host_=host&ipversion_=0&discoverytype_=0&discoveryschedule_=0&id=1001";

            var client = Initialize_Client(new AddressValidatorResponse(url));

            var parameters = new NewDeviceParameters("device", "host");

            await client.AddDeviceAsync(1001, parameters, false);
        }
Пример #2
0
        public async Task AddDevice_CanExecuteAsync()
        {
            var url = "adddevice2.htm?name_=device&host_=host&ipversion_=0&discoverytype_=0&discoveryschedule_=0&id=1001";

            var parameters = new NewDeviceParameters("device", "host");

            await ExecuteAsync(
                async c => await c.AddDeviceAsync(1001, parameters, false),
                url
                );
        }
Пример #3
0
        public void AddDevice_CanExecute()
        {
            var url = "adddevice2.htm?name_=device&host_=host&ipversion_=0&discoverytype_=0&discoveryschedule_=0&id=1001";

            var parameters = new NewDeviceParameters("device", "host");

            Execute(
                c => c.AddDevice(1001, parameters, false),
                url
                );
        }
Пример #4
0
        public void NewDeviceParameters_DoesNotChangeAutoDiscoveryMode_WhenNoTemplatesAssigned()
        {
            var parameters = new NewDeviceParameters("dc-1");

            Assert.AreEqual(AutoDiscoveryMode.Manual, parameters.AutoDiscoveryMode);

            parameters.DeviceTemplates = null;
            Assert.AreEqual(AutoDiscoveryMode.Manual, parameters.AutoDiscoveryMode);

            parameters.DeviceTemplates = new List <DeviceTemplate>();
            Assert.AreEqual(AutoDiscoveryMode.Manual, parameters.AutoDiscoveryMode);
        }
Пример #5
0
        public void NewDeviceParameters_SetsAutomaticTemplate_WhenTemplatesAssigned()
        {
            var templates = Execute(c => c.GetDeviceTemplates());

            var parameters = new NewDeviceParameters("dc-1");

            Assert.AreEqual(AutoDiscoveryMode.Manual, parameters.AutoDiscoveryMode);

            parameters.DeviceTemplates = templates;
            Assert.AreEqual(templates, parameters.DeviceTemplates);
            Assert.AreEqual(AutoDiscoveryMode.AutomaticTemplate, parameters.AutoDiscoveryMode);
        }
Пример #6
0
        public async Task AddDevice_WithTemplates_Throws_WhenNoTemplatesSpecifiedAsync()
        {
            var client = Initialize_Client(new MultiTypeResponse());

            var parameters = new NewDeviceParameters("device", "host")
            {
                AutoDiscoveryMode = AutoDiscoveryMode.AutomaticTemplate
            };

            await AssertEx.ThrowsAsync <InvalidOperationException>(
                async() => await client.AddDeviceAsync(1001, parameters, false),
                "Property 'DeviceTemplates' requires a value when property 'AutoDiscoveryMode' is value 'AutomaticTemplate', however the value was null or empty."
                );
        }
Пример #7
0
        public void AddDevice_WithTemplates_Throws_WhenNoTemplatesSpecified()
        {
            var client = Initialize_Client(new MultiTypeResponse());

            var parameters = new NewDeviceParameters("device", "host")
            {
                AutoDiscoveryMode = AutoDiscoveryMode.AutomaticTemplate
            };

            AssertEx.Throws <InvalidOperationException>(
                () => client.AddDevice(1001, parameters, false),
                "Property 'DeviceTemplates' requires a value when property 'AutoDiscoveryMode' is value 'AutomaticTemplate', however the value was null, empty or whitespace."
                );
        }
Пример #8
0
        public void NewDeviceParameters_AssignsHostToCorrectProperty()
        {
            var parameters = new NewDeviceParameters("device", "dc-1");

            Assert.AreEqual("dc-1", GetCustomParameter(parameters, "host_"));

            parameters.Host = "dc-2";
            Assert.AreEqual("dc-2", GetCustomParameter(parameters, "host_"));

            parameters.IPVersion = IPVersion.IPv6;
            Assert.AreEqual("dc-2", GetCustomParameter(parameters, "hostv6_"));

            parameters.Host = "dc-3";
            Assert.AreEqual("dc-3", GetCustomParameter(parameters, "hostv6_"));
        }
Пример #9
0
        public void NewDeviceParameters_SwapsHostWithIPVersion()
        {
            var parameters = new NewDeviceParameters("device", "dc-1");

            Assert.AreEqual("dc-1", GetCustomParameter(parameters, "host_"));
            Assert.AreEqual("dc-1", parameters.Host);

            parameters.IPVersion = IPVersion.IPv6;
            Assert.AreEqual("dc-1", GetCustomParameter(parameters, "hostv6_"));
            Assert.AreEqual(null, GetCustomParameter(parameters, "host_"));
            Assert.AreEqual("dc-1", parameters.Host);

            parameters.IPVersion = IPVersion.IPv4;
            Assert.AreEqual("dc-1", GetCustomParameter(parameters, "host_"));
            Assert.AreEqual(null, GetCustomParameter(parameters, "hostv6_"));
            Assert.AreEqual("dc-1", parameters.Host);
        }
Пример #10
0
        public void NewDeviceParameters_ClearsTemplates_WhenAutoDiscoveryModeChanged()
        {
            var templates = Execute(c => c.GetDeviceTemplates());

            var parameters = new NewDeviceParameters("dc-1");

            Assert.AreEqual(AutoDiscoveryMode.Manual, parameters.AutoDiscoveryMode);

            parameters.DeviceTemplates = templates;
            Assert.AreEqual(templates, parameters.DeviceTemplates);
            Assert.AreEqual(AutoDiscoveryMode.AutomaticTemplate, parameters.AutoDiscoveryMode);

            parameters.AutoDiscoveryMode = AutoDiscoveryMode.AutomaticTemplate;
            Assert.AreEqual(templates, parameters.DeviceTemplates);

            parameters.AutoDiscoveryMode = AutoDiscoveryMode.Automatic;
            Assert.AreEqual(null, parameters.DeviceTemplates);
        }
Пример #11
0
        public async Task AddDevice_WithTemplates_CanExecuteAsync()
        {
            var templateClient = Initialize_Client(new MultiTypeResponse());
            var templates      = (await templateClient.GetDeviceTemplatesAsync()).Take(2).ToList();

            var builder = new StringBuilder();

            builder.Append("adddevice2.htm?name_=device&host_=host&ipversion_=0&discoverytype_=2&discoveryschedule_=0&devicetemplate_=1&");
            builder.Append("devicetemplate__check=Cisco+ADSL.odt%7CADSL%7C%7C&");
            builder.Append("devicetemplate__check=Cloudwatch.odt%7CAmazon+Cloudwatch%7C%7C&");
            builder.Append("id=1001");

            var client = Initialize_Client(new AddressValidatorResponse(builder.ToString()));

            var parameters = new NewDeviceParameters("device", "host")
            {
                AutoDiscoveryMode = AutoDiscoveryMode.AutomaticTemplate,
                DeviceTemplates   = templates
            };

            await client.AddDeviceAsync(1001, parameters, false);
        }
Пример #12
0
 public DeviceProxy(NewDeviceParameters parameters, PrtgClient client) : base(i => client.AddDevice(i, parameters))
 {
 }