private DeleteChargeAction GivenAnDeleteChargeActionMock() { DeleteChargeAction action = Substitute.For <DeleteChargeAction>(new object[] { null }); ActionsFactoryMock.CreateDeleteChargeAction(action); return(action); }
private async Task VerifyResult(DeleteChargeAction action, HttpResponseMessage result, string messageException) { result.StatusCode.Should().Be(HttpStatusCode.BadRequest); var errorMessage = result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); errorMessage.Should().Be(messageException); await action.Received(1).Execute(identifier); }
public async Task given_an_idenfier_for_delete_charge_and_dont_exist_we_obtein_a_false_response() { clientChargeRepository.DeleteCharge(identifier).Returns(false); var deleteChargeAction = new DeleteChargeAction(clientChargeRepository); var result = await deleteChargeAction.Execute(identifier); result.Should().Be(false); await clientChargeRepository.Received(1).DeleteCharge(identifier); }
public async Task given_an_identifier_try_delete_not_exist_charge_return_not_found_response() { var requestUri = string.Format("http://localhost:10000/api/charges/charge/{0}", identifier); DeleteChargeAction action = GivenAnDeleteChargeActionMock(); action.Execute(Arg.Any <string>()).Returns(false); var result = await client.DeleteAsync(requestUri); result.StatusCode.Should().Be(HttpStatusCode.NotFound); await action.Received(1).Execute(identifier); }
public async Task given_an_identifier_try_delete_and_have_anyproblem_return_badrequest_response() { var requestUri = string.Format("http://localhost:10000/api/charges/charge/{0}", identifier); DeleteChargeAction action = GivenAnDeleteChargeActionMock(); string messageException = "any message exception"; ReturnsExceptionFor(action, messageException); var result = await client.DeleteAsync(requestUri); await VerifyResult(action, result, messageException); }
internal static void CreateDeleteChargeAction(DeleteChargeAction action) { Instance.CreateDeleteChargeAction().Returns(action); }
private static void ReturnsExceptionFor(DeleteChargeAction action, string messageException) { action.Execute(Arg.Any <string>()).Throws(new ChargesException(messageException)); }