public void GetCacheDependency_NoCurrentDependencyCurrentExistsFalse_ReturnsNextCacheDependency()
        {
            var currentNode = new DummyResourceResolverNode();
            var nextNode = new DummyResourceResolverNode();

            currentNode.GetCurrentCacheDependencyMock = (pathDefinition, virtualPath, virtualPathDependencies, utcDate) => null;
            currentNode.CurrentExistsMock = (pathDefinition, virtualPath) => false;

            var nextCacheDependency = new CacheDependency(Directory.GetCurrentDirectory());
            nextNode.GetCurrentCacheDependencyMock = (pathDefinition, virtualPath, virtualPathDependencies, utcDate) => nextCacheDependency;
            nextNode.CurrentExistsMock = (pathDefinition, virtualPath) => true;

            currentNode.SetNext(nextNode);

            var result = currentNode.GetCacheDependency(new PathDefinition(), "~/Test", null, DateTime.UtcNow);
            Assert.IsNotInstanceOfType(result, typeof(AggregateCacheDependency));

            Assert.AreSame(nextCacheDependency, result, "The returned cache dependency is not that of the second node.");
        }
        public void GetCacheDependency_HasCurrentDependencyCurrentExistsFalse_AggregatesCurrentCacheDependencyWithNext()
        {
            var currentNode = new DummyResourceResolverNode();
            var nextNode = new DummyResourceResolverNode();

            var currentCacheDependency = new CacheDependency(Directory.GetCurrentDirectory());
            currentNode.GetCurrentCacheDependencyMock = (pathDefinition, virtualPath, virtualPathDependencies, utcDate) => currentCacheDependency;
            currentNode.CurrentExistsMock = (pathDefinition, virtualPath) => false;

            var nextCacheDependency = new CacheDependency(Directory.GetCurrentDirectory());
            nextNode.GetCurrentCacheDependencyMock = (pathDefinition, virtualPath, virtualPathDependencies, utcDate) => nextCacheDependency;
            nextNode.CurrentExistsMock = (pathDefinition, virtualPath) => true;

            currentNode.SetNext(nextNode);

            var result = currentNode.GetCacheDependency(new PathDefinition(), "~/Test", null, DateTime.UtcNow);
            Assert.IsInstanceOfType(result, typeof(AggregateCacheDependency), "Resulting cache dependency is not aggregated.");

            var dependencies = this.GetAggregatedDependencies((AggregateCacheDependency)result);

            Assert.AreEqual(2, dependencies.Count);
            Assert.IsTrue(dependencies.Contains(currentCacheDependency), "The resulting aggregated cache dependency does not contain the dependency of the first node.");
            Assert.IsTrue(dependencies.Contains(nextCacheDependency), "The resulting aggregated cache dependency does not contain the dependency of the second node.");
        }