Пример #1
0
        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.");
        }
Пример #2
0
        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.");
        }
Пример #3
0
        public void Open_CurrentExistsFalse_ReturnsNextOpenResult()
        {
            var currentNode = new DummyResourceResolverNode();
            var nextNode = new DummyResourceResolverNode();

            currentNode.GetCurrentCacheDependencyMock = (pathDefinition, virtualPath, virtualPathDependencies, utcDate) => null;
            var currentStream = new MemoryStream();
            currentNode.CurrentOpenMock = (pathDefinition, virtualPath) => currentStream;
            currentNode.CurrentExistsMock = (pathDefinition, virtualPath) => false;

            var nextCacheDependency = new CacheDependency(Directory.GetCurrentDirectory());
            var nextStream = new MemoryStream();
            nextNode.CurrentOpenMock = (pathDefinition, virtualPath) => nextStream;
            nextNode.CurrentExistsMock = (pathDefinition, virtualPath) => true;

            currentNode.SetNext(nextNode);

            var result = currentNode.Open(new PathDefinition(), "~/Test");
            Assert.AreSame(nextStream, result, "The returned stream is not that of the second node.");
        }