From 38ff3e5503d6c62c4000e812c96ede2325169d48 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 20 Oct 2021 15:30:26 +0300 Subject: [PATCH] Add test for default currency of PaymentRequestAppService --- .../src/Payment.Domain/PaymentOptions.cs | 2 +- .../PaymentRequestAppService_Tests.cs | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/payment/src/Payment.Domain/PaymentOptions.cs b/modules/payment/src/Payment.Domain/PaymentOptions.cs index bf069b0..5691c6b 100644 --- a/modules/payment/src/Payment.Domain/PaymentOptions.cs +++ b/modules/payment/src/Payment.Domain/PaymentOptions.cs @@ -2,6 +2,6 @@ { public class PaymentOptions { - public string DefaultCurrency { get; set; } + public string DefaultCurrency { get; set; } = "USD" } } diff --git a/modules/payment/test/Payment.Application.Tests/PaymentRequests/PaymentRequestAppService_Tests.cs b/modules/payment/test/Payment.Application.Tests/PaymentRequests/PaymentRequestAppService_Tests.cs index 361716f..f52372a 100644 --- a/modules/payment/test/Payment.Application.Tests/PaymentRequests/PaymentRequestAppService_Tests.cs +++ b/modules/payment/test/Payment.Application.Tests/PaymentRequests/PaymentRequestAppService_Tests.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Microsoft.Extensions.Options; using Shouldly; using Xunit; @@ -24,10 +25,24 @@ namespace Payment.PaymentRequests Price = 99.99m } ); - + result.Id.ShouldNotBe(Guid.Empty); result.Price.ShouldBe(99.99m); result.ProductName.ShouldBe("My product 1"); } + + [Fact] + public async Task Should_Create_Payment_Request_With_Default_Currency() + { + var result = await _paymentRequestAppService.CreateAsync(new PaymentRequestCreationDto + { + Price = 4.95m, + ProductName = "Donation" + }); + + var options = GetRequiredService>(); + + result.Currency.ShouldBe(options.Value.DefaultCurrency); + } } } \ No newline at end of file