Exemplo n.º 1
0
        public void NewAlertForMonitoredService()
        {
            // Set Up
            _persistenceAdapterMock.Setup(m => m.CreateOrRetrieveMonitoredService(SERVICE_ID)).Returns(GetMonitoredService());
            _persistenceAdapterMock.Setup(m => m.UpdateHealthStatus(MONITORED_SERVICE_ID, false));

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

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

            _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.Alert(GetAlert());

            // Assert

            _persistenceAdapterMock.Verify(m => m.UpdateHealthStatus(MONITORED_SERVICE_ID, false), Times.Once);
            _persistenceAdapterMock.Verify(m => m.CreateOrRetrieveMonitoredService(SERVICE_ID), Times.Once);
            _escalationPolicyAdapterMock.Verify(m => m.RetrieveEscalationPolicy(SERVICE_ID), Times.Once);
            _emailAdapaterMock.Verify(m => m.SendEmail(ESCALATION_LEVEL_EMAIL_1), Times.Once);
            _timerAdapterMock.Verify(m => m.CreateTimer(MONITORED_SERVICE_ID, _timer15min), Times.Once);
        }
Exemplo n.º 2
0
        public void DuplicateAlertForMonitoredService()
        {
            //Set Up
            _persistenceAdapterMock.Setup(m => m.CreateOrRetrieveMonitoredService(SERVICE_ID))
            .Returns(GetMonitoredService(isHealthy: false));

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

            pager.Alert(GetAlert());

            // Assert
            _persistenceAdapterMock.Verify(m => m.CreateOrRetrieveMonitoredService(SERVICE_ID), Times.Once);
        }