Activation strategy that creates a reference from the owner to the named scopes.
Inheritance: ActivationStrategy
        public void ActivationCreatesNamedScopeReferenceUsingTheKernel()
        {
            var requestParameters = new List<IParameter>();
            var reference = new InstanceReference { Instance = new object() };
            var namedScopeParameter = new NamedScopeParameter("Scope1");
            var kernelMock = new Mock<IKernel>();
            var contextMock = CreateContextMock();

            contextMock.Object.Parameters.Add(namedScopeParameter);
            contextMock.SetupGet(context => context.Kernel).Returns(kernelMock.Object);
            SetupKernelGetNamedScopeReference(kernelMock, requestParameters);

            var testee = new NamedScopeActivationStrategy();
            testee.Activate(contextMock.Object, reference);

            requestParameters.Count().Should().Be(2);
            AssertConstructorArgumentExists("scope", namedScopeParameter.Scope, requestParameters);
            AssertNamedScopeReferenceScopeParameterExists(reference.Instance, requestParameters);
        }
Ejemplo n.º 2
0
        public void ActivationCreatesNamedScopeReferenceUsingTheKernel()
        {
            var requestParameters = new List <IParameter>();
            var reference         = new InstanceReference {
                Instance = new object()
            };
            var namedScopeParameter = new NamedScopeParameter("Scope1");
            var kernelMock          = new Mock <IKernel>();
            var contextMock         = CreateContextMock();

            contextMock.Object.Parameters.Add(namedScopeParameter);
            contextMock.SetupGet(context => context.Kernel).Returns(kernelMock.Object);
            SetupKernelGetNamedScopeReference(kernelMock, requestParameters);

            var testee = new NamedScopeActivationStrategy();

            testee.Activate(contextMock.Object, reference);

            requestParameters.Count().Should().Be(2);
            AssertConstructorArgumentExists("scope", namedScopeParameter.Scope, requestParameters);
            AssertNamedScopeReferenceScopeParameterExists(reference.Instance, requestParameters);
        }