예제 #1
0
        public void TestSetCacheTwice()
        {
            var cache = new WebCache();

            cache.AddEntry("key1", "html1");
            cache.AddEntry("key1", "html2");
            Assert.That(cache.GetEntry("key1"), Is.EqualTo("html2"));
        }
예제 #2
0
        public void TestCacheEntryMissing()
        {
            var cache = new WebCache();

            cache.AddEntry("key1", "html1");
            Assert.That(cache.GetEntry("key2"), Is.Null);
        }
예제 #3
0
        public void TestCacheTimeout()
        {
            var timeoutMillis = 1000;
            var cache         = new WebCache(timeoutMillis);

            cache.AddEntry("key1", "html1");
            Assert.That(cache.GetEntry("key1"), Is.EqualTo("html1"));
            Thread.Sleep(timeoutMillis + 100);
            Assert.That(cache.GetEntry("key1"), Is.Null);
        }
예제 #4
0
        public void TestCacheWorksWithTestHtmlDoc()
        {
            TextReader tr   = new StreamReader(@"TestFiles/TestSearchResult.txt");
            string     html = tr.ReadToEnd();

            var    cache = new WebCache();
            string url   = "http://google.com/search?q=e-settlements";

            cache.AddEntry(url, html);
            Assert.That(cache.GetEntry(url), Is.EqualTo(html));
        }
예제 #5
0
        public void TestCacheWorksWithUrlAndHtml()
        {
            var    cache = new WebCache();
            string url   = "http://google.com/search?q=e-settlements";
            string html  = @"<!DOCTYPE html>
<html>
<body>

<h1>My First | Heading</h1>
<p>My first paragraph.</p>

</body>
</html>";

            cache.AddEntry(url, html);
            Assert.That(cache.GetEntry(url), Is.EqualTo(html));
        }
예제 #6
0
        public void TestCacheWorksWithNewLineAndCarriageReturn()
        {
            var    cache = new WebCache();
            string url   = "http://google.com/search?q=e-settlements";
            string html  = String.Format(@"<!DOCTYPE html>
<html>
<body>

<h1>My First | Heading</h1>
<p>My first paragraph.</p>
{0}
{1}
{2}
</body>
</html>", System.Environment.NewLine, "\r", "\n");

            cache.AddEntry(url, html);
            Assert.That(cache.GetEntry(url), Is.EqualTo(html));
        }