public void TryGet()
 {
     var fake = A.Fake<IOutputCacheConnection>();
     A.CallTo(() => fake.Get("key1")).Returns(new ArgumentException("foo"));
     RedisOutputCacheProvider cache = new RedisOutputCacheProvider();
     cache.cache = fake;
     var obj = cache.Get("key1");
     Assert.IsType<ArgumentException>(obj);
 }
        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);
            }
        }
 public void GetWithoutSetTest()
 {
     using (RedisServer Server = new RedisServer())
     {
         RedisOutputCacheProvider provider = new RedisOutputCacheProvider();
         NameValueCollection config = new NameValueCollection();
         config.Add("ssl", "false");
         DateTime utxExpiry = DateTime.UtcNow.AddMinutes(3);
         provider.Initialize("name", config);
         Assert.Equal(null, provider.Get("key1"));
     }
 }
        public void AddWithExistingSetTest()
        {
            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.Set("key3", "data3", utxExpiry);
                provider.Add("key3", "data3.1", utxExpiry);
                object data = provider.Get("key3");
                Assert.Equal("data3", data);
            }
        }
 public void RemoveWithoutSetTest()
 {
     using (RedisServer Server = new RedisServer())
     {
         RedisOutputCacheProvider provider = new RedisOutputCacheProvider();
         NameValueCollection config = new NameValueCollection();
         config.Add("ssl", "false");
         provider.Initialize("name", config);
         provider.Remove("key6");
         object data = provider.Get("key6");
         Assert.Equal(null, data);
     }
 }