public void Invalid() { HashValidatingDownloader downloader = CreateDownloader(request => CreateResponse(request, "crc32c=Bogus1==")); for (int chunks = 1; chunks < 5; chunks++) { // Make sure it definitely fits... downloader.ChunkSize = (s_data.Length + 100) / chunks; var stream = new MemoryStream(); var status = downloader.Download("http://pretend.google.com/", stream); Assert.Equal(DownloadStatus.Failed, status.Status); Assert.Contains("Incorrect hash", status.Exception.Message); } }
public void Valid(string headerValue) { HashValidatingDownloader downloader = CreateDownloader(request => CreateResponse(request, headerValue)); for (int chunks = 1; chunks < 5; chunks++) { // Make sure it definitely fits... downloader.ChunkSize = (s_data.Length + 100) / chunks; var stream = new MemoryStream(); var status = downloader.Download("http://pretend.google.com/", stream); if (status.Exception != null) { throw status.Exception; } Assert.Equal(DownloadStatus.Completed, status.Status); Assert.Equal(s_data, stream.ToArray()); } }