public void CreateAsync_ShouldNotCreateCache_WithoutValidKey() { string key = ""; // invalid key MyStubClass myStubClass = null; string expectedErrorMessage = "Unable to create the cache entry because the arguments are null"; CalendarPlusApplicationException ex = Assert.ThrowsAsync <CalendarPlusApplicationException>( () => _cacheProvider.CreateAsync(key, myStubClass, null, default) ); Assert.AreEqual(expectedErrorMessage, ex.Message); }
public async Task CreateAsync_ShouldCreateCacheAsync() { string key = $"Anonimo:{ typeof(MyStubClass).Name }:2021-03-19:"; MyStubClass myStubClass = A.Fake <MyStubClass>(); string dataAsJson = JsonConvert.SerializeObject(key); byte[] dataAsBytesArray = Encoding.UTF8.GetBytes(dataAsJson); await _cacheProvider.CreateAsync(key, myStubClass, null, default); A.CallTo(() => _cache.SetAsync(key, dataAsBytesArray, null, default)) .WithAnyArguments() .MustHaveHappened(); }