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_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); }