Ejemplo n.º 1
0
 public static ILogHandler For(Type type)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     EnsureFactory();
     return(_loggerFactory.CreateFor(type));
 }
Ejemplo n.º 2
0
        public void should_leverage_the_log_factory_to_create_a_logger_for_the_given_type()
        {
            var logger = mockery.DynamicMock <ILogger>();

            using (mockery.Record()) {
                Expect
                .Call(factory.CreateFor(GetType()))
                .Return(logger)
                .Repeat
                .AtLeastOnce();
            }

            using (mockery.Playback()) {
                Log.For(this);
            }
        }
Ejemplo n.º 3
0
        public void Should_leverage_factory_to_return_a_logger_to_the_client( )
        {
            ILog        mockLog        = mockery.DynamicMock <ILog>( );
            ILogFactory mockLogFactory = mockery.DynamicMock <ILogFactory>( );

            IDependencyContainer mockContainer = mockery.DynamicMock <IDependencyContainer>( );

            using (mockery.Record( )) {
                Expect.Call(mockContainer.GetMeAnImplementationOfAn <ILogFactory>( )).Return(mockLogFactory);
                Expect.Call(mockLogFactory.CreateFor(typeof(LogTest))).Return(mockLog);
            }

            using (mockery.Playback( )) {
                Resolve.InitializeWith(mockContainer);
                ILog log = Log.For(this);
                Assert.AreEqual(mockLog, log);
                Resolve.InitializeWith(null);
            }
        }