public void StateTriggerParameters_Create_FromExistingTrigger()
        {
            var trigger    = GetMultipleItems().First(t => t.Type == TriggerType.State);
            var parameters = new StateTriggerParameters(1234, trigger);

            TriggerParameters_Create_FromExistingTrigger(trigger, parameters);
        }
        public void StateTriggerParameters_AllProperties_HaveValues()
        {
            var parameters = new StateTriggerParameters(1)
            {
                OnNotificationAction         = GetNotificationAction(),
                OffNotificationAction        = GetNotificationAction(),
                EscalationNotificationAction = GetNotificationAction(),
                Latency           = 60,
                EscalationLatency = 300,
                RepeatInterval    = 3,
                State             = TriggerSensorState.PartialDown
            };

            Func <PropertyInfo, bool> additionalChecks = prop =>
            {
                var val = prop.GetValue(parameters);

                if (prop.Name == nameof(parameters.State))
                {
                    Assert.IsTrue(!((Enum)val).Equals(TriggerSensorState.Down), $"Property '{prop.Name}' had value {val}");
                    return(true);
                }

                return(false);
            };

            TriggerParameters_AllProperties_HaveValues(parameters, additionalChecks);
        }
        public async Task AddNotificationTrigger_UnsupportedTypeAsync()
        {
            var client = Initialize_Client(new SetNotificationTriggerResponse());

            var parameters = new StateTriggerParameters(1001);

            await AssertEx.ThrowsAsync <InvalidTriggerTypeException>(async() => await client.AddNotificationTriggerAsync(parameters), "Trigger type 'State' is not a valid trigger type");
        }
        public void AddNotificationTrigger_UnsupportedType()
        {
            var client = Initialize_Client(new SetNotificationTriggerResponse());

            var parameters = new StateTriggerParameters(1001);

            AssertEx.Throws <InvalidTriggerTypeException>(() => client.AddNotificationTrigger(parameters), "Trigger type 'State' is not a valid trigger type");
        }
        public async Task SetNotificationTrigger_CanExecuteAsync()
        {
            var client = Initialize_Client(new SetNotificationTriggerResponse());

            var parameters = new StateTriggerParameters(1001, 1);

            await client.SetNotificationTriggerAsync(parameters);
        }
        public void SetNotificationTrigger_CanExecute()
        {
            var client = Initialize_Client(new SetNotificationTriggerResponse());

            var parameters = new StateTriggerParameters(1001, 1);

            client.SetNotificationTrigger(parameters);
        }
        public async Task AddNotificationTrigger_Throws_ResolvingMultipleAsync()
        {
            var client = Initialize_Client(new DiffBasedResolveResponse(true));

            var parameters = new StateTriggerParameters(1001)
            {
                OnNotificationAction = { Id = 301 }
            };

            var str = "Could not uniquely identify created NotificationTrigger: multiple new objects ('Type = State, Inherited = False, OnNotificationAction = Email to all members of group PRTG Users Group 2',";

            await AssertEx.ThrowsAsync <ObjectResolutionException>(async() => await client.AddNotificationTriggerAsync(parameters), str);
        }
        public async Task AddNotificationTrigger_ResolveScenariosAsync()
        {
            var client = Initialize_Client(new DiffBasedResolveResponse(false));

            var parameters = new StateTriggerParameters(1001)
            {
                OnNotificationAction = { Id = 301 }
            };

            var resolvedTrigger = await client.AddNotificationTriggerAsync(parameters);

            Assert.AreEqual("Email to all members of group PRTG Users Group 2", resolvedTrigger.OnNotificationAction.ToString());

            var trigger = await client.AddNotificationTriggerAsync(parameters, false);

            Assert.AreEqual(null, trigger, "Trigger was not null");
        }
示例#9
0
        public void Action_NotificationTrigger_AddWithCustomization_State()
        {
            var actions = client.GetNotificationActions();

            var parameters = new StateTriggerParameters(Settings.Probe)
            {
                OnNotificationAction         = actions.First(),
                OffNotificationAction        = actions.Skip(1).First(),
                EscalationNotificationAction = actions.Skip(2).First(),
                Latency           = 90,
                EscalationLatency = 400,
                RepeatInterval    = 3,
                State             = TriggerSensorState.PartialDown
            };

            AddRemoveTrigger(parameters, false);
        }
示例#10
0
        private void CloneTrigger()
        {
            TriggerParameters parameters;

            switch (Trigger.Type)
            {
            case TriggerType.Change:
                parameters = new ChangeTriggerParameters(DestinationId, Trigger);
                break;

            case TriggerType.State:
                parameters = new StateTriggerParameters(DestinationId, Trigger);
                break;

            case TriggerType.Speed:
                parameters = new SpeedTriggerParameters(DestinationId, Trigger);
                break;

            case TriggerType.Threshold:
                parameters = new ThresholdTriggerParameters(DestinationId, Trigger);
                break;

            case TriggerType.Volume:
                parameters = new VolumeTriggerParameters(DestinationId, Trigger);
                break;

            default:
                throw new NotImplementedException($"Handler of trigger type '{Trigger.Type}' is not implemented.");
            }

            if (Resolve)
            {
                var triggers = client.AddNotificationTriggerInternal(parameters, true, CancellationToken, DisplayResolutionError, ShouldStop);

                foreach (var obj in triggers)
                {
                    WriteObject(obj);
                }
            }
            else
            {
                client.AddNotificationTrigger(parameters);
            }
        }
示例#11
0
        public void Action_NotificationTrigger_AddWithoutCustomization_State()
        {
            var parameters = new StateTriggerParameters(Settings.Probe);

            AddRemoveTrigger(parameters, true);
        }
        public void StateTriggerParameters_AllProperties_HaveDefault()
        {
            var parameters = new StateTriggerParameters(1, 1);

            TriggerParameters_AllProperties_HaveDefault(parameters);
        }
示例#13
0
 public void TriggerParameters_Create_FromNullTrigger()
 {
     var parameters = new StateTriggerParameters(1234, null, ModifyAction.Add);
 }