public void simple_creation_of_properties_with_only_constants() { var step = new ConcreteBuild <SetterTarget>(); step.Set(x => x.Color, "Red"); step.Set(x => x.Direction, "North"); var builder = (Func <IContext, SetterTarget>)step.ToDelegate(); SetterTarget target = builder(new FakeContext()); target.Color.ShouldEqual("Red"); target.Direction.ShouldEqual("North"); }
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 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); }