Browse Source

Create PaymentRequestAppService_Tests

pull/69/head
Halil İbrahim Kalkan 5 years ago
parent
commit
436ea8dac6
  1. 1
      modules/payment/src/Payment.Domain.Shared/PaymentRequests/PaymentRequestConsts.cs
  2. 3
      modules/payment/src/Payment.EntityFrameworkCore/EntityFrameworkCore/PaymentDbContextModelCreatingExtensions.cs
  3. 33
      modules/payment/test/Payment.Application.Tests/PaymentRequests/PaymentRequestAppService_Tests.cs

1
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;
}

3
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);

33
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<IPaymentRequestAppService>();
}
[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");
}
}
}
Loading…
Cancel
Save