Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class CaptchaValidatorTests
private Mock<FakeHttpMessageHandler> _fakeHttpMessageHandler;
private HttpClient _httpClient;
public CaptchaValidatorTests()
_fakeHttpMessageHandler = new Mock<FakeHttpMessageHandler> { CallBase = true };
_httpClient = new HttpClient(_fakeHttpMessageHandler.Object);
public async Task ValidateCaptchaAsync_ShouldReturn_TheCorrectType()
_fakeHttpMessageHandler.Setup(f => f.Send(It.IsAny<HttpRequestMessage>())).Returns(new HttpResponseMessage
StatusCode = HttpStatusCode.OK,
Content =new StringContent("{\"success\": false,\"error-codes\": [\"It's a fake error!\",\"It's a fake error\"]}")
var sut = new CaptchaValidator(_httpClient);
var result = await sut.ValidateCaptchaAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.