public virtual void TestHotItemsAreEvictedLast() { var puppet = new TestPuppet(); if (puppet.cache.GetType().FullName.IndexOf("LRU2QXCache") > 0) { // LRU2QXCache doesn't meet all the expectations return; } puppet.FillCache(); puppet.FillCache(0, 2); // 0 and 1 are hot now puppet.CacheMiss(11); // 2 should have been evicted to make room for 11 puppet.CacheMiss(2); puppet.CacheHit(11); // 11 is as hot as 0 and 1 now puppet.CacheMiss(12); puppet.CacheHit(0); puppet.CacheHit(1); puppet.CacheHit(2); puppet.CacheMiss(3); puppet.CacheMiss(4); puppet.CacheMiss(5); puppet.CacheMiss(13); puppet.CacheMiss(14); puppet.CacheMisses(new[] { 6, 7, 8, 9 }); puppet.DumpCache(); puppet.CacheHits(new[] { 6, 7, 8, 9, 13, 14 }); puppet.CacheMiss(15); puppet.CacheMiss(11); puppet.CacheMiss(0); puppet.DumpCache(); }
public virtual void TestHotItemsAreEvictedLast() { var puppet = new TestPuppet(); if (puppet.cache.GetType().FullName.IndexOf("LRU2QXCache") > 0) { // LRU2QXCache doesn't meet all the expectations return; } puppet.FillCache(); puppet.FillCache(0, 2); // 0 and 1 are hot now puppet.CacheMiss(11); // 2 should have been evicted to make room for 11 puppet.CacheMiss(2); puppet.CacheHit(11); // 11 is as hot as 0 and 1 now puppet.CacheMiss(12); puppet.CacheHit(0); puppet.CacheHit(1); puppet.CacheHit(2); puppet.CacheMiss(3); puppet.CacheMiss(4); puppet.CacheMiss(5); puppet.CacheMiss(13); puppet.CacheMiss(14); puppet.CacheMisses(new[] {6, 7, 8, 9}); puppet.DumpCache(); puppet.CacheHits(new[] {6, 7, 8, 9, 13, 14}); puppet.CacheMiss(15); puppet.CacheMiss(11); puppet.CacheMiss(0); puppet.DumpCache(); }
public virtual void TestOnDiscard() { var puppet = new TestPuppet(); puppet.FillCache(); var discarded = new ByRef(); puppet.Produce(42, new _IProcedure4_19(discarded)); Assert.AreEqual("0", ((string) discarded.value)); }
public virtual void TestOnDiscard() { var puppet = new TestPuppet(); puppet.FillCache(); var discarded = new ByRef(); puppet.Produce(42, new _IProcedure4_19(discarded)); Assert.AreEqual("0", ((string)discarded.value)); }
public virtual void TestIterable() { var puppet = new TestPuppet(); Iterator4Assert.SameContent(new object[] {}, puppet.Values()); puppet.Produce(0); Iterator4Assert.SameContent(new object[] {"0"}, puppet.Values()); puppet.FillCache(); Iterator4Assert.SameContent(new object[] { "0", "1", "2", "3", "4", "5", "6", "7" , "8", "9" }, puppet.Values()); }
public virtual void TestIterable() { var puppet = new TestPuppet(); Iterator4Assert.SameContent(new object[] {}, puppet.Values()); puppet.Produce(0); Iterator4Assert.SameContent(new object[] { "0" }, puppet.Values()); puppet.FillCache(); Iterator4Assert.SameContent(new object[] { "0", "1", "2", "3", "4", "5", "6", "7" , "8", "9" }, puppet.Values()); }
public virtual void TestProducerIsNotCalledOnCacheHit() { var puppet = new TestPuppet(); puppet.FillCache(); puppet.Verify(ApplyCalls(10)); puppet.FillCache(); puppet.Verify(ApplyCalls(10)); Assert.AreEqual("10", puppet.Produce(10)); puppet.Verify(ApplyCalls(11)); puppet.Reset(); Assert.AreEqual("0", puppet.Produce(0)); puppet.Verify(ApplyCalls(1)); puppet.FillCache(2, 10); puppet.Verify(ApplyCalls(1)); }
public _IFunction4_50(TestPuppet _enclosing) { this._enclosing = _enclosing; }
public void Init() { PuppetTestUtils.Init(); puppet = new TestPuppet(); }