public void PreBuildUpWithCacheLifetimeFromParentAddsCorrectLifetime()
        {
            // Fixture setup
            var dummyLease = new Mock <ILease>().Object;
            var originalLifetimeManager = new CacheLifetimeManager(dummyLease);

            var parentList = new Mock <IPolicyList>().Object;

            var buildKey = new NamedTypeBuildKey <Version>();

            var contextMock = new Mock <IBuilderContext> {
                DefaultValue = DefaultValue.Mock
            };

            contextMock.SetupGet(ctx => ctx.BuildKey).Returns(buildKey);
            contextMock.Setup(ctx => ctx.PersistentPolicies.Get(typeof(ILifetimePolicy), buildKey, false, out parentList)).Returns(originalLifetimeManager);

            var sut = new CacheLifetimeStrategy();

            // Exercise system
            sut.PreBuildUp(contextMock.Object);
            // Verify outcome
            contextMock.Verify(ctx => ctx.Lifetime.Add(It.Is <object>(obj => new CacheLifetimeManagerCloneLikeness(originalLifetimeManager).Equals(obj))));
            // Teardown
        }
 public void PreBuildUpWithNullContextThrows()
 {
     // Fixture setup
     var sut = new CacheLifetimeStrategy();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.PreBuildUp(null));
     // Teardown
 }
        public void PreBuildUpWithNullContextThrows()
        {
            // Fixture setup
            var sut = new CacheLifetimeStrategy();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.PreBuildUp(null));
            // Teardown
        }
        public void PreBuildUpWithCacheLifetimeFromParentAddsCorrectLifetime()
        {
            // Fixture setup
            var dummyLease = new Mock<ILease>().Object;
            var originalLifetimeManager = new CacheLifetimeManager(dummyLease);

            var parentList = new Mock<IPolicyList>().Object;

            var buildKey = new NamedTypeBuildKey<Version>();

            var contextMock = new Mock<IBuilderContext> { DefaultValue = DefaultValue.Mock };
            contextMock.SetupGet(ctx => ctx.BuildKey).Returns(buildKey);
            contextMock.Setup(ctx => ctx.PersistentPolicies.Get(typeof(ILifetimePolicy), buildKey, false, out parentList)).Returns(originalLifetimeManager);

            var sut = new CacheLifetimeStrategy();
            // Exercise system
            sut.PreBuildUp(contextMock.Object);
            // Verify outcome
            contextMock.Verify(ctx => ctx.Lifetime.Add(It.Is<object>(obj => new CacheLifetimeManagerCloneLikeness(originalLifetimeManager).Equals(obj))));
            // Teardown
        }