public static Interface DependencyFor <Interface>() { try { return(container.GetMeAnImplementationOfAn <Interface>( )); } catch (Exception e) { throw new InterfaceResolutionException(e, typeof(Interface)); } }
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); } }