예제 #1
0
        public void AddReturnsTrueForPreviouslySeenValue()
        {
            LRUCacheSet <string> lru = new LRUCacheSet <string>(10);

            lru.Add("a");
            Assert.True(lru.Add("a"));
        }
 bool IUserDeduplicator.ProcessUser(User user)
 {
     if (user == null || user.Key == null)
     {
         return(false);
     }
     return(!_userKeys.Add(user.Key));
 }
예제 #3
0
        public void ValueBecomesNewEachTimeItIsAdded()
        {
            LRUCacheSet <string> lru = new LRUCacheSet <string>(2);

            lru.Add("a");
            lru.Add("b");
            lru.Add("a");
            lru.Add("c");
            Assert.True(lru.Add("c"));
            Assert.True(lru.Add("a"));
            Assert.False(lru.Add("b"));
        }
예제 #4
0
        public void OldestValueIsForgottenIfCapacityExceeded()
        {
            LRUCacheSet <string> lru = new LRUCacheSet <string>(2);

            lru.Add("a");
            lru.Add("b");
            lru.Add("c");
            Assert.True(lru.Add("c"));
            Assert.True(lru.Add("b"));
            Assert.False(lru.Add("a"));
        }
예제 #5
0
        public void AddReturnsFalseForNeverSeenValue()
        {
            LRUCacheSet <string> lru = new LRUCacheSet <string>(10);

            Assert.False(lru.Add("a"));
        }