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"));
 }
Esempio n. 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"));
        }
 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"));
 }
Esempio n. 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"));
        }
        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"));
        }
Esempio n. 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"));
        }