public void PostTearDownWithNullContextThrows()
 {
     // Fixture setup
     var sut = new CacheReleasingLifetimeStrategy();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.PostTearDown(null));
     // Teardown
 }
예제 #2
0
        public void PostTearDownWithNullContextThrows()
        {
            // Fixture setup
            var sut = new CacheReleasingLifetimeStrategy();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.PostTearDown(null));
            // Teardown
        }
        public void PostTearDownRemovesFromAllLifetimePolicies()
        {
            // Fixture setup
            var lifetimeMocks = Enumerable.Range(1, 3).Select(i => new Mock<CacheLifetimeManager>(new Mock<ILease>().Object)).ToList();

            var lifetimeContainer = new LifetimeContainer();
            lifetimeMocks.ForEach(m => lifetimeContainer.Add(m.Object));

            var contextStub = new Mock<IBuilderContext>();
            contextStub.SetupGet(ctx => ctx.Lifetime).Returns(lifetimeContainer);

            var sut = new CacheReleasingLifetimeStrategy();
            // Exercise system
            sut.PostTearDown(contextStub.Object);
            // Verify outcome
            lifetimeMocks.ForEach(m => m.Verify(lp => lp.RemoveValue()));
            // Teardown
        }
예제 #4
0
        public void PostTearDownRemovesFromAllLifetimePolicies()
        {
            // Fixture setup
            var lifetimeMocks = Enumerable.Range(1, 3).Select(i => new Mock <CacheLifetimeManager>(new Mock <ILease>().Object)).ToList();

            var lifetimeContainer = new LifetimeContainer();

            lifetimeMocks.ForEach(m => lifetimeContainer.Add(m.Object));

            var contextStub = new Mock <IBuilderContext>();

            contextStub.SetupGet(ctx => ctx.Lifetime).Returns(lifetimeContainer);

            var sut = new CacheReleasingLifetimeStrategy();

            // Exercise system
            sut.PostTearDown(contextStub.Object);
            // Verify outcome
            lifetimeMocks.ForEach(m => m.Verify(lp => lp.RemoveValue()));
            // Teardown
        }