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 TryRemove()
        {
            var fake = A.Fake <IOutputCacheConnection>();

            A.CallTo(() => fake.Remove("key1"));
            DateTime utcExpiry             = DateTime.Now;
            RedisOutputCacheProvider cache = new RedisOutputCacheProvider();

            cache.cache = fake;
            cache.Remove("key1");
            A.CallTo(() => fake.Remove("key1")).MustHaveHappened();
        }
        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 #5
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);
     }
 }
        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);
        }
Example #7
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);
            }
        }
Example #8
0
        public void ExpiryTest()
        {
            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("key8", "data8", utxExpiry);
                // Wait for 1.1 seconds so that data will expire
                System.Threading.Thread.Sleep(1100);
                object data = provider.Get("key8");
                Assert.Null(data);
            }
        }
Example #9
0
        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);
        }
Example #10
0
        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");
            config.Add("redisSerializerType", "Microsoft.Web.Redis.BinarySerializer");
            cache.Initialize("name", config);

            Assert.Equal("localhost", RedisOutputCacheProvider.configuration.Host);
            Assert.Equal(1234, RedisOutputCacheProvider.configuration.Port);
            Assert.Equal("hello world", RedisOutputCacheProvider.configuration.AccessKey);
            Assert.True(RedisOutputCacheProvider.configuration.UseSsl);
            Assert.Equal("Microsoft.Web.Redis.BinarySerializer", RedisOutputCacheProvider.configuration.RedisSerializerType);
        }