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

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

            return ctx;
        }
        private static MockBuilderContext BuildContext(PolicyList innerPolicies)
        {
            MockBuilderContext ctx = new MockBuilderContext(new BuildPlanStrategy());

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

            return ctx;
        }
        private static MockBuilderContext BuildContext()
        {
            IBuilderStrategy[] strategies = {
                                                new SimplifiedSingletonStrategy(),
                                                new MockCreationStrategy()
                                            };
            MockBuilderContext ctx = new MockBuilderContext(strategies);
            LifetimeContainer lifetimeContainer = new LifetimeContainer();

            if (!ctx.Locator.Contains(typeof (ILifetimeContainer)))
                ctx.Locator.Add(typeof (ILifetimeContainer), lifetimeContainer);

            ctx.Policies.SetDefault<ICreationPolicy>(new DefaultCreationPolicy());

            return ctx;
        }
        public void TestValuesAreCreated()
        {
            SessionStateBindingStrategy strategy = new SessionStateBindingStrategy();
            MockBuilderContext builderContext = new MockBuilderContext(strategy);
            MockSessionStateLocatorService sessionLocator = new MockSessionStateLocatorService();
            builderContext.Locator.Add(new DependencyResolutionLocatorKey(typeof (ISessionStateLocatorService), null),
                                       sessionLocator);

            SampleClass sample = new SampleClass();
            sample.String0 = "test";
            strategy.BuildUp(builderContext, typeof (SampleClass), sample, null);

            Assert.AreEqual("test", sample.String0);
            Assert.IsNotNull(sample.String1);
            Assert.IsNotNull(sample.String2);
        }
        public void StrategyShouldDoTypeMapping()
        {
            TestableRootCompositionContainer root = new TestableRootCompositionContainer();
            root.RegisterTypeMapping<IFoo, Foo>();

            ContainerAwareTypeMappingStrategy strategy = new ContainerAwareTypeMappingStrategy();
            MockBuilderContext builderContext =
                new MockBuilderContext(strategy, new ReturnRequestedTypeStrategy());
            builderContext.Policies.SetDefault<IContainerAwareTypeMappingPolicy>(
                new ContainerAwareTypeMappingPolicy());
            builderContext.Locator = root.Locator;

            object result = strategy.BuildUp(builderContext, typeof (IFoo), null, "Test object");
            DependencyResolutionLocatorKey key = result as DependencyResolutionLocatorKey;
            Assert.IsNotNull(key);
            Assert.AreEqual(typeof (Foo), key.Type);
        }
        private static MockBuilderContext BuildContext()
        {
            MockBuilderContext ctx = new MockBuilderContext(new BuildPlanStrategy());

            return ctx;
        }
        private MockBuilderContext CreateContext(MockConstructorReflectionStrategy mockReflectionStrategy)
        {
            IBuilderStrategy[] strategies = {
                                                new SingletonStrategy(),
                                                mockReflectionStrategy,
                                                new CreationStrategy()
                                            };
            MockBuilderContext context = new MockBuilderContext(strategies);

            context.Policies.SetDefault<ICreationPolicy>(new DefaultCreationPolicy());
            context.Policies.SetDefault<ISingletonPolicy>(new SingletonPolicy(true));
            return context;
        }
        private MockBuilderContext CreateContext(Locator locator)
        {
            IBuilderStrategy[] strategies = {
                                                new SingletonStrategy(),
                                                new ConstructorReflectionStrategy(),
                                                new CreationStrategy()
                                            };
            MockBuilderContext result = new MockBuilderContext(strategies);
            result.Locator = locator;

            LifetimeContainer lifetimeContainer = new LifetimeContainer();

            if (!result.Locator.Contains(typeof (ILifetimeContainer)))
                result.Locator.Add(typeof (ILifetimeContainer), lifetimeContainer);

            result.Policies.SetDefault<ICreationPolicy>(new DefaultCreationPolicy());
            result.Policies.SetDefault<ISingletonPolicy>(new SingletonPolicy(true));
            return result;
        }
        public void ValuesArePulledFromSession()
        {
            SessionStateBindingStrategy strategy = new SessionStateBindingStrategy();
            MockBuilderContext builderContext = new MockBuilderContext(strategy);
            MockSessionStateLocatorService sessionLocator = new MockSessionStateLocatorService();
            sessionLocator.SessionState["key"] = "value";
            builderContext.Locator.Add(new DependencyResolutionLocatorKey(typeof (ISessionStateLocatorService), null),
                                       sessionLocator);

            SampleClass sample = new SampleClass();
            strategy.BuildUp(builderContext, typeof (SampleClass), sample, null);

            Assert.AreEqual("value", sample.String2.Value);
        }