예제 #1
0
        public void link_files_the_clear_cache()
        {
            theCache.LinkFilesToResource(resource1, new AssetFile[] { file1, file2 });
            theCache.LinkFilesToResource(resource2, new AssetFile[] { file1, file2, file3 });
            theCache.LinkFilesToResource(resource3, new AssetFile[] { file2, file3, file4 });

            var output1A = storeAgainstResource(resource1);
            var output2A = storeAgainstResource(resource2);
            var output3A = storeAgainstResource(resource3);

            Func <IRecordedOutput> shouldNotBeCalled = () =>
            {
                Assert.Fail("Do not call me");
                return(null);
            };

            // 2nd pass
            theCache.Retrieve(resource1, shouldNotBeCalled).ShouldBeTheSameAs(output1A);
            theCache.Retrieve(resource2, shouldNotBeCalled).ShouldBeTheSameAs(output2A);
            theCache.Retrieve(resource3, shouldNotBeCalled).ShouldBeTheSameAs(output3A);

            theCache.Changed(file1);

            var output1B = getOutputWithEtag("2345");
            var output2B = getOutputWithEtag("23456");
            var output3B = getOutputWithEtag("23457");

            theCache.Retrieve(resource1, () => output1B).ShouldBeTheSameAs(output1B);
            theCache.Retrieve(resource1, shouldNotBeCalled).ShouldBeTheSameAs(output1B);
            theCache.Retrieve(resource1, shouldNotBeCalled).ShouldBeTheSameAs(output1B);

            theCache.Retrieve(resource2, () => output2B).ShouldBeTheSameAs(output2B);
            theCache.Current(resource2).ShouldEqual("23456");

            // Was not cleared because it does not depend on file1
            theCache.Retrieve(resource3, shouldNotBeCalled).ShouldBeTheSameAs(output3A);
        }
예제 #2
0
        public void flush_all_removes_the_content_and_ejects_all_of_the_header_cache()
        {
            var hash1 = "12345";
            var hash2 = "23456";
            var hash3 = "34567";

            theCache.LinkFilesToResource(hash1, new AssetFile[] { file1, file2, file3 });
            theCache.LinkFilesToResource(hash2, new AssetFile[] { file2, file3, file4 });
            theCache.LinkFilesToResource(hash3, new AssetFile[] { file5 });

            theCache.FlushAll();

            headersCache.AssertWasCalled(x => x.Eject(hash1));
            headersCache.AssertWasCalled(x => x.Eject(hash2));
            headersCache.AssertWasCalled(x => x.Eject(hash3));

            theOutputCache.AssertWasCalled(x => x.Eject(hash1));
            theOutputCache.AssertWasCalled(x => x.Eject(hash2));
            theOutputCache.AssertWasCalled(x => x.Eject(hash3));
        }