private static MockBuilderContext BuildContext(MockReturnExistingPlanBuilderStrategy mockPlanBuilderStrategy)
        {
            MockBuilderContext ctx = new MockBuilderContext(new BuildPlanStrategy());

            ctx.Policies.SetDefault<IPlanBuilderPolicy>(CreatePlanBuilder(mockPlanBuilderStrategy));

            return ctx;
        }
        private static IPlanBuilderPolicy CreatePlanBuilder(MockReturnExistingPlanBuilderStrategy mockPlanBuilderStrategy)
        {
            BuilderStrategyChain chain = new BuilderStrategyChain();
            chain.Add(mockPlanBuilderStrategy);

            PolicyList policies = new PolicyList();

            return new DynamicMethodPlanBuilderPolicy(chain, policies);
        }
        public void CreateInstanceBuildUpIsCalled()
        {
            MockReturnExistingPlanBuilderStrategy mockPlanBuilderStrategy = new MockReturnExistingPlanBuilderStrategy();
            MockBuilderContext ctx = BuildContext(mockPlanBuilderStrategy);

            MockObject i1 = (MockObject) ctx.HeadOfChain.BuildUp(ctx, typeof (MockObject), null, null);

            Assert.IsTrue(mockPlanBuilderStrategy.BuildUpCalled);
        }
        public void BuildUpExistingInstanceBuildUpIsCalled()
        {
            MockReturnExistingPlanBuilderStrategy mockPlanBuilderStrategy = new MockReturnExistingPlanBuilderStrategy();
            MockBuilderContext ctx = BuildContext(mockPlanBuilderStrategy);
            MockObject expectedObject = new MockObject();

            MockObject i1 = (MockObject) ctx.HeadOfChain.BuildUp(ctx, typeof (MockObject), expectedObject, null);

            Assert.IsTrue(mockPlanBuilderStrategy.BuildUpCalled);
            Assert.AreSame(expectedObject, i1);
        }