public void InitializeTest() { IKernel mockKernel = MockRepository.GenerateMock <IKernel>(); IWindsorContainer mockWindsorContainer = MockRepository.GenerateMock <IWindsorContainer>(); mockKernel.Expect(m => m.HasComponent(typeof(int))).Return(true); mockKernel.Expect(m => m.HasComponent(typeof(string))).Return(true); mockWindsorContainer.Expect(m => m.Resolve(typeof(int))).Return(1); mockWindsorContainer.Expect(m => m.ResolveAll(typeof(int))).Return(new[] { 1, 2, 3 }); mockWindsorContainer.Expect(m => m.Resolve(typeof(string))).Return("1"); mockWindsorContainer.Expect(m => m.ResolveAll(typeof(string))).Return(new[] { "1", "2", "3" }); mockWindsorContainer.Expect(m => m.Kernel).Return(mockKernel); Target = new WindsorDependencyResolver(mockWindsorContainer); }
public void ThenReleaseShouldBeCalled() { var obj = new object(); _container.Expect(c => c.Release(obj)); _resolver.DisposeImplementation(obj); _container.VerifyAllExpectations(); }
public void InitializeTest() { _TestTransaction = new TransactionScope(); try { IRepositoryContainer educationContainer = MockRepository.GenerateMock<IRepositoryContainer>(); EducationDataContext = new EducationDataContext(); educationContainer.Expect(m => m.Obtain<IUserRepository>()).Return(new UserRepository(EducationDataContext)); educationContainer.Expect(m => m.Obtain<IEulaAgreementRepository>()).Return(new EulaAgreementRepository(EducationDataContext)); MockWindsorContainer = MockRepository.GenerateMock<IWindsorContainer>(); MockWindsorContainer.Expect(m => m.Resolve<IRepositoryContainer>()).Return(educationContainer); AccountManager = new AccountManager(MockWindsorContainer, MockRepository.GenerateMock<IEmailConfirmationManager>(), new DataTableBinder(), new UserAuditor()); MockDependecyResolver = MockRepository.GenerateMock<IDependencyResolver>(); MockDependecyResolver.Expect(m => m.GetService(typeof(IAccountManager))).Return(AccountManager); DependencyResolver.SetResolver(MockDependecyResolver); } catch (Exception) { _TestTransaction.Dispose(); _TestTransaction = null; if (EducationDataContext != null) { EducationDataContext.Dispose(); EducationDataContext = null; } throw; } }