public void CheckAllInputLinksWhenNoFilterIsSpecified() { // arrange var input = new LinkCheckerInput(_links); (var httpClient, _) = CreateMockHttpClient((msg, token) => new HttpResponseMessage { StatusCode = HttpStatusCode.OK }); var linkChecker = new LinkChecker(httpClient); // act var result = linkChecker.Check(input); PrintOut(result); // assert result.LinkStates.Keys.Should().BeEquivalentTo(_links); }
public void SkipNonHttpLinks() { // arrange var malformedUrl = new Link("xtp://something.com/"); var input = new LinkCheckerInput(new [] { malformedUrl }); (var httpClient, var httpHandlerMock) = CreateMockHttpClient((msg, token) => throw new NotImplementedException()); var linkChecker = new LinkChecker(httpClient); // act var result = linkChecker.Check(input); PrintOut(result); // assert result.LinkStates.Should().BeEquivalentTo(new Dictionary <Link, LinkStatus> { [malformedUrl] = LinkStatus.SKIPPED }); httpHandlerMock.Protected().Verify("SendAsync", Times.Never(), ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()); }
public void ReportInvalidLinks(HttpResponseMessage responseMessage) { // arrange var link = new Link("http://www.google.com/"); var input = new LinkCheckerInput(new [] { link }); (var httpClient, var httpHandlerMock) = CreateMockHttpClient((msg, token) => responseMessage); var linkChecker = new LinkChecker(httpClient); // act var result = linkChecker.Check(input); PrintOut(result); // assert result.LinkStates.Should().BeEquivalentTo(new Dictionary <Link, LinkStatus> { [link] = LinkStatus.INVALID }); httpHandlerMock.Protected().Verify( "SendAsync", Times.Exactly(1), ItExpr.Is <HttpRequestMessage>(rm => rm.Method == HttpMethod.Get && rm.RequestUri == new Uri(link.Url)), ItExpr.IsAny <CancellationToken>()); }