public async Task Should_invoke_asset_store_to_download_picture() { assetStore.Setup(x => x.DownloadAsync(userId, 0, "picture", It.IsAny <Stream>())) .Callback <string, long, string, Stream>((id, version, suffix, stream) => stream.Write(new byte[] { 1, 2, 3, 4 }, 0, 4)) .Returns(TaskHelper.Done) .Verifiable(); var result = await sut.DownloadAsync(userId); Assert.Equal(0, result.Position); Assert.Equal(4, result.Length); assetStore.VerifyAll(); }
public async Task Should_invoke_asset_store_to_download_picture() { A.CallTo(() => assetStore.DownloadAsync(userId, 0, "picture", A <Stream> .Ignored)) .Invokes(async(string id, long version, string suffix, Stream stream) => { await stream.WriteAsync(new byte[] { 1, 2, 3, 4 }, 0, 4); }); var result = await sut.DownloadAsync(userId); Assert.Equal(0, result.Position); Assert.Equal(4, result.Length); A.CallTo(() => assetStore.DownloadAsync(userId, 0, "picture", A <Stream> .Ignored)).MustHaveHappened(); }
public async Task Should_invoke_asset_store_to_download_picture() { A.CallTo(() => assetStore.DownloadAsync(userId, 0, "picture", A <Stream> .Ignored, CancellationToken.None)) .Invokes(async(IFakeObjectCall call) => { var stream = call.GetArgument <Stream>(3); await stream.WriteAsync(new byte[] { 1, 2, 3, 4 }, 0, 4); }); var result = await sut.DownloadAsync(userId); Assert.Equal(0, result.Position); Assert.Equal(4, result.Length); A.CallTo(() => assetStore.DownloadAsync(userId, 0, "picture", A <Stream> .Ignored, CancellationToken.None)).MustHaveHappened(); }