From 436ea8dac6e46953c074a3806332fdecf09ded5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 7 Oct 2021 15:39:14 +0300 Subject: [PATCH] Create PaymentRequestAppService_Tests --- .../PaymentRequests/PaymentRequestConsts.cs | 1 + ...PaymentDbContextModelCreatingExtensions.cs | 3 +- .../PaymentRequestAppService_Tests.cs | 33 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 modules/payment/test/Payment.Application.Tests/PaymentRequests/PaymentRequestAppService_Tests.cs diff --git a/modules/payment/src/Payment.Domain.Shared/PaymentRequests/PaymentRequestConsts.cs b/modules/payment/src/Payment.Domain.Shared/PaymentRequests/PaymentRequestConsts.cs index 02574dc..bd3a2a7 100644 --- a/modules/payment/src/Payment.Domain.Shared/PaymentRequests/PaymentRequestConsts.cs +++ b/modules/payment/src/Payment.Domain.Shared/PaymentRequests/PaymentRequestConsts.cs @@ -2,6 +2,7 @@ { public static class PaymentRequestConsts { + public const int MaxCustomerIdLength = 100; public const int MaxProductIdLength = 100; public const int MaxProductNameLength = 200; } diff --git a/modules/payment/src/Payment.EntityFrameworkCore/EntityFrameworkCore/PaymentDbContextModelCreatingExtensions.cs b/modules/payment/src/Payment.EntityFrameworkCore/EntityFrameworkCore/PaymentDbContextModelCreatingExtensions.cs index 512724e..ef9b081 100644 --- a/modules/payment/src/Payment.EntityFrameworkCore/EntityFrameworkCore/PaymentDbContextModelCreatingExtensions.cs +++ b/modules/payment/src/Payment.EntityFrameworkCore/EntityFrameworkCore/PaymentDbContextModelCreatingExtensions.cs @@ -16,8 +16,9 @@ namespace Payment.EntityFrameworkCore { b.ToTable(PaymentDbProperties.DbTablePrefix + "PaymentRequests", PaymentDbProperties.DbSchema); b.ConfigureByConvention(); + b.Property(x => x.CustomerId).HasMaxLength(PaymentRequestConsts.MaxCustomerIdLength); + b.Property(x => x.ProductId).HasMaxLength(PaymentRequestConsts.MaxProductIdLength); b.Property(x => x.ProductName).IsRequired().HasMaxLength(PaymentRequestConsts.MaxProductNameLength); - b.Property(x => x.ProductId).IsRequired().HasMaxLength(PaymentRequestConsts.MaxProductIdLength); b.HasIndex(x => x.CustomerId); b.HasIndex(x => x.State); diff --git a/modules/payment/test/Payment.Application.Tests/PaymentRequests/PaymentRequestAppService_Tests.cs b/modules/payment/test/Payment.Application.Tests/PaymentRequests/PaymentRequestAppService_Tests.cs new file mode 100644 index 0000000..0a5bb3e --- /dev/null +++ b/modules/payment/test/Payment.Application.Tests/PaymentRequests/PaymentRequestAppService_Tests.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading.Tasks; +using Shouldly; +using Xunit; + +namespace Payment.PaymentRequests +{ + public class PaymentRequestAppService_Tests : PaymentApplicationTestBase + { + private readonly IPaymentRequestAppService _paymentRequestAppService; + + public PaymentRequestAppService_Tests() + { + _paymentRequestAppService = GetRequiredService(); + } + + [Fact] + public async Task Should_Create_Minimal_Payment_Request() + { + var result = await _paymentRequestAppService.CreateAsync( + new PaymentRequestCreationDto + { + ProductName = "My product 1", + Amount = 99.99m + } + ); + + result.Id.ShouldNotBe(Guid.Empty); + result.Amount.ShouldBe(99.99m); + result.ProductName.ShouldBe("My product 1"); + } + } +} \ No newline at end of file