示例#1
0
        public void ExistsAsync_GivenNullCacheKey_ShouldThrowArgumentNullException()
        {
            //---------------Set up test pack-------------------
            var thuriaCache = new ThuriaCache <string>();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var exception = Assert.ThrowsAsync <ArgumentNullException>(() => thuriaCache.ExistsAsync(null));

            //---------------Test Result -----------------------
            exception.ParamName.Should().Be("cacheKey");
        }
示例#2
0
        public async Task ExistsAsync_GivenDataDoesNotExist_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            var cacheKey    = RandomValueGenerator.CreateRandomString(5, 10);
            var thuriaCache = new ThuriaCache <string>();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var dataExist = await thuriaCache.ExistsAsync(cacheKey);

            //---------------Test Result -----------------------
            dataExist.Should().BeFalse();
        }
示例#3
0
        public async Task ExistsAsync_GivenDataExists_And_NotExpired_ShouldReturnTrue()
        {
            //---------------Set up test pack-------------------
            var cacheKey    = RandomValueGenerator.CreateRandomString(5, 10);
            var cacheData   = RandomValueGenerator.CreateRandomString(20, 50);
            var thuriaCache = new ThuriaCache <string>();

            await thuriaCache.UpsertAsync(cacheKey, new ThuriaCacheData <string>(cacheData));

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var dataExist = await thuriaCache.ExistsAsync(cacheKey);

            //---------------Test Result -----------------------
            dataExist.Should().BeTrue();
        }
示例#4
0
        public async Task ExistsAsync_GivenDataExists_And_Expired_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            var cacheKey        = RandomValueGenerator.CreateRandomString(5, 10);
            var cacheData       = RandomValueGenerator.CreateRandomString(20, 50);
            var thuriaCache     = new ThuriaCache <string>();
            var thuriaCacheData = new ThuriaCacheData <string>(cacheData, DateTime.UtcNow.AddMilliseconds(10));

            await thuriaCache.UpsertAsync(cacheKey, thuriaCacheData, false);

            Thread.Sleep(200);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var dataExist = await thuriaCache.ExistsAsync(cacheKey);

            //---------------Test Result -----------------------
            dataExist.Should().BeFalse();
        }