public void TestNoWriteThrough() { LRUReplacementPolicy <int, int> lruReplacement = new LRUReplacementPolicy <int, int>(); MyMemory <int, int> memoryAccess = new MyMemory <int, int>(); NWaySetAssociativeCache <int, int> cache; cache = new NWaySetAssociativeCache <int, int>(memoryAccess, lruReplacement, 8, 2, false); Tuple <int, int>[] tuples = new Tuple <int, int> [100]; for (int i = 0; i < 100; i++) { tuples[i] = Tuple.Create(i + 1, i + 1); memoryAccess.Put(i + 1, i + 1); } int[] oldValues = cache.PutAll(tuples); for (int i = 0; i < 100; i++) { if (oldValues[i] != 0) { if (memoryAccess.Contains(i + 1)) { memoryAccess.Remove(i + 1); } memoryAccess.Put(i + 1, oldValues[i]); } } cache.Get(100); }
public void TestNoWriteBackException() { LRUReplacementPolicy <int, int> lruReplacement = new LRUReplacementPolicy <int, int>(); MyMemory <int, int> memoryAccess = new MyMemory <int, int>(); NWaySetAssociativeCache <int, int> cache; cache = new NWaySetAssociativeCache <int, int>(memoryAccess, lruReplacement, 8, 2, false); Tuple <int, int>[] tuples = new Tuple <int, int> [100]; for (int i = 0; i < 100; i++) { tuples[i] = Tuple.Create(i + 1, i + 1); memoryAccess.Put(i + 1, i + 1); } int[] oldValues = cache.PutAll(tuples); for (int i = 0; i < 100; i++) { if (oldValues[i] != 0) { if (memoryAccess.Contains(i + 1)) { memoryAccess.Remove(i + 1); } memoryAccess.Put(i + 1, oldValues[i]); } } try { cache.Get(1); Assert.Fail(); } catch (EntryNotFoundException e) { Console.WriteLine(e); } }