private async Task CompareDownloadedStreamToStringContent(string contentToCompare, DocumentFormatReader documentFormatReader) { using (var downloaded = new MemoryStream()) { await(await documentFormatReader.OpenStream()).CopyToAsync(downloaded); var downloadedString = System.Text.Encoding.UTF8.GetString(downloaded.ToArray()); Assert.AreEqual(downloadedString, contentToCompare, "Downloaded stream is not identical"); } }
private async Task CompareDownloadedStreamToFile(string pathToFileToCompare, DocumentFormatReader documentFormatReader) { using (var downloaded = new MemoryStream()) using (var uploaded = new MemoryStream()) { using (var fileStream = File.OpenRead(pathToFileToCompare)) { await fileStream.CopyToAsync(uploaded).ConfigureAwait(false); } await(await documentFormatReader.OpenStream()).CopyToAsync(downloaded); Assert.IsTrue(CompareMemoryStreams(uploaded, downloaded), "Downloaded format is not equal to last format uploaded"); } }