public void TryAdd()
 {
     var fake = A.Fake<IOutputCacheConnection>();
     DateTime utcExpiry = DateTime.Now;
     A.CallTo(() => fake.Add("key1", "object", utcExpiry)).Returns(new ArgumentException("foo"));
     RedisOutputCacheProvider cache = new RedisOutputCacheProvider();
     cache.cache = fake;
     var obj = cache.Add("key1", "object", utcExpiry);
     Assert.IsType<ArgumentException>(obj);
 }
        public void AddWithoutSetTest()
        {
            using (RedisServer Server = new RedisServer())
            {
                RedisOutputCacheProvider provider = new RedisOutputCacheProvider();
                NameValueCollection config = new NameValueCollection();
                config.Add("ssl", "false");
                provider.Initialize("name", config);

                DateTime utxExpiry = DateTime.UtcNow.AddMinutes(3);
                provider.Add("key4", "data4", utxExpiry);
                object data = provider.Get("key4");
                Assert.Equal("data4", data);
            }
        }
        public void AddScriptFixForExpiryTest()
        {
            using (RedisServer Server = new RedisServer())
            {
                RedisOutputCacheProvider provider = new RedisOutputCacheProvider();
                NameValueCollection config = new NameValueCollection();
                config.Add("ssl", "false");
                provider.Initialize("name", config);

                DateTime utxExpiry = DateTime.UtcNow.AddSeconds(1);
                provider.Add("key9", "data9", utxExpiry);
                object data = provider.Get("key9");
                Assert.Equal("data9", data);
                // Wait for 1.1 seconds so that data will expire
                System.Threading.Thread.Sleep(1100);
                data = provider.Get("key9");
                Assert.Equal(null, data);
            }
        }