public void when_GetTransaction_is_called_and_not_found_then_we_should_get_a_NotFoundException() { using (HttpTest httpTest = new HttpTest()) { httpTest.RespondWithJson(404, new { message = "Not Found" }); var signhostApiClient = new SignHostApiClient(settings); Func<Task> getTransaction = () => signhostApiClient.GetTransaction("transaction Id"); getTransaction.ShouldThrow<ErrorHandling.NotFoundException>(); } }
public void when_GetTransaction_is_called_and_the_authorization_is_bad_then_we_should_get_a_BadAuthorizationException() { using (HttpTest httpTest = new HttpTest()) { httpTest.RespondWithJson(401, new { message = "unauthorized" }); var signhostApiClient = new SignHostApiClient(settings); Func<Task> getTransaction = () => signhostApiClient.GetTransaction("transaction Id"); getTransaction.ShouldThrow<UnauthorizedAccessException>(); } }
public void when_GetTransaction_is_called_and_unkownerror_like_418_occures_then_we_should_get_a_SignhostException() { using (HttpTest httpTest = new HttpTest()) { httpTest.RespondWithJson(418, new { message = "418 I'm a teapot" }); var signhostApiClient = new SignHostApiClient(settings); Func<Task> getTransaction = () => signhostApiClient.GetTransaction("transaction Id"); getTransaction.ShouldThrow<ErrorHandling.SignhostRestApiClientException>() .WithMessage("*418*"); } }
public async Task when_a_GetTransaction_is_called_then_we_should_have_called_the_transaction_get_once() { using (HttpTest httpTest = new HttpTest()) { httpTest.RespondWith(200, APIResponses.GetTransaction); var signhostApiClient = new SignHostApiClient(settings); var result = await signhostApiClient.GetTransaction("transaction Id"); result.Id.Should().Be("c487be92-0255-40c7-bd7d-20805a65e7d9"); httpTest.ShouldHaveCalled($"{settings.Endpoint}transaction/*") .WithVerb(HttpMethod.Get) .Times(1); } }
public void when_GetTransaction_is_called_and_there_is_an_InternalServerError_then_we_should_get_a_InternalServerErrorException() { using (HttpTest httpTest = new HttpTest()) { httpTest.RespondWithJson(500, new { message = "Internal Server Error" }); var signhostApiClient = new SignHostApiClient(settings); Func<Task> getTransaction = () => signhostApiClient.GetTransaction("transaction Id"); getTransaction.ShouldThrow<ErrorHandling.InternalServerErrorException>(); } }
public void when_a_function_is_called_with_a_wrong_endpoint_we_should_get_a_SignhostRestApiClientException() { using (HttpTest httpTest = new HttpTest()) { httpTest.RespondWithJson(502, new { message = "Bad Gateway" }); var signhostApiClient = new SignHostApiClient(settings); Func<Task> getTransaction = () => signhostApiClient.GetTransaction("transaction Id"); getTransaction.ShouldThrow<ErrorHandling.SignhostRestApiClientException>(); } }