public async void IReport_Download_Tests() { PdfReport report = new PdfReport("a/b/c/file.pdf"); Assert.True(await report.Configure(PdfApiMock.Object, BarcodeMock.Object), "Configure should succeed"); byte[] actualContent; byte[] expectedContent = { 0x01, 0x02, 0x03 }; await using (MemoryStream ms = new MemoryStream()) { await report.Download(ms); actualContent = ms.ToArray(); } PdfApiMock.Verify(e => e.DownloadFileAsync("a/b/c/file.pdf", null, null), Times.Exactly(1)); Assert.True(actualContent.SequenceEqual(expectedContent), "Download bytes do not match"); PdfApiMock.Invocations.Clear(); await using (MemoryStream ms = new MemoryStream()) { await report.Download(PdfApiMock.Object, ms, "a/b/c/file.pdf", null); actualContent = ms.ToArray(); } PdfApiMock.Verify(e => e.DownloadFileAsync("a/b/c/file.pdf", null, null), Times.Exactly(1)); Assert.True(actualContent.SequenceEqual(expectedContent), "Download bytes do not match"); }