예제 #1
0
 public void TestShouldAddItemEvenIfCapacityExceedsByRemovingLeastAccessedItem()
 {
     int capacity = 2;
     var forgettingMap = new ForgettingMap(capacity);
     forgettingMap.Add("key", System.DateTime.Now.ToShortDateString());
     forgettingMap.Add("key1", System.DateTime.Now.ToShortDateString());
     forgettingMap.Add("key2", System.DateTime.Now.ToShortDateString());
     Assert.IsNotNull(forgettingMap.Find("key2"));
 }
예제 #2
0
        public void TestShouldAddItemEvenIfCapacityExceedsByRemovingLeastAccessedItem()
        {
            int capacity      = 2;
            var forgettingMap = new ForgettingMap(capacity);

            forgettingMap.Add("key", System.DateTime.Now.ToShortDateString());
            forgettingMap.Add("key1", System.DateTime.Now.ToShortDateString());
            forgettingMap.Add("key2", System.DateTime.Now.ToShortDateString());
            Assert.IsNotNull(forgettingMap.Find("key2"));
        }
예제 #3
0
 public void TestKeepTrackOfSearchCount()
 {
     int capacity = 2;
     var forgettingMap = new ForgettingMap(capacity);
     forgettingMap.Add("key", System.DateTime.Now.ToShortDateString());
     forgettingMap.Add("key2", System.DateTime.Now.ToShortDateString());
     var searchCount = 5;
     for (int i = 0; i < searchCount; i++)
     {
         var found = forgettingMap.Find("key");
     }
     Assert.AreEqual(searchCount, forgettingMap.SearchStats("key"));
 }
예제 #4
0
        public void TestKeepTrackOfSearchCount()
        {
            int capacity      = 2;
            var forgettingMap = new ForgettingMap(capacity);

            forgettingMap.Add("key", System.DateTime.Now.ToShortDateString());
            forgettingMap.Add("key2", System.DateTime.Now.ToShortDateString());
            var searchCount = 5;

            for (int i = 0; i < searchCount; i++)
            {
                var found = forgettingMap.Find("key");
            }
            Assert.AreEqual(searchCount, forgettingMap.SearchStats("key"));
        }
예제 #5
0
        public void TestShouldRemoveOldestItemIfTwoItemsWithLeastSearch()
        {
            int capacity = 2;
            var forgettingMap = new ForgettingMap(capacity);
            forgettingMap.Add("key", System.DateTime.Now.ToShortDateString());
            forgettingMap.Find("key");
            forgettingMap.Find("key");
            forgettingMap.Find("key");

            forgettingMap.Add("key1", System.DateTime.Now.ToShortDateString());
            forgettingMap.Find("key1");
            forgettingMap.Find("key1");
            forgettingMap.Find("key1");
            forgettingMap.Add("key2", System.DateTime.Now.ToShortDateString());
            Assert.IsNotNull(forgettingMap.Find("key1"));
        }
예제 #6
0
        public void TestShouldRemoveOldestItemIfTwoItemsWithLeastSearch()
        {
            int capacity      = 2;
            var forgettingMap = new ForgettingMap(capacity);

            forgettingMap.Add("key", System.DateTime.Now.ToShortDateString());
            forgettingMap.Find("key");
            forgettingMap.Find("key");
            forgettingMap.Find("key");

            forgettingMap.Add("key1", System.DateTime.Now.ToShortDateString());
            forgettingMap.Find("key1");
            forgettingMap.Find("key1");
            forgettingMap.Find("key1");
            forgettingMap.Add("key2", System.DateTime.Now.ToShortDateString());
            Assert.IsNotNull(forgettingMap.Find("key1"));
        }