예제 #1
0
        public void ShouldDelegateInfoMessageToLegacyLogger()
        {
            var legacyLogger = new Mock <ILogger>();
            var logger       = new LegacyLoggerAdapter(legacyLogger.Object);

            logger.Info("message: {0}", "hello world");
            legacyLogger.Verify(x => x.Info("message: hello world"));
        }
예제 #2
0
        public void ShouldAllowNullLegacyLogger()
        {
            var logger = new LegacyLoggerAdapter(null);

            // should not throw any error
            logger.Error(null, "1");
            logger.Warn(null, "2");
            logger.Info(null, "3");
            logger.Debug("4");
            logger.Trace("5");
        }
예제 #3
0
        public void ShouldDelegateInfoToLegacyLogger()
        {
            var legacyLogger = new Mock <ILogger>();
            var logger       = new LegacyLoggerAdapter(legacyLogger.Object);

            var message = "a message {0}";
            var error   = new Exception("an exception");

            logger.Info(message, error);

            legacyLogger.Verify(x => x.Info("a message System.Exception: an exception"));
        }