Exemple #1
0
        public void should_reenable_appender_after_quarantine_delay()
        {
            var logEvent = new Mock <ILogEvent>().Object;
            var message  = new byte[4];

            _appenderMock.Setup(x => x.WriteEvent(logEvent, message, message.Length)).Throws <Exception>();

            SystemDateTime.PauseTime();
            _guardedAppender.WriteEvent(logEvent, message, message.Length);
            _appenderMock.Verify(x => x.WriteEvent(logEvent, message, message.Length), Times.Once);

            SystemDateTime.AddToPausedTime(TimeSpan.FromSeconds(2));
            _guardedAppender.WriteEvent(logEvent, message, message.Length);
            _appenderMock.Verify(x => x.WriteEvent(logEvent, message, message.Length), Times.Once);

            SystemDateTime.AddToPausedTime(TimeSpan.FromSeconds(20));
            _guardedAppender.WriteEvent(logEvent, message, message.Length);
            _appenderMock.Verify(x => x.WriteEvent(logEvent, message, message.Length), Times.Exactly(2));
        }