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"); }
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(); }
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(); }
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(); }