public void TestSetCacheTwice() { var cache = new WebCache(); cache.AddEntry("key1", "html1"); cache.AddEntry("key1", "html2"); Assert.That(cache.GetEntry("key1"), Is.EqualTo("html2")); }
public void TestCacheEntryMissing() { var cache = new WebCache(); cache.AddEntry("key1", "html1"); Assert.That(cache.GetEntry("key2"), Is.Null); }
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); }
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)); }
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)); }
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)); }