Пример #1
0
        private void LoadSimpleData()
        {
            var data = new TestData {
                Double1 = 4.5, Int1 = 32, String1 = "test"
            };

            _cache.Add(data, "key1", Cache.NoAbsoluteExpiration);
            _cache.Add(data, "key2", DateTime.Now);
            _cache.Add(data, "key3", DateTime.Now.AddDays(2));
            _cache.Add(data, "key4", DateTime.Now.AddDays(-2));
        }
        public void AddGetRemove_Success()
        {
            // Arrange
            Customer customer = TestData.CreateCustomer();
            ICache   cache    = new FileSystemCache();

            // Add, Get and Assert
            cache.Add(customer.Id.ToString(), customer);
            object customerObject = cache.Get(customer.Id.ToString());

            // Assert
            Assert.IsNotNull(customerObject);
            Assert.IsInstanceOfType(customerObject, typeof(Customer));


            // Remove and Assert
            cache.Remove(customer.Id.ToString());
            customerObject = cache.Get(customer.Id.ToString());
            Assert.IsNull(customerObject);
        }
Пример #3
0
        public void WhenAnItemIsAddedToTheCache_ThenKeysContainsTheKeyName()
        {
            _cache.Add("Test", "TestKey", Cache.NoAbsoluteExpiration);

            Assert.IsTrue(_cache.Keys.Contains("testkey", StringComparer.OrdinalIgnoreCase));
        }