Exemplo n.º 1
0
        public void create_variable_should_be_through_constructor(Type concreteType, ServiceLifetime lifetime, BuildMode build, DisposeTracking disposal)
        {
            var instance = new ConstructorInstance(concreteType, concreteType, lifetime);

            instance.CreatePlan(ServiceGraph.Empty());

            instance.CreateVariable(build, new ResolverVariables(), false).Creator
            .ShouldBeOfType <InstanceConstructorFrame>()
            .Disposal.ShouldBe(disposal);
        }
Exemplo n.º 2
0
        public void default_policies_in_empty_graph()
        {
            var graph = ServiceGraph.Empty();


            graph.FamilyPolicies[0].ShouldBeOfType <EnumerablePolicy>();
            graph.FamilyPolicies[1].ShouldBeOfType <FuncOrLazyPolicy>();

            graph.FamilyPolicies[2].ShouldBeOfType <CloseGenericFamilyPolicy>();
            graph.FamilyPolicies[3].ShouldBeOfType <ConcreteFamilyPolicy>();
            graph.FamilyPolicies[4].ShouldBeOfType <EmptyFamilyPolicy>();
        }
Exemplo n.º 3
0
        public void should_be_an_injected_field(ServiceLifetime lifetime, BuildMode mode, bool isInjected)
        {
            var instance = ConstructorInstance.For <AWidget>(lifetime);

            instance.CreatePlan(ServiceGraph.Empty());

            var variable = instance.CreateVariable(mode, null, false);

            if (isInjected)
            {
                var argType = variable.ShouldBeOfType <InjectedServiceField>()
                              .ArgType;

                argType.ShouldBe(typeof(AWidget));
            }
            else
            {
                variable.ShouldNotBeOfType <InjectedServiceField>();
            }
        }