public void AddOrUpdateExistingWithObjectTest()
        {
            var _cache = new CollectionCache<object, object>();
            var _key = typeof(object);
            var _value = typeof(object);

            var _addOrGetExisting = _cache.AddOrGetExisting(_key, _value, DateTimeOffset.UtcNow.AddMilliseconds(500));
            Assert.AreEqual(_value, _addOrGetExisting);

            var _value2 = new KeyValuePair<object, object>(_key, new object());
            var _actual = _cache.AddOrUpdateExisting(_key, _value2);

            Assert.AreEqual(_actual, _value2);
        }
        public void AddOrUpdateExistingWhenRegionNameTest()
        {
            const string REGION = "Test";

            var _cache = new CollectionCache<object, object>();
            var _key = new object();
            var _value1 = new object();

            var _addOrGetExisting = _cache.AddOrGetExisting(_key, _value1, REGION);
            Assert.AreEqual(_value1, _addOrGetExisting);

            var _value2 = new KeyValuePair<object, object>(_key, new object());
            var _value = _cache.AddOrUpdateExisting(_key, _value2, null, REGION);

            Assert.AreNotEqual(_addOrGetExisting, _value);
            Assert.AreEqual(_value2, _value);
        }
        public void AddOrUpdateExistingWhenAbsoluteExpirationTest()
        {
            var _cache = new CollectionCache<string, object>();
            const string KEY = "Test";
            var _value1 = new object();

            var _addOrGetExisting = _cache.AddOrGetExisting(KEY, _value1);
            Assert.AreEqual(_value1, _addOrGetExisting);

            var _value2 = new object();
            var _value = _cache.AddOrUpdateExisting(KEY, _value2, DateTimeOffset.UtcNow.AddMilliseconds(20));

            Assert.AreNotEqual(_addOrGetExisting, _value);
            Assert.AreEqual(_value2, _value);

            Thread.Sleep(80);

            Assert.IsNull(_cache.Get(KEY).FirstOrDefault(_x => _x == _value));
        }
        public void AddOrUpdateExistingWhenNotExistsTest()
        {
            var _cache = new CollectionCache<string, object>();
            const string KEY = "Test";

            var _value = new KeyValuePair<string, object>(KEY, new object());
            var _actual = _cache.AddOrUpdateExisting(KEY, _value);

            Assert.AreEqual(_value, _actual);
        }
        public void AddOrUpdateExistingTest()
        {
            var _cache = new CollectionCache<string, object>();
            const string KEY = "Test";
            var _value1 = new object();

            var _addOrGetExisting = _cache.AddOrGetExisting(KEY, _value1);
            Assert.AreEqual(_value1, _addOrGetExisting);

            var _value2 = new KeyValuePair<string, object>(KEY, new object());
            var _value = _cache.AddOrUpdateExisting(KEY, _value2);

            Assert.AreNotEqual(_addOrGetExisting, _value);
            Assert.AreEqual(_value2, _value);
        }