private void RunTestAndCheckIfOneItemLogged(Action <ILogger <object>, WindsorContainer> testAction)
        {
            WindsorContainer       container = new WindsorContainer();
            TestLogOutput <object> logOutput = new TestLogOutput <object>();
            ILogger <object>       logger    = LoggerFactory.Create <object>().WriteTo(logOutput);

            logger.BindToWindsor(container.Kernel);

            testAction(logger, container);

            Assert.AreEqual(1, logOutput.LogDataCount);
        }
コード例 #2
0
        public void DecoratorsMethodsShouldBeLoggable()
        {
            WindsorContainer       container = new WindsorContainer();
            TestLogOutput <object> logOutput = new TestLogOutput <object>();
            ILogger <object>       logger    = LoggerFactory.Create <object>().WriteTo(logOutput);

            logger.BindToWindsor(container.Kernel);

            logger.LogInvocationOf <TestClass>(t => t.TestMethod());
            logger.LogInvocationOf <TestClassDecorator>(t => t.TestMethod());

            container.Register(Component.For <ITest>().ImplementedBy <TestClassDecorator>());
            container.Register(Component.For <ITest>().ImplementedBy <TestClass>());

            container.Resolve <ITest>().TestMethod();

            Assert.AreEqual(2, logOutput.LogDataCount);
        }