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 NotificationTrigger_Throws_WhenChannelCantBeResolved()
        {
            var client = Initialize_Client(new NotificationTriggerResponse(NotificationTriggerItem.ThresholdTrigger(channel: "Backup State")));

            AssertEx.Throws <InvalidStateException>(
                () => client.GetNotificationTriggers(1001).First(),
                "Object may be in a corrupted state"
                );
        }
        private PrtgClient GetResolvesASensorChannelResponseClient()
        {
            var notificationItem = NotificationTriggerItem.ThresholdTrigger(channel: "Backup State");
            var channelItem      = new ChannelItem(name: "Backup State");

            var client = Initialize_Client(new NotificationTriggerResponse(new[] { notificationItem }, new[] { channelItem }));

            return(client);
        }
        public async Task NotificationTrigger_Throws_WhenChannelCantBeResolvedAsync()
        {
            var client = Initialize_Client(new NotificationTriggerResponse(NotificationTriggerItem.ThresholdTrigger(channel: "Backup State")));

            await AssertEx.ThrowsAsync <InvalidStateException>(
                async() => (await client.GetNotificationTriggersAsync(1001)).First(),
                "Object may be in a corrupted state"
                );
        }
        private NotificationTrigger GetTrigger()
        {
            var notificationItem = NotificationTriggerItem.ThresholdTrigger(channel: "Primary");

            var client = Initialize_Client(new NotificationTriggerResponse(new[] { notificationItem }));

            var trigger = client.GetNotificationTriggers(1).First(t => t.Type == TriggerType.Threshold);

            return(trigger);
        }
        private IWebResponse GetTableResponse(string address, string function, bool async)
        {
            var components = UrlUtilities.CrackUrl(address);

            Content?content;

            try
            {
                content = components["content"].DescriptionToEnum <Content>();
            }
            catch
            {
                content = null;
            }

            var count = GetCount(components, content);

            //Hack to make test "forces streaming with a date filter and returns no results" work
            if (content == Content.Logs && count == 0 && components["columns"] == "objid,name")
            {
                count   = 501;
                address = address.Replace("count=1", "count=501");
            }

            if (function == nameof(XmlFunction.HistoricData))
            {
                return(new SensorHistoryResponse(GetItems(i => new SensorHistoryItem(), count)));
            }

            var columns = components["columns"]?.Split(',');

            switch (content)
            {
            case Content.Sensors: return(Sensors(CreateSensor, count, columns, address, async));

            case Content.Devices: return(Devices(CreateDevice, count, columns, address, async));

            case Content.Groups:  return(Groups(CreateGroup, count, columns, address, async));

            case Content.Probes: return(Probes(CreateProbe, count, columns, address, async));

            case Content.Logs:
                if (IsGetTotalLogs(address))
                {
                    return(TotalLogsResponse());
                }

                return(Messages(i => new MessageItem($"WMI Remote Ping{i}"), count));

            case Content.History: return(new ModificationHistoryResponse(new ModificationHistoryItem()));

            case Content.Notifications: return(Notifications(CreateNotification, count));

            case Content.Schedules: return(Schedules(CreateSchedule, count));

            case Content.Channels: return(new ChannelResponse(GetItems(Content.Channels, i => new ChannelItem(), 1)));

            case Content.Objects:
                return(Objects(address, function, components));

            case Content.Triggers:
                return(new NotificationTriggerResponse(
                           NotificationTriggerItem.StateTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group"),
                           NotificationTriggerItem.ThresholdTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group", offNotificationAction: "300|Email to all members of group PRTG Users Group"),
                           NotificationTriggerItem.SpeedTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group", offNotificationAction: "300|Email to all members of group PRTG Users Group"),
                           NotificationTriggerItem.VolumeTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group"),
                           NotificationTriggerItem.ChangeTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group")
                           ));

            case Content.SysInfo:
                return(new SystemInfoResponse(
                           SystemInfoItem.SystemItem(), SystemInfoItem.HardwareItem(), SystemInfoItem.SoftwareItem(),
                           SystemInfoItem.ProcessItem(), SystemInfoItem.ServiceItem(), SystemInfoItem.UserItem()
                           ));

            default:
                throw new NotImplementedException($"Unknown content '{content}' requested from {nameof(MultiTypeResponse)}");
            }
        }