Ejemplo n.º 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);
        }
Ejemplo n.º 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
                );
        }
Ejemplo n.º 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
                );
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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."
                );
        }
Ejemplo n.º 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."
                );
        }
Ejemplo n.º 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_"));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 12
0
 public DeviceProxy(NewDeviceParameters parameters, PrtgClient client) : base(i => client.AddDevice(i, parameters))
 {
 }