Exemple #1
0
        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;
        }
Exemple #2
0
        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 try_a_simple_constructor_with_all_constants()
        {
            var step = ConcreteBuild <CtorTarget> .For(() => new CtorTarget("", 0));

            step.Constructor.Add(Constant.For("Jeremy"));
            step.Constructor.Add(Constant.For <int>(39));

            var context = new FakeBuildSession();

            var target = step.Build <CtorTarget>(context);

            target.Name.ShouldEqual("Jeremy");
            target.Age.ShouldEqual(39);
        }
        public void SetUp()
        {
            theTarget   = new BuildTarget();
            theInstance = new ObjectInstance(theTarget);

            theInterceptors = new IInterceptor[0];

            theInner = Constant.For(theTarget);

            _plan =
                new Lazy <BuildPlan>(() => new BuildPlan(typeof(IBuildTarget), theInstance, theInner, new Policies(), theInterceptors));

            theSession = new FakeBuildSession();
        }
        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);
        }
Exemple #6
0
        public BuildPlanTester()
        {
            theTarget   = new BuildTarget();
            theInstance = new ObjectInstance(theTarget);

            theInterceptors = new IInterceptor[0];

            theInner = Constant.For(theTarget);

            plan =
                new Lazy <BuildPlan>(
                    () => new BuildPlan(typeof(IBuildTarget), theInstance, theInner, Policies.Default(), theInterceptors));

            theSession = new FakeBuildSession();
        }
        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 SetUp()
        {
            var build = new ConcreteBuild <Game>();

            build.Constructor.Add(new ConcreteBuild <SportsTeam>()
                                  .ConstructorArgs("San Diego", "Chargers"));

            build.Constructor.Add(new ConcreteBuild <SportsTeam>()
                                  .ConstructorArgs("Kansas City", "Chiefs"));

            build.Set(x => x.Stadium, "Qualcomm Stadium");

            build.Set(x => x.Referee, new ConcreteBuild <Referee>().ConstructorArgs("John", "Smith"));

            var session = new FakeBuildSession();

            game = build.Build(session, session).As <Game>();
        }
Exemple #9
0
        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 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);
        }