-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test to create a payment method specific type
- Loading branch information
1 parent
855bc11
commit e4996ac
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
tests/Mollie.Tests.Unit/Models/Payment/Request/PaymentRequestTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Mollie.Api.Models; | ||
using Mollie.Api.Models.Payment; | ||
using Mollie.Api.Models.Payment.Request; | ||
using Mollie.Api.Models.Payment.Request.PaymentSpecificParameters; | ||
using Xunit; | ||
|
||
namespace Mollie.Tests.Unit.Models.Payment.Request; | ||
|
||
public class PaymentRequestTests { | ||
[Theory] | ||
[InlineData(PaymentMethod.CreditCard, typeof(CreditCardPaymentRequest))] | ||
[InlineData(PaymentMethod.Ideal, typeof(IdealPaymentRequest))] | ||
public void CreatePaymentRequest(string paymentMethod, Type expectedType) { | ||
var amount = new Amount(Currency.EUR, 50m); | ||
var description = "my-description"; | ||
var paymentRequest = new PaymentRequest() { | ||
Amount = amount, | ||
Description = description | ||
}; | ||
switch (paymentMethod) { | ||
case PaymentMethod.CreditCard: | ||
paymentRequest = new CreditCardPaymentRequest(paymentRequest) { | ||
CardToken = "card-token" | ||
}; | ||
break; | ||
case PaymentMethod.Ideal: | ||
paymentRequest = new IdealPaymentRequest(paymentRequest) { | ||
Issuer = "ideal_issuer" | ||
}; | ||
break; | ||
} | ||
|
||
paymentRequest.Should().BeOfType(expectedType); | ||
paymentRequest.Amount.Should().Be(amount); | ||
paymentRequest.Description.Should().Be(description); | ||
} | ||
} |