Exemple #1
0
        public void TryUpdateCacheItem_KeyDoesNotExist_ReturnsFalse()
        {
            int newValue = _value + 7;
            ICacheItem <int> newCacheItem = new NonExpiringCacheItem <int>(newValue);
            bool             result       = _cache.TryUpdate(_key, newCacheItem);

            Assert.False(result);
        }
        public void TryUpdateCacheItem_KeyDoesNotExist_ReturnsFalse()
        {
            int newValue = _value + 7;
            ICacheItem<int> newCacheItem = new NonExpiringCacheItem<int>(newValue);
            bool result = _cache.TryUpdate(_key, newCacheItem);

            Assert.False(result);
        }
        public void TryUpdateCacheItem_KeyExists_ReturnsTrue()
        {
            int newValue = _value + 7;
            ICacheItem<int> newCacheItem = new NonExpiringCacheItem<int>(newValue);
            _cache.Add(_key, _cacheItem);

            bool result = _cache.TryUpdate(_key, newCacheItem);

            Assert.True(result);
        }
Exemple #4
0
        public void TryUpdateCacheItem_KeyExists_ReturnsTrue()
        {
            int newValue = _value + 7;
            ICacheItem <int> newCacheItem = new NonExpiringCacheItem <int>(newValue);

            _cache.Add(_key, _cacheItem);

            bool result = _cache.TryUpdate(_key, newCacheItem);

            Assert.True(result);
        }
        public void TryUpdateCacheItem_KeyDoesNotExist_NewItemIsNotAdded()
        {
            int newValue = _value + 7;
            ICacheItem<int> newCacheItem = new NonExpiringCacheItem<int>(newValue);
            _cache.TryUpdate(_key, newCacheItem);

            ICacheItem<int> updatedCacheItem;
            bool result = _cache.TryGetValue(_key, out updatedCacheItem);

            Assert.False(result);
        }
Exemple #6
0
        public void TryUpdateCacheItem_KeyDoesNotExist_NewItemIsNotAdded()
        {
            int newValue = _value + 7;
            ICacheItem <int> newCacheItem = new NonExpiringCacheItem <int>(newValue);

            _cache.TryUpdate(_key, newCacheItem);

            ICacheItem <int> updatedCacheItem;
            bool             result = _cache.TryGetValue(_key, out updatedCacheItem);

            Assert.False(result);
        }
        public void Contains_ValueIsReferenceType_ChecksForReferenceEquality()
        {
            ICache<string, SampleValue> cache = new Cache<string, SampleValue>(_timerInterval);
            SampleValue value = new SampleValue();
            ICacheItem<SampleValue> cacheItem = new NonExpiringCacheItem<SampleValue>(value);
            KeyValuePair<string, SampleValue> keyValuePair = new KeyValuePair<string, SampleValue>(_key, value);
            cache.Add(_key, cacheItem);

            bool result = cache.Contains(keyValuePair);

            Assert.True(result);
        }
        public void TryUpdateCacheItem_KeyExists_ValueIsUpdated()
        {
            int newValue = _value + 7;
            ICacheItem<int> newCacheItem = new NonExpiringCacheItem<int>(newValue);
            _cache.Add(_key, _cacheItem);
            _cache.TryUpdate(_key, newCacheItem);

            ICacheItem<int> updatedCacheItem;
            bool result = _cache.TryGetValue(_key, out updatedCacheItem) && updatedCacheItem == newCacheItem;

            Assert.True(result);
        }
Exemple #9
0
        public void Contains_ValueIsReferenceType_ChecksForReferenceEquality()
        {
            ICache <string, SampleValue> cache = new Cache <string, SampleValue>(_timerInterval);
            SampleValue value = new SampleValue();
            ICacheItem <SampleValue>           cacheItem    = new NonExpiringCacheItem <SampleValue>(value);
            KeyValuePair <string, SampleValue> keyValuePair = new KeyValuePair <string, SampleValue>(_key, value);

            cache.Add(_key, cacheItem);

            bool result = cache.Contains(keyValuePair);

            Assert.True(result);
        }
Exemple #10
0
        public void TryUpdateCacheItem_KeyExists_ValueIsUpdated()
        {
            int newValue = _value + 7;
            ICacheItem <int> newCacheItem = new NonExpiringCacheItem <int>(newValue);

            _cache.Add(_key, _cacheItem);
            _cache.TryUpdate(_key, newCacheItem);

            ICacheItem <int> updatedCacheItem;
            bool             result = _cache.TryGetValue(_key, out updatedCacheItem) && updatedCacheItem == newCacheItem;

            Assert.True(result);
        }
        protected override void FinalizeSetup()
        {
            _key1 = "key1";
            _key2 = "key2";
            _key3 = "key3";

            _value1 = _value + 1;
            _value2 = _value + 2;
            _value3 = _value + 3;

            _cacheItem1 = new NonExpiringCacheItem <int>(_value1);
            _cacheItem2 = new NonExpiringCacheItem <int>(_value2);
            _cacheItem3 = new NonExpiringCacheItem <int>(_value3);
        }
        protected override void FinalizeSetup()
        {
            _key1 = "key1";
            _key2 = "key2";
            _key3 = "key3";

            _value1 = _value + 1;
            _value2 = _value + 2;
            _value3 = _value + 3;

            _cacheItem1 = new NonExpiringCacheItem<int>(_value1);
            _cacheItem2 = new NonExpiringCacheItem<int>(_value2);
            _cacheItem3 = new NonExpiringCacheItem<int>(_value3);
        }