public void TestCache()
        {
            var cache = new InstanceCache();
            cache.Clear();

            var summary = new HtmlSummary(HttpStatusCode.OK,
                "http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4", RawHtml, "text/html");
            cache.Set("first", summary);
            cache.Set("second", summary);

            var first = cache.Get<HtmlSummary>("first");
            var second = cache.Get<HtmlSummary>("second");

            first.Should().NotBeNull();
            second.Should().NotBeNull();
            first.CreatedAt.Should().Be(second.CreatedAt);

            cache.Unset("first");
            var none = cache.Get<HtmlSummary>("first");
            none.Should().BeNull();
        }
Example #2
0
        public void ClearCacheTest()
        {
            // set up cache with an initial value
            var cache       = new InstanceCache <string>();
            var cachedValue = "Initial value";

            // get value from cache and check it matches initial
            var value = cache.Get(CacheDuration, () => cachedValue);

            Assert.AreEqual("Initial value", value);

            // clear the cache
            cache.Clear();

            // change the cached value
            cachedValue = "Changed value";

            // check that it returns the changed value
            value = cache.Get(CacheDuration, () => cachedValue);
            Assert.AreEqual("Changed value", value);
        }
 public void ClearInstances()
 {
     PageCache.Clear();
     InstanceCache.Clear();
 }
Example #4
0
 public void ClearInstances()
 {
     InstanceCache.Clear();
     PageCache.Clear();
     _linkCache.Clear();
 }