private IBuilderContext GetContext()
 {
     BuilderContext context = new BuilderContext(
         strategies,
         new Locator(),
         policies);
     return context;
 }
        public void CreationPolicyWillRecordSingletonsUsingLocalLifetimeContainerOnly()
        {
            BuilderStrategyChain chain = new BuilderStrategyChain();
            chain.Add(new CreationStrategy());

            Locator parentLocator = new Locator();
            LifetimeContainer container = new LifetimeContainer();
            parentLocator.Add(typeof (ILifetimeContainer), container);

            Locator childLocator = new Locator(parentLocator);

            PolicyList policies = new PolicyList();
            policies.SetDefault<ICreationPolicy>(new DefaultCreationPolicy());
            policies.SetDefault<ISingletonPolicy>(new SingletonPolicy(true));

            BuilderContext ctx = new BuilderContext(chain, childLocator, policies);

            object obj = ctx.HeadOfChain.BuildUp(ctx, typeof (object), null, null);

            Assert.IsNotNull(obj);
            Assert.IsNull(childLocator.Get(new DependencyResolutionLocatorKey(typeof (object), null)));
        }
예제 #3
0
        public void PassingNullPoliciesObjectDoesntThrowWhenAskingForPolicy()
        {
            BuilderContext context = new BuilderContext(null, null, null);

            Assert.IsNull(context.Policies.Get <IBuilderPolicy>(typeof(object), null));
        }