Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void TestSetGetCache()
        {
            var cache = new WebCache();

            cache.AddEntry("key1", "html1");
            cache.AddEntry("key4", "html2");
            cache.AddEntry("key5", "html6");
            Assert.That(cache.GetEntry("key1"), Is.EqualTo("html1"));
            Assert.That(cache.GetEntry("key4"), Is.EqualTo("html2"));
            Assert.That(cache.GetEntry("key5"), Is.EqualTo("html6"));
        }
Exemplo n.º 3
0
        public void TestCacheEntryMissing()
        {
            var cache = new WebCache();

            cache.AddEntry("key1", "html1");
            Assert.That(cache.GetEntry("key2"), Is.Null);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }