Пример #1
0
        public void WillNotCallDebugIfLevelIsHigher()
        {
            var consoleLogger = new TestLogger(LogLevel.None);
            consoleLogger.Debug("Test");

            Assert.Empty(consoleLogger.GetLogEvents(LogLevel.Debug));
        }
Пример #2
0
        public void UsesDefaultObjectRendererForUnknownTypes()
        {
            var testLogger = new TestLogger(LogLevel.Debug);
            
            testLogger.Debug("Test {0}", "Test");

            Assert.Equal("Test Test", testLogger.GetLogEvents(LogLevel.Debug).First());
        }
Пример #3
0
        public void UsesSpecifiedObjectRendererForType()
        {
            var testLogger = new TestLogger(LogLevel.Debug);
            var mockRenderer = MockRepository.GenerateMock<IObjectRenderer>();
            testLogger.AddObjectRenderer<string>(mockRenderer);

            testLogger.Debug("Test {0}", "Test");

            mockRenderer.AssertWasCalled(p => p.Render("Test"));
        }
Пример #4
0
        public void WalksTheClassHierarchyUpwardsIfNoRenderersAreFound()
        {
            var testLogger = new TestLogger(LogLevel.Debug);
            var mockRenderer = MockRepository.GenerateMock<IObjectRenderer>();
            testLogger.AddObjectRenderer<ObjectRendering>(mockRenderer);

            var childClassOfChildClass = new SubTestClass();
            testLogger.Debug("Test {0}", childClassOfChildClass);

            mockRenderer.AssertWasCalled(p => p.Render(childClassOfChildClass));
        }
Пример #5
0
        public void UsesRendererOfBaseClassIfPossible()
        {
            var testLogger = new TestLogger(LogLevel.Debug);
            var mockRenderer = MockRepository.GenerateMock<IObjectRenderer>();
            testLogger.AddObjectRenderer<ObjectRendering>(mockRenderer);

            var testChildClass = new TestChildClass();
            testLogger.Debug("Test {0}", testChildClass);

            mockRenderer.AssertWasCalled(p => p.Render(testChildClass));
        }