public void when_CreateTransaction_is_called_with_invalid_email_then_we_should_get_a_BadRequestException() { using (HttpTest httpTest = new HttpTest()) { httpTest.RespondWithJson(400, new { message = "Bad Request" }); var signhostApiClient = new SignHostApiClient(settings); Signer testSigner = new Signer(); testSigner.Email = "firstname.lastnamegmail.com"; Transaction testTransaction = new Transaction(); testTransaction.Signers.Add(testSigner); Func<Task> getTransaction = () => signhostApiClient.CreateTransaction(testTransaction); getTransaction.ShouldThrow<ErrorHandling.BadRequestException>(); httpTest.ShouldHaveCalled($"{settings.Endpoint}transaction") .WithVerb(HttpMethod.Post) .WithContentType("application/json") .Times(1); } }
public async Task when_a_CreateTransaction_is_called_then_we_should_have_called_the_transaction_Post_once() { using (HttpTest httpTest = new HttpTest()) { httpTest.RespondWith(200, APIResponses.AddTransaction); var signhostApiClient = new SignHostApiClient(settings); Signer testSigner = new Signer(); testSigner.Email = "*****@*****.**"; Transaction testTransaction = new Transaction(); testTransaction.Signers.Add(testSigner); var result = await signhostApiClient.CreateTransaction(testTransaction); result.Id.Should().Be("c487be92-0255-40c7-bd7d-20805a65e7d9"); httpTest.ShouldHaveCalled($"{settings.Endpoint}transaction") .WithVerb(HttpMethod.Post) .WithContentType("application/json") .Times(1); } }