Example #1
0
        public void RemoveValueDisposesValue()
        {
            // Fixture setup
            var leaseStub = new Mock <ILease>();

            leaseStub.SetupGet(l => l.IsExpired).Returns(true);

            var sut = new CacheLifetimeManager(leaseStub.Object);

            var valueMock = new Mock <IDisposable>();

            sut.SetValue(valueMock.Object);
            // Exercise system
            sut.RemoveValue();
            // Verify outcome
            valueMock.Verify(d => d.Dispose());
            // Teardown
        }
Example #2
0
        public void RemoveValueRemovesValueWhenLeaseIsExpired()
        {
            // Fixture setup
            var leaseStub = new Mock <ILease>();

            leaseStub.SetupGet(l => l.IsExpired).Returns(true);

            var sut = new CacheLifetimeManager(leaseStub.Object);

            sut.SetValue(new object());
            // Exercise system
            sut.RemoveValue();
            // Verify outcome
            var result = sut.GetValue();

            Assert.Null(result);
            // Teardown
        }
Example #3
0
        public void RemoveValueDoesNotRemoveValueWhenLeaseIsNotExpired()
        {
            // Fixture setup
            var leaseStub = new Mock <ILease>();

            leaseStub.SetupGet(l => l.IsExpired).Returns(false);

            var expected = new object();

            var sut = new CacheLifetimeManager(leaseStub.Object);

            sut.SetValue(expected);
            // Exercise system
            sut.RemoveValue();
            // Verify outcome
            var result = sut.GetValue();

            Assert.Equal(expected, result);
            // Teardown
        }
        public void RemoveValueRemovesValueWhenLeaseIsExpired()
        {
            // Fixture setup
            var leaseStub = new Mock<ILease>();
            leaseStub.SetupGet(l => l.IsExpired).Returns(true);

            var sut = new CacheLifetimeManager(leaseStub.Object);
            sut.SetValue(new object());
            // Exercise system
            sut.RemoveValue();
            // Verify outcome
            var result = sut.GetValue();
            Assert.Null(result);
            // Teardown
        }
        public void RemoveValueDisposesValue()
        {
            // Fixture setup
            var leaseStub = new Mock<ILease>();
            leaseStub.SetupGet(l => l.IsExpired).Returns(true);

            var sut = new CacheLifetimeManager(leaseStub.Object);

            var valueMock = new Mock<IDisposable>();
            sut.SetValue(valueMock.Object);
            // Exercise system
            sut.RemoveValue();
            // Verify outcome
            valueMock.Verify(d => d.Dispose());
            // Teardown
        }
        public void RemoveValueDoesNotRemoveValueWhenLeaseIsNotExpired()
        {
            // Fixture setup
            var leaseStub = new Mock<ILease>();
            leaseStub.SetupGet(l => l.IsExpired).Returns(false);

            var expected = new object();

            var sut = new CacheLifetimeManager(leaseStub.Object);
            sut.SetValue(expected);
            // Exercise system
            sut.RemoveValue();
            // Verify outcome
            var result = sut.GetValue();
            Assert.Equal(expected, result);
            // Teardown
        }