public void Replace()
        {
            _cache.Store("key", 123, Encoding.ASCII.GetBytes("12345"), new DateTime(1999, 1, 1));
            _cache.Replace("key", 123, new DateTime(1999, 1, 1), Encoding.ASCII.GetBytes("12345"));

            Assert.AreEqual(2, _testObserver.Messages.Count);
            var storeNotification1 = GetNotification();

            Assert.IsInstanceOfType(storeNotification1, typeof(StoreNotification));
            var storeNotification2 = GetNotification(1);

            Assert.IsInstanceOfType(storeNotification2, typeof(StoreNotification));
        }
Beispiel #2
0
        public void ReplacePreventsEvict()
        {
            _cache.Store("key1", 0, new byte[] { 0, 1, 2, 3 }, DateTime.MaxValue);
            _cache.Store("key2", 0, new byte[] { 0, 1, 2, 3 }, DateTime.MaxValue);
            _cache.Replace("key1", 0, DateTime.MaxValue, new byte[] { 3, 2, 1, 0 });

            _cache.Store("key3", 0, new byte[] { 0, 1, 2, 3, 4 }, DateTime.MaxValue);

            var keys = _cache.Keys.ToArray();

            Assert.AreEqual(2, keys.Length);
            Assert.IsTrue(keys.Contains("key1"));
            Assert.IsTrue(keys.Contains("key3"));
        }