public void it_should_create_the_dependency_with_all_of_its_dependencies_resolved_correctly() { greediest_constructor = ObjectFactory.expression.to_target <TypeWithLotsOfDependencies>(). ctor_pointed_at_by(() => new TypeWithLotsOfDependencies(null, null)); pick_a_constructor = (type) => { Assert.AreEqual(type, typeof(TypeWithLotsOfDependencies)); return(greediest_constructor); }; the_container.Stub(x => x.a(typeof(IDbConnection))).Return(connection); the_container.Stub(x => x.a(typeof(IDataReader))).Return(reader); dependency_resolver = new AutomaticallyResolvingDependencyFactory(typeof(TypeWithLotsOfDependencies), pick_a_constructor, the_container); result = (TypeWithLotsOfDependencies)dependency_resolver.create(); Assert.IsInstanceOf <TypeWithLotsOfDependencies>(result); Assert.AreEqual(result.connection, connection); Assert.AreEqual(result.reader, reader); }
public void it_should_create_the_dependency_with_all_of_its_dependencies_resolved_correctly() { greediest_constructor = ObjectFactory.expression.to_target<TypeWithLotsOfDependencies>(). ctor_pointed_at_by(() => new TypeWithLotsOfDependencies(null,null)); pick_a_constructor = (type) => { Assert.AreEqual(type, typeof (TypeWithLotsOfDependencies)); return greediest_constructor; }; the_container.Stub(x => x.a(typeof (IDbConnection))).Return(connection); the_container.Stub(x => x.a(typeof (IDataReader))).Return(reader); dependency_resolver = new AutomaticallyResolvingDependencyFactory(typeof(TypeWithLotsOfDependencies), pick_a_constructor, the_container); result = (TypeWithLotsOfDependencies) dependency_resolver.create(); Assert.IsInstanceOf<TypeWithLotsOfDependencies>(result); Assert.AreEqual(result.connection, connection); Assert.AreEqual(result.reader, reader); }