示例#1
0
文件: Resolve.cs 项目: xlgmokha/sait
 public static Interface DependencyFor <Interface>()
 {
     try {
         return(container.GetMeAnImplementationOfAn <Interface>( ));
     }
     catch (Exception e) {
         throw new InterfaceResolutionException(e, typeof(Interface));
     }
 }
示例#2
0
文件: LogTest.cs 项目: xlgmokha/sait
        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);
            }
        }