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 TryInitialize() { var fake = A.Fake<IOutputCacheConnection>(); RedisOutputCacheProvider cache = new RedisOutputCacheProvider(); cache.cache = fake; NameValueCollection config = new NameValueCollection(); config.Add("host", "localhost"); config.Add("port", "1234"); config.Add("accessKey", "hello world"); config.Add("ssl", "true"); cache.Initialize("name", config); Assert.Equal(RedisOutputCacheProvider.configuration.Host, "localhost"); Assert.Equal(RedisOutputCacheProvider.configuration.Port, 1234); Assert.Equal(RedisOutputCacheProvider.configuration.AccessKey, "hello world"); Assert.Equal(RedisOutputCacheProvider.configuration.UseSsl, true); }
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 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); } }