Beispiel #1
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(address, UnitRequest.Objects("filter_objid=1001"));
                return(new ProbeResponse(new ProbeItem(objid: "1001", name: "Local Probe")));

            case 2:
                Assert.AreEqual(address, UnitRequest.Probes("filter_objid=1001&filter_parentid=0"));
                return(new ProbeResponse(new ProbeItem(objid: "1001", name: "Local Probe")));

            //Probe -> Devices
            case 3:
                Assert.AreEqual(address, UnitRequest.Devices("filter_parentid=1001"));
                return(new DeviceResponse(
                           new DeviceItem(objid: "3001", name: "dc-1", position: "10", positionRaw: "10"),
                           new DeviceItem(objid: "3002", name: "dc-2", position: "20", positionRaw: "20")
                           ));

            //Probe -> Groups
            case 4:
                Assert.AreEqual(address, UnitRequest.Groups("filter_parentid=1001"));
                return(new GroupResponse(new GroupItem(objid: "2001", name: "Servers", position: "30", positionRaw: "30")));

            //Probe -> Triggers
            case 5:
                Assert.AreEqual(address, UnitRequest.Triggers(1001));
                return(new NotificationTriggerResponse(
                           NotificationTriggerItem.StateTrigger(onNotificationAction: "300|Trigger1", parentId: "1001"),
                           NotificationTriggerItem.StateTrigger(onNotificationAction: "301|Trigger2", parentId: "1001"),
                           NotificationTriggerItem.StateTrigger(onNotificationAction: "302|Trigger3", parentId: "1001")
                           ));

            //Probe -> Devices -> Sensors
            case 6:
                Assert.AreEqual(address, UnitRequest.Sensors("filter_parentid=3001"));
                return(new SensorResponse(
                           new SensorItem(name: "Sensor2", objid: "4002", position: "20", positionRaw: "20"),
                           new SensorItem(name: "Sensor1", objid: "4001", position: "10", positionRaw: "10")
                           ));

            case 7:
                Assert.AreEqual(address, UnitRequest.Sensors("filter_parentid=3002"));
                return(new SensorResponse());

            //Probe -> Groups -> Devices
            case 8:
                Assert.AreEqual(address, UnitRequest.Devices("filter_parentid=2001"));
                return(new DeviceResponse());

            //Probe -> Groups -> Groups
            case 9:
                Assert.AreEqual(address, UnitRequest.Groups("filter_parentid=2001"));
                return(new GroupResponse());

            default:
                throw UnknownRequest(address);
            }
        }
        protected override IWebResponse GetResponse(string address, Content content)
        {
            switch (requestNum)
            {
            case 1:     //Get a group
                Assert.AreEqual(UnitRequest.Groups("count=1", UrlFlag.Columns), address);
                return(new GroupResponse(new GroupItem()));

            case 2:     //Are there any other groups called "Windows Infrastructure"?
                Assert.AreEqual(UnitRequest.Groups("count=*&filter_name=Windows+Infrastructure", UrlFlag.Columns), address);
                return(new GroupResponse(new GroupItem()));

            case 3:     //Get all sensors under the group "Windows Infrastructure"
                Assert.AreEqual(UnitRequest.Sensors("count=*&filter_name=@sub(ping)&filter_group=Windows+Infrastructure", UrlFlag.Columns), address);
                return(new SensorResponse(new SensorItem(name: "First"), new SensorItem(name: "Ping")));

            case 4:     //Get the child groups of "Windows Infrastructure"
                Assert.AreEqual(UnitRequest.Groups("count=*&filter_parentid=2211", UrlFlag.Columns), address);
                return(new GroupResponse(new GroupItem(name: "Child Group")));

            case 5:     //Are there any other groups called "Child Group"?
                Assert.AreEqual(UnitRequest.Groups("count=*&filter_name=Child+Group", UrlFlag.Columns), address);
                return(new GroupResponse(new GroupItem(name: "Child Group")));

            case 6:     //Get all sensors under the group "Child Group"
                Assert.AreEqual(UnitRequest.Sensors("count=*&filter_name=@sub(ping)&filter_group=Child+Group", UrlFlag.Columns), address);
                return(new SensorResponse(new SensorItem(name: "Second"), new SensorItem(name: "Ping"), new SensorItem(name: "Ping")));

            default:
                throw UnknownRequest(address);
            }
        }
Beispiel #3
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Groups("count=1", UrlFlag.Columns), address);
                return(new BasicResponse(standardResponse.GetResponseText(ref address)));

            case 2:
                Assert.AreEqual(UnitRequest.Groups("filter_objid=9999"), address);
                return(new GroupResponse(new GroupItem(objid: "2000", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")));

            //Tree

            case 3:
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2000"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3001"), new DeviceItem(objid: "3002")));

            case 4:
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3001"), address);
                return(new SensorResponse(new SensorItem(objid: "4001")));

            case 5:
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3002"), address);
                return(new SensorResponse(new SensorItem(objid: "4002")));

            default:
                throw UnknownRequest(address);
            }
        }
Beispiel #4
0
        public void Tree_Lazy_Child_ResolvesOnlyOnce()
        {
            var client = BaseTest.Initialize_Client(new TreeRequestResponse(TreeRequestScenario.MultiLevelContainer));

            var validator = new EventValidator(client, new[]
            {
                //Get Object
                UnitRequest.Objects("filter_objid=1001"),

                //Get Probe
                UnitRequest.Probes("filter_objid=1001&filter_parentid=0"),

                //Probe -> Devices/Groups
                UnitRequest.Devices("filter_parentid=1001"),
                UnitRequest.Groups("filter_parentid=1001"),

                //Probe -> Device -> Sensors
                UnitRequest.Sensors("filter_parentid=3001")
            });

            validator.MoveNext(2);
            var tree = client.GetTreeLazy(1001);

            validator.MoveNext(2);
            var child      = tree.Children[0];
            var childAgain = tree.Children[0];

            validator.MoveNext();
            var grandChild      = child.Children[0];
            var grandChildAgain = child.Children[0];
        }
Beispiel #5
0
        protected override IWebResponse GetResponse(string address, Content content)
        {
            switch (requestNum)
            {
            case 1:     //Get a group
                Assert.AreEqual(UnitRequest.Groups("count=1", UrlFlag.Columns), address);
                return(new GroupResponse(new GroupItem(objid: "2000")));

            case 2:     //Are there any other groups called "Windows Infrastructure"?
                Assert.AreEqual(UnitRequest.Groups("count=*&filter_name=Windows+Infrastructure", UrlFlag.Columns), address);
                return(new GroupResponse(new GroupItem(objid: "2000"), new GroupItem(objid: "2050")));

            case 3:     //Get all devices under the group "Windows Infrastructure" that we're piping from
                Assert.AreEqual(UnitRequest.Devices("count=*&filter_parentid=2000", UrlFlag.Columns), address);
                return(new DeviceResponse(new DeviceItem(name: "Device1", objid: "3000"), new DeviceItem(name: "Device2", objid: "3001")));

            case 4:     //Get all sensors from the child devices
                Assert.AreEqual(UnitRequest.Sensors("count=*&filter_name=@sub(ping)&filter_parentid=3000&filter_parentid=3001", UrlFlag.Columns), address);
                return(new SensorResponse(new SensorItem(name: "Ping", objid: "4000"), new SensorItem(name: "Pong2", objid: "4001")));

            case 5:     //Get all child groups under "Windows Infrastructure
                Assert.AreEqual(UnitRequest.Groups("count=*&filter_parentid=2000", UrlFlag.Columns), address);
                return(new GroupResponse(new GroupItem(name: "Child Group", objid: "2001", totalsens: "0")));

            default:
                throw UnknownRequest(address);
            }
        }
 private void QueryGroup(System.Linq.Expressions.Expression <Func <Group, bool> > predicate, string url)
 {
     ExecuteClient(c => c.QueryGroups(predicate), new[]
     {
         UnitRequest.Groups($"count=500" + (string.IsNullOrEmpty(url) ? url : $"&{url}"), UrlFlag.Columns)
     }, s => s.ToList());
 }
Beispiel #7
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Groups(), address);
                return(new GroupResponse(new GroupItem(objid: "0", name: "Root"), new GroupItem(objid: "3001", name: "Servers", parentId: "1001")));

            default:
                throw UnknownRequest(address);
            }
        }
Beispiel #8
0
        protected void AssertGroupRequest(string address, Content content, string request, UrlFlag?flags = null)
        {
            Assert.AreEqual(Content.Groups, content);

            if (flags == null)
            {
                Assert.AreEqual(UnitRequest.Groups(request), address);
            }
            else
            {
                Assert.AreEqual(UnitRequest.Groups(request, flags), address);
            }
        }
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Groups("filter_objid=0"), address);
                return(new GroupResponse(new GroupItem(objid: "0", name: "Root", notifiesx: "Inherited 1 State")));

            case 2:
                Assert.AreEqual(UnitRequest.Triggers(0), address);
                return(new NotificationTriggerResponse(NotificationTriggerItem.StateTrigger()));

            case 3:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Notifications("filter_objid=301"), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 4:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.NotificationProperties(301), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 5:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Schedules(), address);
                return(new ScheduleResponse(new ScheduleItem()));

            case 6:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.ScheduleProperties(623), address);
                return(new ScheduleResponse(new ScheduleItem()));

            default:
                throw UnknownRequest(address);
            }
        }
Beispiel #10
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:     //We want probes, so we get probes!
                Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "0", groupnumRaw: "0", devicenum: "0", devicenumRaw: "0")));

            case 2:     //Requesting any objects without the root node is incoherent
                Assert.AreEqual(UnitRequest.Groups("filter_objid=0"), address);
                return(new GroupResponse(new GroupItem(name: "Root", objid: "0")));

            default:
                throw UnknownRequest(address);
            }
        }
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Groups("filter_objid=0"), address);
                return(new GroupResponse(new GroupItem(objid: "0", name: "Root", notifiesx: "Inherited 1 State")));

            case 2:
                Assert.AreEqual(UnitRequest.RequestObjectData(0), address);
                return(new SensorSettingsResponse());

            default:
                throw UnknownRequest(address);
            }
        }
        protected override IWebResponse GetResponse(string address, Content content)
        {
            switch (requestNum)
            {
            case 1:     //Get a group
                Assert.AreEqual(UnitRequest.Groups("count=1", UrlFlag.Columns), address);
                return(new GroupResponse(new GroupItem()));

            case 2:     //Get 2 sensors under the group "Windows Infrastructure"
                Assert.AreEqual(UnitRequest.Sensors("count=2&filter_group=Windows+Infrastructure", UrlFlag.Columns), address);
                return(new SensorResponse(new SensorItem(name: "First")));

            //todo: why didnt this start streaming?

            default:
                throw UnknownRequest(address);
            }
        }
Beispiel #13
0
        protected override IWebResponse GetResponse(string address, Content content)
        {
            switch (requestNum)
            {
            case 1:     //Get a group
                Assert.AreEqual(UnitRequest.Groups("count=1", UrlFlag.Columns), address);
                return(new GroupResponse(new GroupItem()));

            case 2:     //Get 2 sensors under the group "Windows Infrastructure"
                Assert.AreEqual(UnitRequest.Sensors("count=2&filter_name=@sub(ping)&filter_group=Windows+Infrastructure", UrlFlag.Columns), address);
                return(new SensorResponse(new SensorItem(name: "First"), new SensorItem(name: "Second")));

            case 3:     //Get total number of sensors
                Assert.AreEqual(UnitRequest.Sensors("count=0&filter_name=@sub(ping)&filter_group=Windows+Infrastructure", null), address);
                return(new SensorResponse(Enumerable.Range(0, 600).Select(i => new SensorItem()).ToArray()));

            case 4:     //Get next 2 sensors
                Assert.AreEqual(UnitRequest.Sensors("count=2&filter_name=@sub(ping)&filter_group=Windows+Infrastructure&start=2", UrlFlag.Columns), address);
                return(new SensorResponse(
                           new SensorItem(name: "Pong1"), //Skipped by BaseResponse
                           new SensorItem(name: "Pong2"), //Skipped by BaseResponse
                           new SensorItem(name: "Ping"),
                           new SensorItem(name: "Pong3")
                           ));

            case 5:     //Request a whole page at a time
            case 6:     //Still haven't gotten all the sensors we want. Ask for 500 sensors then
                Assert.AreEqual(UnitRequest.Sensors("count=500&filter_name=@sub(ping)&filter_group=Windows+Infrastructure&start=4", UrlFlag.Columns), address);
                return(new SensorResponse(Enumerable.Range(0, 504).Select(i =>
                {
                    if (i == 500)
                    {
                        return new SensorItem(name: "Ping");
                    }

                    return new SensorItem();
                }).ToArray()));

            default:
                throw UnknownRequest(address);
            }
        }
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Groups("filter_objid=0"), address);
                return(new GroupResponse(new GroupItem(objid: "0", name: "Root")));

            case 2:
                Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3")));

            case 3:
                Assert.AreEqual(UnitRequest.Groups(), address);
                return(new GroupResponse(
                           new GroupItem(objid: "0", parentId: "-1000", name: "Root"),
                           new GroupItem(objid: "2001", parentId: "1001", groupnum: "1", groupnumRaw: "1", devicenum: "2", devicenumRaw: "2"),
                           new GroupItem(objid: "2002", parentId: "2001", name: "VMware", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")
                           ));

            case 4:
                Assert.AreEqual(UnitRequest.Devices(), address);
                return(new DeviceResponse(
                           new DeviceItem(objid: "3001", parentId: "1001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3002", parentId: "2001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3003", parentId: "2002", totalsens: "2", totalsensRaw: "2")
                           ));

            case 5:
                Assert.AreEqual(UnitRequest.Sensors(), address);
                return(new SensorResponse(
                           new SensorItem(objid: "4001", parentId: "3001"),
                           new SensorItem(objid: "4002", parentId: "3002"),
                           new SensorItem(objid: "4003", parentId: "3003")
                           ));

            default:
                throw UnknownRequest(address);
            }
        }
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Probes("count=1&filter_parentid=0", UrlFlag.Columns), address);
                return(new BasicResponse(standardResponse.GetResponseText(ref address)));

            //Probe 1

            case 2:
                Assert.AreEqual(UnitRequest.Groups("filter_probe=127.0.0.10"), address);
                return(new BasicResponse(standardResponse.GetResponseText(ref address)));

            //Tree

            case 3:
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2000"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3000", totalsens: "1", totalsensRaw: "1")));

            case 4:
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3000"), address);
                return(new SensorResponse(new SensorItem(objid: "4000")));

            case 5:
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2001"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3001", totalsens: "1", totalsensRaw: "1")));

            case 6:
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3001"), address);
                return(new SensorResponse(new SensorItem(objid: "4001")));

            default:
                throw UnknownRequest(address);
            }
        }
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:     //Resolve Object
                Assert.AreEqual(UnitRequest.Objects("filter_objid=1001"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3")));

            case 2:
                Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "1", groupnumRaw: "1", devicenum: "0", devicenumRaw: "0")));

            case 3:
                Assert.AreEqual(UnitRequest.Groups("filter_parentid=1001"), address);
                return(new GroupResponse(new GroupItem(objid: "2002", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")));

            case 4:
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2002"), address);
                return(new DeviceResponse(new DeviceItem(totalsens: "0", totalsensRaw: "0")));

            default:
                throw UnknownRequest(address);
            }
        }
Beispiel #17
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Objects("filter_objid=1001"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001")));

            case 2:
                Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001")));

            case 3:
                Assert.AreEqual(UnitRequest.Groups("filter_parentid=1001"), address);
                return(new GroupResponse(new GroupItem(objid: "3001", name: "Servers", parentId: "1001")));

            case 4:
                Assert.AreEqual(UnitRequest.Groups("filter_parentid=3001"), address);
                return(new GroupResponse());

            default:
                throw UnknownRequest(address);
            }
        }
Beispiel #18
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3", notifiesx: "Inherited")));

            case 2:
                Assert.AreEqual(UnitRequest.Groups(), address);
                return(new GroupResponse(
                           new GroupItem(objid: "0", parentId: "-1000", name: "Root"),
                           new GroupItem(objid: "2001", parentId: "1001", groupnum: "1", groupnumRaw: "1", devicenum: "2", devicenumRaw: "2"),
                           new GroupItem(objid: "2002", parentId: "2001", name: "VMware", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")
                           ));

            case 3:
                Assert.AreEqual(UnitRequest.Devices(), address);
                return(new DeviceResponse(
                           new DeviceItem(objid: "3001", parentId: "1001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3002", parentId: "2001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3003", parentId: "2002", totalsens: "2", totalsensRaw: "2")
                           ));

            case 4:
                Assert.AreEqual(UnitRequest.Sensors(), address);
                return(new SensorResponse(
                           new SensorItem(objid: "4001", parentId: "3001"),
                           new SensorItem(objid: "4002", parentId: "3002"),
                           new SensorItem(objid: "4003", parentId: "3003")
                           ));

            case 5:
                Assert.AreEqual(UnitRequest.RequestObjectData(4001), address);
                return(new SensorSettingsResponse());

            case 6:
                Assert.AreEqual(UnitRequest.RequestObjectData(3001), address);
                return(new SensorSettingsResponse());

            case 7:
                Assert.AreEqual(UnitRequest.RequestObjectData(4002), address);
                return(new SensorSettingsResponse());

            case 8:
                Assert.AreEqual(UnitRequest.RequestObjectData(3002), address);
                return(new SensorSettingsResponse());

            case 9:
                Assert.AreEqual(UnitRequest.RequestObjectData(4003), address);
                return(new SensorSettingsResponse());

            case 10:
                Assert.AreEqual(UnitRequest.RequestObjectData(3003), address);
                return(new SensorSettingsResponse());

            case 11:
                Assert.AreEqual(UnitRequest.RequestObjectData(2002), address);
                return(new SensorSettingsResponse());

            case 12:
                Assert.AreEqual(UnitRequest.RequestObjectData(2001), address);
                return(new SensorSettingsResponse());

            case 13:
                Assert.AreEqual(UnitRequest.RequestObjectData(1001), address);
                return(new SensorSettingsResponse());

            case 14:
                Assert.AreEqual(UnitRequest.RequestObjectData(0), address);
                return(new SensorSettingsResponse());

            default:
                throw UnknownRequest(address);
            }
        }
Beispiel #19
0
 private GroupResponse GetChildren(List <GroupNode> groupChildren, int parentId, string address)
 {
     Assert.AreEqual(UnitRequest.Groups($"filter_parentid={parentId}"), address);
     return(new GroupResponse(groupChildren.Select(g => g.GetTestItem()).ToArray()));
 }
Beispiel #20
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3")));

            case 2:
                Assert.AreEqual(UnitRequest.Groups(), address);
                return(new GroupResponse(
                           new GroupItem(objid: "0", parentId: "-1000", name: "Root"),
                           new GroupItem(objid: "2001", parentId: "1001", groupnum: "1", groupnumRaw: "1", devicenum: "2", devicenumRaw: "2"),
                           new GroupItem(objid: "2002", parentId: "2001", name: "VMware", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")
                           ));

            case 3:
                Assert.AreEqual(UnitRequest.Devices(), address);
                return(new DeviceResponse(
                           new DeviceItem(objid: "3001", parentId: "1001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3002", parentId: "2001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3003", parentId: "2002", totalsens: "2", totalsensRaw: "2")
                           ));

            case 4:
                Assert.AreEqual(UnitRequest.Sensors(), address);
                return(new SensorResponse(
                           new SensorItem(objid: "4001", parentId: "3001"),
                           new SensorItem(objid: "4002", parentId: "3002"),
                           new SensorItem(objid: "4003", parentId: "3003")
                           ));

            case 5:
                Assert.AreEqual(UnitRequest.Triggers(1001), address);
                return(new NotificationTriggerResponse(NotificationTriggerItem.StateTrigger(parentId: "1001")));

            case 6:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Notifications("filter_objid=301"), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 7:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.NotificationProperties(301), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 8:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Schedules(), address);
                return(new ScheduleResponse(new ScheduleItem()));

            case 9:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.ScheduleProperties(623), address);
                return(new ScheduleResponse(new ScheduleItem()));

            default:
                throw UnknownRequest(address);
            }
        }
Beispiel #21
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:     //Resolve Object
                Assert.AreEqual(UnitRequest.Objects("filter_objid=1001"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3")));

            case 2:     //Probes
                Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3", notifiesx: "Inherited 1 State")));

            case 3:     //Probe -> Device
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=1001"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3001", totalsens: "2", totalsensRaw: "2")));

            case 4:     //Probe -> Group
                Assert.AreEqual(UnitRequest.Groups("filter_parentid=1001"), address);
                return(new GroupResponse(new GroupItem(objid: "2001", groupnum: "1", groupnumRaw: "1", devicenum: "2", devicenumRaw: "2")));

            case 5:     //Probe -> Device -> Sensor
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3001"), address);
                return(new SensorResponse(new SensorItem(objid: "4001")));

            case 6:     //Probe -> Group -> Device
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2001"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3002", totalsens: "2", totalsensRaw: "2")));

            case 7:     //Probe -> Group -> Group
                Assert.AreEqual(UnitRequest.Groups("filter_parentid=2001"), address);
                return(new GroupResponse(new GroupItem(objid: "2002", name: "VMware", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")));

            case 8:     //Probe -> Group -> Device -> Sensor
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3002"), address);
                return(new SensorResponse(new SensorItem(objid: "4002")));

            case 9:     //Probe -> Group -> Group -> Device
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2002"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3003", totalsens: "2", totalsensRaw: "2")));

            case 10:     //Probe -> Group -> Group -> Sensor
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3003"), address);
                return(new SensorResponse(new SensorItem(objid: "4003")));

            case 11:
                Assert.AreEqual(UnitRequest.Triggers(1001), address);
                return(new NotificationTriggerResponse(NotificationTriggerItem.StateTrigger(parentId: "1001")));

            case 12:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Notifications("filter_objid=301"), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 13:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.NotificationProperties(301), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 14:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Schedules(), address);
                return(new ScheduleResponse(new ScheduleItem()));

            case 15:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.ScheduleProperties(623), address);
                return(new ScheduleResponse(new ScheduleItem()));

            default:
                throw UnknownRequest(address);
            }
        }