Exemple #1
0
 public void ThrowsAnExceptionWhenTheLogIsNull()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var unused = new DefaultEventLoggingPolicy(null);
     });
 }
Exemple #2
0
        public void LogsTheEventInformation()
        {
            var log = new Mock <ILog>();

            var target = new DefaultEventLoggingPolicy(log.Object);

            target.LogEvent(EventLevel.Error, new PInvokeInt32CallCompletedTraceEvent());

            log.Verify(o => o.Log(EventLevel.Error, It.IsAny <TraceEvent>()), Times.Once);
        }
Exemple #3
0
        public void SwallowExceptionsWhenLoggingEvents()
        {
            var log = new Mock <ILog>();

            log.Setup(o => o.Log(EventLevel.Error, It.IsAny <TraceEvent>())).Throws <Exception>().Verifiable();

            var target = new DefaultEventLoggingPolicy(log.Object);

            target.LogEvent(EventLevel.Error, new PInvokeInt32CallCompletedTraceEvent());

            log.Verify();
        }
Exemple #4
0
        public void ThrowsAnExceptionWhenTheEventDataIsNull()
        {
            var target = new DefaultEventLoggingPolicy(new Mock <ILog>().Object);

            Assert.Throws <ArgumentNullException>(() => target.LogEvent(EventLevel.Error, null));
        }