Exemplo n.º 1
0
        public void Test()
        {
            var loggerFactory = new Log4NetLoggerFactory();

            global::log4net.LogManager.ResetConfiguration();
            Log4NetConfigurator.Configure(new ConsoleAppender { Threshold = Level.All });

            var log = loggerFactory.GetLogger("Test");

            Assert.IsInstanceOf<Log4NetLogger>(log);

            CallAllMethodsOnLog(log);

            log = loggerFactory.GetLogger(typeof(LoggerFactoryTests));

            CallAllMethodsOnLog(log);
        }
Exemplo n.º 2
0
        public void Test()
        {
            var loggerFactory = new Log4NetLoggerFactory();

            global::log4net.LogManager.ResetConfiguration();
            Log4NetConfigurator.Configure(new ConsoleAppender {
                Threshold = Level.All
            });

            var log = loggerFactory.GetLogger("Test");

            Assert.IsInstanceOf <Log4NetLogger>(log);

            CallAllMethodsOnLog(log);

            log = loggerFactory.GetLogger(typeof(LoggerFactoryTests));

            CallAllMethodsOnLog(log);
        }
Exemplo n.º 3
0
        public void Test_GetLogger_WithType_ShouldSetContext()
        {
            //---------------Set up test pack-------------------
            IHabaneroLoggerFactory loggerFactory       = new Log4NetLoggerFactory();
            const string           expectedContextName = "Habanero.Test.Base.Logging.FakeObject";
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var logger = loggerFactory.GetLogger(typeof(FakeObject));

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedContextName, logger.ContextName);
        }
Exemplo n.º 4
0
        public void Test_GetLogger_WithType_ShouldCreateLog4NetLogger()
        {
            //---------------Set up test pack-------------------
            IHabaneroLoggerFactory loggerFactory = new Log4NetLoggerFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var logger = loggerFactory.GetLogger(typeof(FakeObject));

            //---------------Test Result -----------------------
            Assert.IsNotNull(logger);
            Assert.IsInstanceOf <Log4NetLogger>(logger);
        }
Exemplo n.º 5
0
        public void Test_GetLogger_WithContextname_ShouldReturnNewLoggerWithContextName()
        {
            //---------------Set up test pack-------------------
            IHabaneroLoggerFactory loggerFactory = new Log4NetLoggerFactory();
            string expectedContextName           = TestUtil.GetRandomString();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var logger = loggerFactory.GetLogger(expectedContextName);

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedContextName, logger.ContextName);
        }
Exemplo n.º 6
0
        public void Test_GetLogger_ShouldReturnNewLogger()
        {
            //---------------Set up test pack-------------------
            IHabaneroLoggerFactory loggerFactory = new Log4NetLoggerFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var logger = loggerFactory.GetLogger(TestUtil.GetRandomString());

            //---------------Test Result -----------------------
            Assert.IsNotNull(logger);
            Assert.IsInstanceOf <IHabaneroLogger>(logger);
            Assert.IsInstanceOf <Log4NetLogger>(logger);
        }