public void TrySet()
 {
     var fake = A.Fake<IOutputCacheConnection>();
     A.CallTo(() => fake.Set("key1", "object", A<DateTime>.Ignored));
     DateTime utcExpiry = DateTime.Now;
     RedisOutputCacheProvider cache = new RedisOutputCacheProvider();
     cache.cache = fake;
     cache.Set("key1", "object", A<DateTime>.Ignored);
     A.CallTo(() => fake.Set("key1", "object", A<DateTime>.Ignored)).MustHaveHappened();
 }
 public void SetGetTest()
 {
     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);
         provider.Set("key1", "data1", utxExpiry);
         object data = provider.Get("key1");
         Assert.Equal("data1", data);
     }
 }
        public void AddWhenSetExpiresTest()
        {
            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.Set("key5", "data5", utxExpiry);
                object data = provider.Get("key5");
                Assert.Equal("data5", data);

                // Wait for 1.1 seconds so that data will expire
                System.Threading.Thread.Sleep(1100);
                utxExpiry = DateTime.UtcNow.AddMinutes(3);
                provider.Add("key5", "data5.1", utxExpiry);
                data = provider.Get("key5");
                Assert.Equal("data5.1", data);
            }
        }