public void FollowUpNotificationOnAcknowledgementTimeout()
        {
            // Set up
            _persistenceAdapterMock.Setup(m => m.RetrieveMonitoredService(MONITORED_SERVICE_ID))
            .Returns(GetMonitoredService(isHealthy: false, escalationLevel: ESCALATION_LEVEL_2));
            _persistenceAdapterMock.Setup(m => m.UpdateEscalationLevel(MONITORED_SERVICE_ID, ESCALATION_LEVEL_3));

            _escalationPolicyAdapterMock
            .Setup(m => m.RetrieveEscalationPolicy(SERVICE_ID))
            .Returns(GetEscalationPolicy());

            _emailAdapaterMock.Setup(m => m.SendEmail(ESCALATION_LEVEL_EMAIL_3));

            _timerAdapterMock.Setup(m => m.CreateTimer(MONITORED_SERVICE_ID, _timer15min));

            // Act
            var pager = new PagerService(_persistenceAdapterMock.Object, _escalationPolicyAdapterMock.Object, _timerAdapterMock.Object,
                                         _emailAdapaterMock.Object, _smsAdapaterMock.Object) as IPagerService;

            pager.AcknowledgmentTimeout(MONITORED_SERVICE_ID);

            // Assert
            _persistenceAdapterMock.Verify(m => m.RetrieveMonitoredService(MONITORED_SERVICE_ID), Times.Once);
            _persistenceAdapterMock.Verify(m => m.UpdateEscalationLevel(MONITORED_SERVICE_ID, ESCALATION_LEVEL_3), Times.Once);
            _escalationPolicyAdapterMock.Verify(m => m.RetrieveEscalationPolicy(SERVICE_ID), Times.Once);
            _emailAdapaterMock.Verify(m => m.SendEmail(ESCALATION_LEVEL_EMAIL_3), Times.Once);
            _timerAdapterMock.Verify(m => m.CreateTimer(MONITORED_SERVICE_ID, _timer15min), Times.Once);
        }
        public void HealthyEventFollowedByAcknowledgementTimeoutSetToHealthy()
        {
            // Set Up
            _persistenceAdapterMock.Setup(m => m.RetrieveMonitoredService(MONITORED_SERVICE_ID))
            .Returns(GetMonitoredService(isHealthy: false));
            _persistenceAdapterMock.Setup(m => m.UpdateHealthStatus(MONITORED_SERVICE_ID, true));

            //Act
            var pager = new PagerService(_persistenceAdapterMock.Object, _escalationPolicyAdapterMock.Object, _timerAdapterMock.Object,
                                         _emailAdapaterMock.Object, _smsAdapaterMock.Object) as IPagerService;

            pager.UpdateHealthStatus(GetHealthyEvent());
            pager.AcknowledgmentTimeout(MONITORED_SERVICE_ID);

            //Assert
            _persistenceAdapterMock.Verify(m => m.RetrieveMonitoredService(MONITORED_SERVICE_ID), Times.Once);
            _persistenceAdapterMock.Verify(m => m.UpdateHealthStatus(MONITORED_SERVICE_ID, true), Times.Once);
        }
        public void NoNotificationOnceMonitoredServiceIsAcknowledged()
        {
            // Set Up
            _persistenceAdapterMock.Setup(m => m.RetrieveMonitoredService(MONITORED_SERVICE_ID))
            .Returns(GetMonitoredService(isHealthy: false, isAlertAcknowledged: true, escalationLevel: ESCALATION_LEVEL_2));

            _escalationPolicyAdapterMock
            .Setup(m => m.RetrieveEscalationPolicy(SERVICE_ID))
            .Returns(GetEscalationPolicy());

            // Act
            var pager = new PagerService(_persistenceAdapterMock.Object, _escalationPolicyAdapterMock.Object, _timerAdapterMock.Object,
                                         _emailAdapaterMock.Object, _smsAdapaterMock.Object) as IPagerService;

            pager.AcknowledgmentTimeout(MONITORED_SERVICE_ID);

            // Assert
            _persistenceAdapterMock.Verify(m => m.RetrieveMonitoredService(MONITORED_SERVICE_ID), Times.Once);
            _escalationPolicyAdapterMock.Verify(m => m.RetrieveEscalationPolicy(SERVICE_ID), Times.Once);
        }
        public void NotifyAllTargets()
        {
            // Set up
            _persistenceAdapterMock.Setup(m => m.RetrieveMonitoredService(MONITORED_SERVICE_ID))
            .Returns(GetMonitoredService(isHealthy: false, escalationLevel: ESCALATION_LEVEL_1));
            _persistenceAdapterMock.Setup(m => m.UpdateEscalationLevel(MONITORED_SERVICE_ID, ESCALATION_LEVEL_2));

            _escalationPolicyAdapterMock
            .Setup(m => m.RetrieveEscalationPolicy(SERVICE_ID))
            .Returns(GetEscalationPolicy());

            _emailAdapaterMock.Setup(m => m.SendEmail(ESCALATION_LEVEL_EMAIL_1));
            _emailAdapaterMock.Setup(m => m.SendEmail(ESCALATION_LEVEL_EMAIL_2));

            _smsAdapaterMock.Setup(m => m.SendSms(ESCALATION_LEVEL_SMS_1));
            _smsAdapaterMock.Setup(m => m.SendSms(ESCALATION_LEVEL_SMS_2));

            _timerAdapterMock.Setup(m => m.CreateTimer(MONITORED_SERVICE_ID, _timer15min));

            // Act
            var pager = new PagerService(_persistenceAdapterMock.Object, _escalationPolicyAdapterMock.Object, _timerAdapterMock.Object,
                                         _emailAdapaterMock.Object, _smsAdapaterMock.Object) as IPagerService;

            pager.AcknowledgmentTimeout(MONITORED_SERVICE_ID);

            // Assert
            _persistenceAdapterMock.Verify(m => m.RetrieveMonitoredService(MONITORED_SERVICE_ID), Times.Once);
            _persistenceAdapterMock.Verify(m => m.UpdateEscalationLevel(MONITORED_SERVICE_ID, ESCALATION_LEVEL_2), Times.Once);
            _escalationPolicyAdapterMock.Verify(m => m.RetrieveEscalationPolicy(SERVICE_ID), Times.Once);

            _emailAdapaterMock.Verify(m => m.SendEmail(It.IsAny <string>()), Times.Exactly(2));
            _emailAdapaterMock.Verify(m => m.SendEmail(ESCALATION_LEVEL_EMAIL_1), Times.Once);
            _emailAdapaterMock.Verify(m => m.SendEmail(ESCALATION_LEVEL_EMAIL_2), Times.Once);

            _smsAdapaterMock.Verify(m => m.SendSms(It.IsAny <string>()), Times.Exactly(2));
            _smsAdapaterMock.Verify(m => m.SendSms(ESCALATION_LEVEL_SMS_1), Times.Once);
            _smsAdapaterMock.Verify(m => m.SendSms(ESCALATION_LEVEL_SMS_2), Times.Once);

            _timerAdapterMock.Verify(m => m.CreateTimer(MONITORED_SERVICE_ID, _timer15min), Times.Once);
        }