Exemplo n.º 1
0
        public void TheLoggerShouldNotLogWithNone()
        {
            var logger = new BaseLoggerMock { LoggingLevel = LogLevels.LogNone };

            logger.Fatal("test");
            logger.Fatal("test", new Exception("testException"));
            logger.FatalFormat("{0}", "test");
            var culture = CultureInfo.CreateSpecificCulture("en-US");
            logger.FatalFormat(culture, "{0}-{1}", "test", 0.2533);
            culture = CultureInfo.CreateSpecificCulture("it-IT");
            logger.FatalFormat(culture, "{0}-{1}", "test", 0.2533);
            Assert.IsNull(logger.ToWrite);
            Assert.IsNull(logger.ToWriteExpanded);
        }
Exemplo n.º 2
0
        public void TheLoggerShouldLogWithFatal()
        {
            var logger = new BaseLoggerMock { LoggingLevel = LogLevels.LogFatal };

            logger.Fatal("test");
            Assert.AreEqual("test", logger.ToWrite);
            Assert.IsTrue(logger.ToWriteExpanded.IndexOf("(FATAL) test") == START_OF_DATA_INDEX, logger.ToWriteExpanded);
            Assert.AreEqual(LogLevels.LogFatal, logger.ToWriteLevel);

            logger.Fatal("test", new Exception("testException"));
            Assert.AreEqual("test\nSystem.Exception: testException", logger.ToWrite);
            Assert.IsTrue(logger.ToWriteExpanded.IndexOf("(FATAL) test\nSystem.Exception: testException") == START_OF_DATA_INDEX, logger.ToWriteExpanded);
            Assert.AreEqual(LogLevels.LogFatal, logger.ToWriteLevel);

            logger.FatalFormat("{0}", "test");
            Assert.AreEqual("test", logger.ToWrite);
            Assert.IsTrue(logger.ToWriteExpanded.IndexOf("(FATAL) test") == START_OF_DATA_INDEX, logger.ToWriteExpanded);
            Assert.AreEqual(LogLevels.LogFatal, logger.ToWriteLevel);

            var culture = CultureInfo.CreateSpecificCulture("en-US");
            logger.FatalFormat(culture, "{0}-{1}", "test", 0.2533);
            Assert.AreEqual("test-0.2533", logger.ToWrite);
            Assert.IsTrue(logger.ToWriteExpanded.IndexOf("(FATAL) test-0.2533") == START_OF_DATA_INDEX, logger.ToWriteExpanded);
            Assert.AreEqual(LogLevels.LogFatal, logger.ToWriteLevel);

            culture = CultureInfo.CreateSpecificCulture("it-IT");
            logger.FatalFormat(culture, "{0}-{1}", "test", 0.2533);
            Assert.AreEqual("test-0,2533", logger.ToWrite);
            Assert.IsTrue(logger.ToWriteExpanded.IndexOf("(FATAL) test-0,2533") == START_OF_DATA_INDEX, logger.ToWriteExpanded);
            Assert.AreEqual(LogLevels.LogFatal, logger.ToWriteLevel);

            logger.LoggingLevel = LogLevels.LogNone;
            logger.Reset();

            logger.Fatal("test");
            logger.Fatal("test", new Exception("testException"));
            logger.FatalFormat("{0}", "test");
            culture = CultureInfo.CreateSpecificCulture("en-US");
            logger.FatalFormat(culture, "{0}-{1}", "test", 0.2533);
            culture = CultureInfo.CreateSpecificCulture("it-IT");
            logger.FatalFormat(culture, "{0}-{1}", "test", 0.2533);
            Assert.IsNull(logger.ToWrite);
            Assert.IsNull(logger.ToWriteExpanded);
        }