-
-
Save HamidMosalla/db7206325cfe9e552211d2f5fe4668be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CaptchaValidatorTests | |
{ | |
private Mock<FakeHttpMessageHandler> _fakeHttpMessageHandler; | |
private HttpClient _httpClient; | |
public CaptchaValidatorTests() | |
{ | |
_fakeHttpMessageHandler = new Mock<FakeHttpMessageHandler> { CallBase = true }; | |
_httpClient = new HttpClient(_fakeHttpMessageHandler.Object); | |
} | |
[Fact] | |
public async Task ValidateCaptchaAsync_ShouldReturn_TheCorrectType() | |
{ | |
//Arrange | |
_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); | |
//Act | |
var result = await sut.ValidateCaptchaAsync(); | |
//Assert | |
result.Should().NotBeNull(); | |
result.Should().BeOfType<CaptchaResponse>(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment