public async Task Should_throw_exception_when_file_to_upload_is_not_an_image() { var stream = new MemoryStream(); var file = new NoopAssetFile(); var command = CreateCommand(new UploadAppImage { AppId = appId, File = file }); var context = CreateContextForCommand(command); A.CallTo(() => assetThumbnailGenerator.GetImageInfoAsync(stream)) .Returns(Task.FromResult <ImageInfo?>(null)); await Assert.ThrowsAsync <ValidationException>(() => sut.HandleAsync(context)); }
public async Task Should_upload_image_to_store() { var file = new NoopAssetFile(); var command = CreateCommand(new UploadAppImage { AppId = appId, File = file }); var context = CreateContextForCommand(command); A.CallTo(() => assetThumbnailGenerator.GetImageInfoAsync(A <Stream> ._)) .Returns(new ImageInfo(100, 100, false)); await sut.HandleAsync(context); A.CallTo(() => appImageStore.UploadAsync(appId.Id, A <Stream> ._, A <CancellationToken> ._)) .MustHaveHappened(); }