public async Task WhenHttpResponseWithoutError_ShouldWorkCorrectly() { // arrange using var httpTest = new HttpTest(); httpTest.RespondWithJson(new { error = false, }); // act var result = await _captchaServiceClient.ValidateAsync("id", "text"); // assert httpTest.ShouldHaveCalled("http://captcha-service/api/captcha-service/validate") .WithVerb(HttpMethod.Post) .WithRequestUrlEncoded(new { id = "id", text = "text", }) .Times(1); result.Correct.Should().BeTrue(); result.ErrorMessage.Should().BeEmpty(); }
public async Task <RegisterOutput> Register(RegisterInput input) { var captchaResult = await _captchaServiceClient.ValidateAsync(input.CaptchaId, input.CaptchaText); if (!captchaResult.Correct) { throw new UserFriendlyException(captchaResult.ErrorMessage); } await _userRegistrationManager.RegisterAsync( input.UserName, input.Password); return(new RegisterOutput { CanLogin = true, }); }