References a scope object. The reference its self has the owner of the scope as scope.
Inheritance: DisposeNotifyingObject
コード例 #1
0
        public void DisposeDisposesTheReferencedScope()
        {
            var scopeMock = new Mock <IDisposable>();
            var testee    = new NamedScopeReference(scopeMock.Object);

            testee.Dispose();

            scopeMock.Verify(scope => scope.Dispose());
        }
コード例 #2
0
        public void DisposeDisposesTheReferencedScope()
        {
            var scopeMock = new Mock<IDisposable>();
            var testee = new NamedScopeReference(scopeMock.Object);

            testee.Dispose();

            scopeMock.Verify(scope => scope.Dispose());
        }
コード例 #3
0
        public void GarbageCollectDoesNotDisposeTheReferencedScope()
        {
            var scopeMock = new Mock<IDisposable>();

            var testee = new NamedScopeReference(scopeMock.Object);
            testee.IsDisposed.Should().BeFalse();

            GC.Collect();

            scopeMock.Verify(scope => scope.Dispose(), Times.Never());
        }
コード例 #4
0
        public void GarbageCollectDoesNotDisposeTheReferencedScope()
        {
            var scopeMock = new Mock <IDisposable>();

            var testee = new NamedScopeReference(scopeMock.Object);

            testee.IsDisposed.Should().BeFalse();

            GC.Collect();

            scopeMock.Verify(scope => scope.Dispose(), Times.Never());
        }
コード例 #5
0
        /// <summary>
        /// Setups kernel.Get{NamedScopeReference};
        /// </summary>
        /// <param name="kernelMock">The kernel mock.</param>
        /// <param name="requestParameters">The request parameters.</param>
        private static void SetupKernelGetNamedScopeReference(Mock <IKernel> kernelMock, List <IParameter> requestParameters)
        {
            var request             = new Mock <IRequest>();
            var namedScopeReference = new NamedScopeReference(new DisposeNotifyingObject());

            kernelMock
            .Setup(kernel => kernel.CreateRequest(
                       typeof(NamedScopeReference),
                       null,
                       It.Is <IEnumerable <IParameter> >(p => MatchAlwaysButAddReceivedParametersToTheSpecifiedList(requestParameters, p)),
                       false,
                       true))
            .Returns(request.Object);
            kernelMock
            .Setup(kernel => kernel.Resolve(request.Object))
            .Returns(new List <object> {
                namedScopeReference
            });
        }
 /// <summary>
 /// Setups kernel.Get{NamedScopeReference};
 /// </summary>
 /// <param name="kernelMock">The kernel mock.</param>
 /// <param name="requestParameters">The request parameters.</param>
 private static void SetupKernelGetNamedScopeReference(Mock<IKernel> kernelMock, List<IParameter> requestParameters)
 {
     var request = new Mock<IRequest>();
     var namedScopeReference = new NamedScopeReference(new DisposeNotifyingObject());
     kernelMock
         .Setup(kernel => kernel.CreateRequest(
             typeof(NamedScopeReference), 
             null, 
             It.Is<IEnumerable<IParameter>>(p => MatchAlwaysButAddReceivedParametersToTheSpecifiedList(requestParameters, p)), 
             false, 
             true))
         .Returns(request.Object);
     kernelMock
         .Setup(kernel => kernel.Resolve(request.Object))
         .Returns(new List<object> { namedScopeReference });
 }