public void CallsErrorIfLevelIsError()
        {
            var consoleLogger = new TestLogger(LogLevel.Error);
            consoleLogger.Error("Test");

            Assert.NotEmpty(consoleLogger.GetLogEvents(LogLevel.Error));
        }
        public void WillNotCallWarningIfLevelIsHigher()
        {
            var consoleLogger = new TestLogger(LogLevel.None);
            consoleLogger.Warning("Test");

            Assert.Empty(consoleLogger.GetLogEvents(LogLevel.Warning));
        }
        public void WillNotCallErrorIfLevelIsHigher()
        {
            var consoleLogger = new TestLogger(LogLevel.None);
            consoleLogger.Error("Test");

            Assert.Empty(consoleLogger.GetLogEvents(LogLevel.Error));
        }
        public void WillNotCallInformationIfLevelIsHigher()
        {
            var consoleLogger = new TestLogger(LogLevel.None);
            consoleLogger.Information("Test");

            Assert.Empty(consoleLogger.GetLogEvents(LogLevel.Information));
        }
        public void UsesDefaultObjectRendererForUnknownTypes()
        {
            var testLogger = new TestLogger(LogLevel.Debug);
            
            testLogger.Debug("Test {0}", "Test");

            Assert.Equal("Test Test", testLogger.GetLogEvents(LogLevel.Debug).First());
        }
        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"));
        }
        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));
        }
        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));
        }