public AllPossibleEnumerableDependency_resolution_Tester() { gateway1 = new StubbedGateway(); gateway2 = new StubbedGateway(); gateway3 = new StubbedGateway(); theSession = new FakeBuildSession(); theSession.LifecycledObjects[typeof(IGateway)][new FakeInstance()] = gateway1; theSession.LifecycledObjects[typeof(IGateway)][new FakeInstance()] = gateway2; theSession.LifecycledObjects[typeof(IGateway)][new FakeInstance()] = gateway3; }
public void SetUp() { gateway1 = new StubbedGateway(); gateway2 = new StubbedGateway(); gateway3 = new StubbedGateway(); theSession = new FakeBuildSession(); theSession.LifecycledObjects[typeof (IGateway)][new FakeInstance()] = gateway1; theSession.LifecycledObjects[typeof (IGateway)][new FakeInstance()] = gateway2; theSession.LifecycledObjects[typeof (IGateway)][new FakeInstance()] = gateway3; }
public void return_type_of_ArrayDependencySource() { var gateway1 = new StubbedGateway(); var gateway2 = new StubbedGateway(); var gateway3 = new StubbedGateway(); var array = new ArrayDependencySource(typeof(IGateway), Constant.For(gateway1), Constant.For(gateway2), Constant.For(gateway3)); array.ReturnedType.ShouldEqual(typeof (IGateway[])); }
public void can_resolve_through_build_session() { var session = new FakeBuildSession(); var gateway = new StubbedGateway(); session.SetDefault<IGateway>(gateway); var build = new ConcreteBuild<GuyWhoUsesGateway>(); build.ConstructorArgs(new DefaultDependencySource(typeof(IGateway))); build.Build<GuyWhoUsesGateway>(session) .Gateway.ShouldBeTheSameAs(gateway); }
public void can_resolve_through_build_session() { var session = new FakeBuildSession(); var gateway = new StubbedGateway(); var gateway2 = new StubbedGateway(); session.NamedObjects[typeof(IGateway)]["Red"] = gateway; session.NamedObjects[typeof(IGateway)]["Blue"] = gateway2; var build = new ConcreteBuild<GuyWhoUsesGateway>(); build.ConstructorArgs(new ReferencedDependencySource(typeof(IGateway), "Blue")); build.Build<GuyWhoUsesGateway>(session) .Gateway.ShouldBeTheSameAs(gateway2); }
public void can_use_lifecyle_resolver_for_dependency() { var build = new ConcreteBuild<LifecycleTarget>(); var gateway = new StubbedGateway(); var instance = new ObjectInstance(gateway); var session = new FakeBuildSession(); session.LifecycledObjects[typeof (IGateway)][instance] = gateway; var arg = new LifecycleDependencySource(typeof (IGateway), instance); build.ConstructorArgs(arg); var target = build.Build<LifecycleTarget>(session); target.Gateway.ShouldBeTheSameAs(gateway); }
public void if_value_exists_and_it_is_the_right_type_return_constant() { ConcreteType.SourceFor(ConcreteType.ConstructorArgument, "SomeProp", typeof (string), "foo") .ShouldBe(Constant.For("foo")); ConcreteType.SourceFor(ConcreteType.ConstructorArgument, "SomeProp", typeof (int), 42) .ShouldBe(Constant.For(42)); // My dad raises registered Beefmasters and he'd be disappointed // if the default here was anything else ConcreteType.SourceFor(ConcreteType.ConstructorArgument, "SomeProp", typeof (BreedEnum), BreedEnum.Beefmaster) .ShouldBe(Constant.For(BreedEnum.Beefmaster)); var gateway = new StubbedGateway(); ConcreteType.SourceFor(ConcreteType.ConstructorArgument, "SomeProp", typeof (IGateway), gateway) .ShouldBe(Constant.For<IGateway>(gateway)); }
public void can_build_with_list_dependency() { var gateway1 = new StubbedGateway(); var gateway2 = new StubbedGateway(); var gateway3 = new StubbedGateway(); var build = new ConcreteBuild<GatewayListUser>(); var array = new ListDependencySource(typeof (IGateway), Constant.For(gateway1), Constant.For(gateway2), Constant.For(gateway3)); build.ConstructorArgs(array); var arrayUser = build.Build<GatewayListUser>(new FakeBuildSession()); arrayUser.Gateways.ShouldHaveTheSameElementsAs(gateway1, gateway2, gateway3); }
public void can_build_setters_on_an_existing_object() { var target = new SetterTarget(); var gateway = new StubbedGateway(); var session = new FakeBuildSession(); session.SetDefault<IGateway>(gateway); var plan = new BuildUpPlan<SetterTarget>(); plan.Set(x => x.Color, "Red"); plan.Set(x => x.Direction, "Green"); plan.Set(x => x.Gateway, new DefaultDependencySource(typeof (IGateway))); plan.BuildUp(session, session, target); target.Color.ShouldBe("Red"); target.Direction.ShouldBe("Green"); target.Gateway.ShouldBeTheSameAs(gateway); }
public void SetUp() { good = Expression.Constant("I am good"); genericEx = new NotImplementedException(); throwGeneral = Expression.Block(Expression.Throw(Expression.Constant(genericEx)), Expression.Constant("bar")); smEx = new StructureMapException("you stink!"); throwSM = Expression.Block(Expression.Throw(Expression.Constant(smEx)), Expression.Constant("bar")); var gateway = new StubbedGateway(); Expression<Action> goodExpr = () => gateway.DoSomething(); goodVoid = Expression.Block(goodExpr.Body); badVoid = Expression.Block(Expression.Throw(Expression.Constant(genericEx))); badSmVoid = Expression.Block(Expression.Throw(Expression.Constant(smEx))); }
public void to_dependency_source() { var gateway = new StubbedGateway(); new ObjectInstance(gateway).ToDependencySource(typeof (IGateway)) .ShouldEqual(Constant.For<IGateway>(gateway)); }