public void GetCountWhenRegionNameTest() { const string REGION = "Test"; var _cache = new CollectionCache<object, object>(); var _key = new object(); var _value = new object(); var _addOrGetExisting = _cache.AddOrGetExisting(_key, _value, REGION); Assert.AreEqual(_value, _addOrGetExisting); var _count = _cache.GetCount(_key, REGION); Assert.AreEqual(1, _count); }
public void GetCountWhenRegionNameDoesNotExistsTest() { const string REGION = "TestA"; const string REGION2 = "TestB"; var _cache = new CollectionCache<object, object>(); var _key = new object(); var _keyValuePair = new KeyValuePair<object, object>(_key, new object()); var _addOrGetExisting = _cache.AddOrGetExisting(_key, _keyValuePair, REGION); Assert.AreEqual(_keyValuePair, _addOrGetExisting); Assert.Throws<KeyNotFoundException>(() => _cache.GetCount(_key, REGION2)); }
public void GetCountWhenNoElementsTest() { var _cache = new CollectionCache<object, object>(); var _count = _cache.GetCount(new object()); Assert.AreEqual(0, _count); }
public void GetCountWhenRegionAndNoElementsTest() { const string REGION = "TestC"; var _cache = new CollectionCache<object, object>(); var _key = new object(); var _keyValuePair = new KeyValuePair<object, object>(_key, new object()); var _addOrGetExisting = _cache.AddOrGetExisting(_key, _keyValuePair, REGION); Assert.AreEqual(_keyValuePair, _addOrGetExisting); var _count = _cache.GetCount(_key); Assert.AreEqual(0, _count); }
public void GetCountTest() { var _cache = new CollectionCache<string, object>(); const string KEY = "Test"; var _value = new object(); var _addOrGetExisting = _cache.AddOrGetExisting(KEY, _value); Assert.AreEqual(_value, _addOrGetExisting); var _count = _cache.GetCount(KEY); Assert.AreEqual(1, _count); }