public void ShouldReturnNullIfNotDownloadPage() { // Arrange var mockHttpMessageHandler = new MockHttpMessageHandlerBadRequest(); var client = new HttpClient(mockHttpMessageHandler); CancellationToken cts = new CancellationToken(); string urlToParse = "http://en.wikipedia.org/"; var sut = new PageDownloaderService(); // Act var task = sut.DownloadPage(urlToParse, client, cts); // Asserts Assert.AreEqual(task.Result, null); }
public void ShouldDownloadPage() { // Arrange var mockHttpMessageHandler = new MockHttpMessageHandlerOK(); var client = new HttpClient(mockHttpMessageHandler); CancellationToken cts = new CancellationToken(); string urlToParse = "http://en.wikipedia.org/"; var sut = new PageDownloaderService(); // Act var task = sut.DownloadPage(urlToParse, client, cts); // Asserts Assert.AreEqual(task.Result, urlToParse.GetHashCode().ToString()); }