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]; }
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) { 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", notifiesx: "Inherited 1 State"))); case 3: Assert.AreEqual(UnitRequest.Triggers(1001), address); return(new NotificationTriggerResponse(NotificationTriggerItem.StateTrigger(parentId: "1001"))); case 4: if (!async) { goto default; } Assert.AreEqual(UnitRequest.Notifications("filter_objid=301"), address); return(new NotificationActionResponse(new NotificationActionItem())); case 5: if (!async) { goto default; } Assert.AreEqual(UnitRequest.NotificationProperties(301), address); return(new NotificationActionResponse(new NotificationActionItem())); case 6: if (!async) { goto default; } Assert.AreEqual(UnitRequest.Schedules(), address); return(new ScheduleResponse(new ScheduleItem())); case 7: if (!async) { goto default; } Assert.AreEqual(UnitRequest.ScheduleProperties(623), address); return(new ScheduleResponse(new ScheduleItem())); default: throw UnknownRequest(address); } }
public void Tree_Lazy_Id_OneAPIRequest() { var client = BaseTest.Initialize_Client(new TreeRequestResponse(TreeRequestScenario.ContainerWithGrandChild)); var validator = new EventValidator(client, new[] { UnitRequest.Objects("filter_objid=1001"), UnitRequest.Probes("filter_objid=1001&filter_parentid=0") }); validator.MoveNext(2); var tree = client.GetTreeLazy(1001); }
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", devicenum: "0", devicenumRaw: "0", groupnum: "0", groupnumRaw: "0"))); case 2: Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address); return(new ProbeResponse(new ProbeItem(objid: "1001", devicenum: "0", devicenumRaw: "0", groupnum: "0", groupnumRaw: "0"))); default: throw UnknownRequest(address); } }
protected override IWebResponse GetResponse(string address) { switch (requestNum) { case 1: Assert.AreEqual(UnitRequest.Objects("filter_objid=3001"), address); return(new DeviceResponse(new DeviceItem(objid: "3001"))); case 2: Assert.AreEqual(UnitRequest.Devices("filter_objid=3001"), address); return(new DeviceResponse(new DeviceItem(objid: "3001"))); case 3: Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3001"), address); return(new SensorResponse(new SensorItem(objid: "4001", parentId: "3001"))); default: throw UnknownRequest(address); } }
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.RequestObjectData(1001), address); return(new SensorSettingsResponse()); default: throw UnknownRequest(address); } }
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); } }
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); } }