コード例 #1
0
        public void UpdateEntryViaAlgorithmShouldBeFirst()
        {
            //Arrange
            string key1   = "1";
            int    value1 = 1;
            string key2   = "2";
            int    value2 = 2;

            var algorithm = new LRUAlgorithm <string, int>();

            algorithm.Add(key1, value1);
            algorithm.Add(key2, value2);
            algorithm.Update(key1);

            //Actual
            //Assert
            Assert.IsTrue(algorithm.IsKeyValuePairFirst(key1));
        }
コード例 #2
0
        public void GetEntryViaCacheShouldBeFirst()
        {
            //Arrange
            int    cacheSize = 256;
            int    nSet      = 5;
            int    key1      = 1;
            string value1    = "1";
            int    key2      = 2;
            string value2    = "2";

            var algorithm = new LRUAlgorithm <int, string>();

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

            cache.Put(key1, value1);
            cache.Put(key2, value2);
            cache.Get(key1);

            //Actual
            //Assert
            Assert.IsTrue(algorithm.IsKeyValuePairFirst(key1));
        }