public void And_Card_Is_Badly_Formed_Then_Validation_Returns_InvalidPayment( string number, int month, int year, string cvv ) { var(request, validator) = PaymentInitialiser.InitialiseRequest(number, month, year, 0.99m); validator.Validate(request, asOf).ShouldBeOfType <InvalidPayment>(); }
public async Task When_MakePayment_Then_ResponseIsUnsuccessful() { var(request, _) = PaymentInitialiser.InitialiseRequest("4485920504392908", 5, 2024, 199.99m); IBank bank = Substitute.For <IBank>(); bank .When(b => b.CreatePayment(Arg.Is <Payment>(p => p.Amount > 100m))) .Do(b => { throw ApiException.Create(Substitute.For <HttpRequestMessage>(), HttpMethod.Post, Substitute.For <HttpResponseMessage>(), Substitute.For <RefitSettings>()).Result; }); var service = new PaymentService(bank); var response = await service.MakePayment(new Payment { Amount = 199.99m }, request.Card); response.Rejected.ShouldBeTrue(); }