public async Task WhenCalling_CacheImageAsync_Should_CallDistributedCacheToSetImage() { var distributedCache = A.Fake <IDistributedCache>(); var sut = new ImagesCache(distributedCache); var testGdiImage = TestHelpers.GetTestImage(); await sut.CacheImageAsync(new ImageCacheKey("01_04_2019_001103"), new Image("01_04_2019_001103", testGdiImage)); A.CallTo(() => distributedCache.SetAsync( A <string> .That.Matches(key => key == "01_04_2019_001103"), A <byte[]> .That.Matches(value => IsMatchingImageBytes(value, "01_04_2019_001103", testGdiImage)), A <DistributedCacheEntryOptions> ._, A <CancellationToken> ._)) .MustHaveHappenedOnceExactly(); }
public async Task WhenCalling_CacheImageAsync_Should_CallDistributedCacheWithWatermarkHashInKey() { var distributedCache = A.Fake <IDistributedCache>(); var sut = new ImagesCache(distributedCache); var testGdiImage = TestHelpers.GetTestImage(); await sut.CacheImageAsync( new ImageCacheKey("01_04_2019_001103", null, null, "Some watermark text"), new Image("01_04_2019_001103", testGdiImage)); A.CallTo(() => distributedCache.SetAsync( A <string> .That.Matches(key => key == "01_04_2019_001103|wm=NZyQwos0iWRAmdBFA9T6q+MZn9B0fgauzH3MJpNplsc="), A <byte[]> .That.Matches(value => IsMatchingImageBytes(value, "01_04_2019_001103", testGdiImage)), A <DistributedCacheEntryOptions> ._, A <CancellationToken> ._)) .MustHaveHappenedOnceExactly(); }