Example #1
0
        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.Null(data);
            }
        }
        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 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"));
     }
 }
Example #4
0
 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.Null(data);
     }
 }
Example #5
0
        public void SetGetTest()
        {
            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("key2", "data2", utxExpiry);
                object data = provider.Get("key2");
                Assert.Equal("data2", data);
            }
        }