public async Task SetTriggerProperty_ChannelAsync() { var triggerItem = NotificationTriggerItem.ThresholdTrigger(channel: "Backup State", parentId: "4000"); var channelItem = new ChannelItem(name: "Backup State"); var response = new NotificationTriggerResponse(new[] { triggerItem }, new[] { channelItem }); var client = Initialize_Client(response); var trigger = client.GetNotificationTriggers(4000).First(t => t.Type == TriggerType.Threshold); await ExecuteAsync( async c => { var channel = await c.GetChannelAsync(4000, 1); await c.SetTriggerPropertyAsync(trigger, TriggerProperty.Channel, channel); }, new[] { UnitRequest.Channels(4000), UnitRequest.ChannelProperties(4000, 1), UnitRequest.Sensors("filter_objid=4000"), UnitRequest.Channels(4000), UnitRequest.ChannelProperties(4000, 1), UnitRequest.EditSettings("id=4000&subid=7&channel_7=1") } ); }
public void AddNotificationTrigger_TriggerChannel_InvalidChannelId_OnSensor() { var urls = new[] { UnitRequest.TriggerTypes(1001), //Validate Supported Triggers UnitRequest.Sensors("filter_objid=1001"), //Validate TriggerChannel target compatibility UnitRequest.ChannelProperties(1001, 99) }; AssertEx.Throws <InvalidOperationException>(() => TestTriggerChannel(new TriggerChannel(99), urls, true), "Channel ID '99' is not a valid channel"); }
public void AddNotificationTrigger_TriggerChannel_ChannelId_OnSensor() { var urls = new[] { UnitRequest.TriggerTypes(1001), //Validate Supported Triggers UnitRequest.Sensors("filter_objid=1001"), //Validate TriggerChannel target compatibility UnitRequest.ChannelProperties(1001, 3), UnitRequest.EditSettings("id=1001&subid=new&onnotificationid_new=-1%7CNone&class=threshold&offnotificationid_new=-1%7CNone&channel_new=3&condition_new=0&threshold_new=0&latency_new=60&objecttype=nodetrigger") //Add Trigger }; TestTriggerChannel(new TriggerChannel(3), urls, true); }
public void AddNotificationTrigger_TriggerChannel_Channel_WithStandardTriggerChannelName_OnSensor() { var urls = new[] { UnitRequest.TriggerTypes(1001), //Validate Supported Triggers UnitRequest.Sensors("filter_objid=1001"), //Validate TriggerChannel target compatibility UnitRequest.Channels(1001), UnitRequest.ChannelProperties(1001, 1), UnitRequest.EditSettings("id=1001&subid=new&onnotificationid_new=-1%7CNone&class=threshold&offnotificationid_new=-1%7CNone&channel_new=1&condition_new=0&threshold_new=0&latency_new=60&objecttype=nodetrigger") //Add Trigger }; var channel = new Channel { Name = "Total", Id = 1 }; TestTriggerChannel(channel, urls, true, new ChannelItem(name: "Total", objId: "1")); }