public async Task MemoryCacheStoreObjectTest2()
        {
            //Arrange
            var cache = new MemoryCache();

            //Act
            var result = await cache.CacheObject("test2", (object)null);

            //Assert
            Assert.IsFalse(result, "object was null, so nothing was cached");
        }
        public async Task MemoryCacheStoreObjectTest4()
        {
            //Arrange
            var cache = new MemoryCache();

            //Act
            var result = await cache.CacheObject("test4", new List <string> {
                "Sample"
            });

            //Assert
            Assert.IsTrue(result, "Item should be in the cache now.");
        }
        public async Task MemoryCacheStoreObjectTest3()
        {
            //Arrange
            var cache = new MemoryCache();

            //Act
            var result = await cache.CacheObject("test3", new List <string> {
                "Sample"
            }, 4);

            //Assert
            Assert.IsFalse(result, "cache ttl below minimum threshold so nothing cached.");
        }
        public async Task MemoryCacheStoreObjectTest1()
        {
            //Arrange
            var cache = new MemoryCache();

            //Act
            var result = await cache.CacheObject(" ", new List <string> {
                "Sample"
            });

            //Assert
            Assert.IsFalse(result, "no key so nothing is cached");
        }
        public async Task MemoryCacheExistsTest2()
        {
            //Arrange
            var cache = new MemoryCache();
            await cache.CacheObject("test2", new List <string> {
                "sample"
            });

            //Act
            var result = cache.DataCached("test2");

            //Assert
            Assert.IsTrue(result, "Should be an object cached under this key");
        }
        public async Task MemoryCacheInvalidationTest3()
        {
            //Arrange
            var cache = new MemoryCache();
            await cache.CacheObject("test3", new List <string> {
                "sample"
            });

            //Act
            var result = cache.InvalidateKey("test3");

            //Assert
            Assert.IsTrue(result, "key matched, removed item.");
        }
        public async Task MemoryCacheExistsTest3()
        {
            //Arrange
            var cache = new MemoryCache();
            await cache.CacheObject("test3", new List <string> {
                "timed out"
            }, 5);

            //Act
            Task.Delay(5500).Wait(); //Give item chance to expire
            var result = cache.DataCached("test3");

            //Assert
            Assert.IsFalse(result, "Should not be anything cached under that key, because its expired.");
        }
        public async Task MemoryCacheGetObjectTest2()
        {
            //Arrange
            var cache  = new MemoryCache();
            var cached = await cache.CacheObject("test2", new List <string> {
                "sample"
            });

            //Act
            var result = cache.GetObjectFromCache <Dictionary <string, string> >("test2");

            //Assert
            Assert.IsTrue(cached, "Should have cached our string collection");
            Assert.IsNull(result, "Invalid Cast results in null");
        }
        public async Task MemoryCacheGetObjectTest3()
        {
            //Arrange
            var cache  = new MemoryCache();
            var cached = await cache.CacheObject("test3", new List <string> {
                "sample"
            }, 5);

            //Act
            Task.Delay(5200).Wait(); //Let cache expire
            var result = cache.GetObjectFromCache <List <string> >("test3");

            //Assert
            Assert.IsTrue(cached, "Should have cached our string collection");
            Assert.IsNull(result, "Data cache ttl expired, should return null.");
        }
        public async Task MemoryCacheGetObjectTest4()
        {
            //Arrange
            var cache  = new MemoryCache();
            var cached = await cache.CacheObject("test4", new List <string> {
                "sample success"
            });

            //Act
            var result = cache.GetObjectFromCache <List <string> >("test4");

            //Assert
            Assert.IsTrue(cached, "Should have cached our string collection");
            Assert.IsNotNull(result, "Should successfully retrieve data from cache");
            Assert.IsInstanceOfType(result, typeof(List <string>), "Should cast to propper type");
            Assert.AreEqual("sample success", result.FirstOrDefault(), "Should be equal");
        }