Esempio n. 1
0
        public async Task SetCachedItemTest()
        {
            //Arrange
            var accessor = new BlogCacheAccessor(_cfg, _connectionMultiplexer);
            var item     = new CacheTestModel
            {
                Number           = 64,
                Text             = $"{_testKeys["SetCachedItemTest"]}",
                StringCollection = new[]
                {
                    "Last test first",
                    "this should work"
                }
            };

            //Act
            await accessor.CacheEnt(_testKeys["SetCachedItemTest"], item);

            Task.Delay(500).Wait();
            var result = await accessor.GetEnt <CacheTestModel>(_testKeys["SetCachedItemTest"]);

            //Assert
            Assert.IsNotNull(result, "Should have cached the item, and retrieved it");
            Assert.IsInstanceOfType(result, typeof(CacheTestModel));
            Assert.AreEqual(item.Number, result.Number, "Should be equal");
            Assert.AreEqual(item.Text, result.Text, "Should be equal");
            Assert.AreEqual(item.StringCollection.Count(), result.StringCollection.Count(), "Should be equal");
        }
Esempio n. 2
0
        public async Task GetCachedItemNotCachedTest()
        {
            //Arrange
            var accessor = new BlogCacheAccessor(_cfg, _connectionMultiplexer);

            //Act
            var result = await accessor.GetEnt <CacheTestModel>(_testKeys["GetCachedItemNotCachedTest"]);

            //Assert
            Assert.IsNull(result, "Should be nothing cached on this key");
        }
Esempio n. 3
0
        public async Task GetCachedItemTest()
        {
            //Arrange
            var accessor = new BlogCacheAccessor(_cfg, _connectionMultiplexer);

            //Act
            var result = await accessor.GetEnt <CacheTestModel>(_testKeys["GetCachedItemTest"]);

            //Assert
            Assert.IsNotNull(result, "Should be an object from cache");
            Assert.IsInstanceOfType(result, typeof(CacheTestModel));
        }