public void setup() { the_connection = MockRepository.GenerateMock <IDbConnection>(); factories = MockRepository.GenerateMock <IFindAFactoryForADependency>(); the_factory_that_can_create_the_dependency = MockRepository.GenerateMock <ICreateOneDependency>(); factories.Stub(x => x.get_factory_to_create(typeof(IDbConnection))).Return(the_factory_that_can_create_the_dependency); error_handler = MockRepository.GenerateMock <ICreateErrorsFromFactoryContainerErrors>(); }
public void setup() { the_connection = MockRepository.GenerateMock<IDbConnection>(); factories = MockRepository.GenerateMock<IFindAFactoryForADependency>(); the_factory_that_can_create_the_dependency = MockRepository.GenerateMock<ICreateOneDependency>(); factories.Stub(x => x.get_factory_to_create(typeof(IDbConnection))).Return(the_factory_that_can_create_the_dependency); error_handler = MockRepository.GenerateMock<ICreateErrorsFromFactoryContainerErrors>(); }
public void when_the_factory_that_creates_the_dependency_throws_a_dependency_creation_exception() { third_party_exception = new Exception(); wrapped_exception = new Exception(); error_handler = ((type, original_exception) => { Assert.AreEqual(type, typeof(IDbConnection)); Assert.AreEqual(original_exception, third_party_exception); throw wrapped_exception; }); the_factory_that_can_create_the_dependency.Stub(x => x.create()).Throw(third_party_exception); dependency_container = new DependencyContainer(factories, error_handler); dependency_container.a(typeof(IDbConnection)); }
public void when_the_factory_that_creates_the_dependency_throws_a_dependency_creation_exception() { third_party_exception = new Exception(); wrapped_exception = new Exception(); error_handler = ((type, original_exception) => { Assert.AreEqual(type, typeof (IDbConnection)); Assert.AreEqual(original_exception, third_party_exception); throw wrapped_exception; }); the_factory_that_can_create_the_dependency.Stub(x => x.create()).Throw(third_party_exception); dependency_container = new DependencyContainer(factories, error_handler); dependency_container.a(typeof (IDbConnection)); }
public DependencyContainer(IFindAFactoryForADependency factories, ICreateErrorsFromFactoryContainerErrors creation_error_factory) { this.factories = factories; this.creation_error_factory = creation_error_factory; }