コード例 #1
0
        public void TryRemovePairFromAlgorithmShouldBerRemovedFromCacheTest()
        {
            //Arrange
            int    cacheSize = 10;
            int    nSet      = 5;
            int    key       = 134;
            string value     = "2221";

            var algorithm = new LRUAlgorithm <int, string>();
            var cache     = new Cache <int, string>(cacheSize, nSet, algorithm);

            cache.Put(key, value);

            algorithm.Remove();

            //Actual
            //Assert
            Assert.Throws <InvalidOperationException>(() => cache.Get(key));
            Assert.Throws <InvalidOperationException>(() => algorithm.GetValue(key));
        }
コード例 #2
0
        public void RemoveEntryViaAlgorithmShouldBeSuccess()
        {
            //Arrange
            int    cacheSize = 255;
            int    nSet      = 1;
            double key       = 6.4;
            double value     = 2.2;

            var algorithm = new LRUAlgorithm <double, double>();

            var cache = new Cache <double, double>(cacheSize, nSet, algorithm);

            cache.Put(key, value);

            algorithm.Remove();

            //Actual
            //Assert
            Assert.Throws <InvalidOperationException>(() => algorithm.GetValue(key));
            Assert.Throws <InvalidOperationException>(() => cache.Get(key));
        }