Activate() public method

Activates the specified context.
public Activate ( IContext context, InstanceReference reference ) : void
context IContext The context.
reference InstanceReference The reference.
return void
        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);
        }
Esempio 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);
        }