public void ServiceLevelAgreementMonitor_Should_Invoke_Proceed_On_The_Proxied_Method() { var slaProvider = new Mock <IServiceLevelAgreementProvider>(); var monitor = new ServiceLevelAgreementMonitor(slaProvider.Object); var mockIntercept = new Mock <IInvocation>(); mockIntercept.Setup(x => x.TargetType).Returns(typeof(SynchronousSLAMonitorTests)); monitor.Intercept(mockIntercept.Object); mockIntercept.Verify(x => x.Proceed()); }
public void ServiceLevelAgreementMonitor_Should_Request_The_SLA_From_The_SLA_Provider() { var slaProvider = new Mock <IServiceLevelAgreementProvider>(); var monitor = new ServiceLevelAgreementMonitor(slaProvider.Object); var expectedSlaType = typeof(SynchronousSLAMonitorTests); var mockIntercept = new Mock <IInvocation>(); mockIntercept.Setup(x => x.TargetType).Returns(expectedSlaType); monitor.Intercept(mockIntercept.Object); slaProvider.Verify(x => x.GetServiceLevelAgreement(expectedSlaType)); }
public void ServiceLevelAgreementMonitor_Should_Log_The_Correct_SLA_Message_when_SLA_is_met() { var slaProvider = new Mock <IServiceLevelAgreementProvider>(); SetupSLAWayIntoTheFuture(slaProvider); var monitor = new ServiceLevelAgreementMonitor(slaProvider.Object); var expectedSlaType = typeof(SynchronousSLAMonitorTests); var mockIntercept = new Mock <IInvocation>(); mockIntercept.Setup(x => x.TargetType).Returns(expectedSlaType); monitor.Intercept(mockIntercept.Object); var appender = GetAppender(); AssertLoggingEvent(appender.Events, Level.Debug); }
public void ServiceLevelAgreementMonitor_Should_use_debug_log_level_when_unsupported_level_provided(Level level) { var slaProvider = new Mock <IServiceLevelAgreementProvider>(); SetupSLAWayIntoTheFuture(slaProvider); var loggingConfiguration = new LoggingConfiguration(loggingLevelWhenSlaIsMet: Level.Off, loggingLevelWhenSlaIsBreached: level); var monitor = new ServiceLevelAgreementMonitor(slaProvider.Object, loggingConfiguration); var expectedSlaType = typeof(SynchronousSLAMonitorTests); var mockIntercept = new Mock <IInvocation>(); mockIntercept.Setup(x => x.TargetType).Returns(expectedSlaType); monitor.Intercept(mockIntercept.Object); var appender = GetAppender(); AssertLoggingEvent(appender.Events, Level.Debug); }
public void ServiceLevelAgreementMonitor_Should_Log_An_Error_When_SLA_is_breached() { var slaProvider = new Mock <IServiceLevelAgreementProvider>(); SetupSLAOfZero(slaProvider); var monitor = new ServiceLevelAgreementMonitor(slaProvider.Object); var expectedSlaType = typeof(SynchronousSLAMonitorTests); var mockIntercept = new Mock <IInvocation>(); mockIntercept.Setup(x => x.Proceed()).Callback(() => Thread.Sleep(5)); mockIntercept.Setup(x => x.TargetType).Returns(expectedSlaType); monitor.Intercept(mockIntercept.Object); var appender = GetAppender(); AssertLoggingEvent(appender.Events, Level.Error); }
public void ServiceLevelAgreementMonitor_Should_be_able_to_configure_the_breach_logging_level(Level level) { var slaProvider = new Mock <IServiceLevelAgreementProvider>(); SetupSLAOfZero(slaProvider); var loggingConfiguration = new LoggingConfiguration(loggingLevelWhenSlaIsMet: Level.Off, loggingLevelWhenSlaIsBreached: level); var monitor = new ServiceLevelAgreementMonitor(slaProvider.Object, loggingConfiguration); var expectedSlaType = typeof(SynchronousSLAMonitorTests); var mockIntercept = new Mock <IInvocation>(); mockIntercept.Setup(x => x.Proceed()).Callback(() => Thread.Sleep(5)); mockIntercept.Setup(x => x.TargetType).Returns(expectedSlaType); monitor.Intercept(mockIntercept.Object); var appender = GetAppender(); AssertLoggingEvent(appender.Events, level); }