Ejemplo n.º 1
0
        public void Log4NetLogger_LoggingTest()
        {
            string    message       = "Error Message";
            Exception ex            = new Exception();
            string    messageFormat = "Message Format: message: {0}, exception: {1}";

            ILog log = new Log4NetLogger(GetType());

            Assert.IsNotNull(log);

            log.Debug(message);
            log.Debug(message, ex);
            log.DebugFormat(messageFormat, message, ex.Message);

            log.Error(message);
            log.Error(message, ex);
            log.ErrorFormat(messageFormat, message, ex.Message);

            log.Fatal(message);
            log.Fatal(message, ex);
            log.FatalFormat(messageFormat, message, ex.Message);

            log.Info(message);
            log.Info(message, ex);
            log.InfoFormat(messageFormat, message, ex.Message);

            log.Warn(message);
            log.Warn(message, ex);
            log.WarnFormat(messageFormat, message, ex.Message);
        }
Ejemplo n.º 2
0
        public void When_logging_using_fatal_format()
        {
            _logger.FatalFormat("E:{0}", 1);
            _mockedLogger.Verify(l => l.FatalFormat("E:{0}", 1), Times.Once);

            _logger.FatalFormat("E:{0}, {1}", 1, 2);
            _mockedLogger.Verify(l => l.FatalFormat("E:{0}, {1}", 1, 2), Times.Once);

            _logger.FatalFormat("E:{0}, {1}, {2}", 1, 2, 3);
            _mockedLogger.Verify(l => l.FatalFormat("E:{0}, {1}, {2}", 1, 2, 3), Times.Once);

            _logger.FatalFormat("E:{0}, {1}, {2}, {3}, {4}", 1, 2, 3, 4, 5);
            _mockedLogger.Verify(l => l.FatalFormat("E:{0}, {1}, {2}, {3}, {4}", 1, 2, 3, 4, 5), Times.Once);

            var italianCulture = new CultureInfo("it-It");
            var date           = new DateTime(2000, 12, 28, 1, 4, 43, 0);

            _logger.FatalFormat(italianCulture, "Date: {0}", date);
            _mockedLogger.Verify(l => l.FatalFormat(italianCulture, "Date: {0}", date));
        }
Ejemplo n.º 3
0
        public void Fatal_FormatMessage()
        {
            // Prepare
            const string format = "Number of Call: {0} occurred";

            logger.SetupGet(o => o.IsFatalEnabled).Returns(() => true);
            logger.Setup(o => o.FatalFormat(format, new object[] { 1 })).Verifiable();
            log = new Log4NetLogger(logger.Object);

            // Act
            log.FatalFormat(format, 1);

            // Assert
            logger.VerifyAll();
        }
Ejemplo n.º 4
0
        public void Fatal_FormatMessage()
        {
            // Prepare
            const string format = "Number of Call: {0} occurred";
            logger.SetupGet(o => o.IsFatalEnabled).Returns(() => true);
            logger.Setup(o => o.FatalFormat(format, new object[] { 1 })).Verifiable();
            log = new Log4NetLogger(logger.Object);

            // Act
            log.FatalFormat(format, 1);

            // Assert
            logger.VerifyAll();
        }