From 07a71a4d75b57906fd08d1d1f484be01eb14fbfd Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 6 Jan 2022 15:34:03 +0300 Subject: [PATCH] updated repository tests --- .../Orders/OrderRepository_Tests.cs | 14 +++++++++-- .../Samples/SampleRepository_Tests.cs | 12 --------- .../OrderingServiceTestDataSeedContributor.cs | 25 ++++++++++++++++--- .../TestData.cs | 3 +++ 4 files changed, 37 insertions(+), 17 deletions(-) delete mode 100644 services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs diff --git a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Orders/OrderRepository_Tests.cs b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Orders/OrderRepository_Tests.cs index 77b9375f..e16d6194 100644 --- a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Orders/OrderRepository_Tests.cs +++ b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Orders/OrderRepository_Tests.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Linq; +using System.Threading.Tasks; using EShopOnAbp.OrderingService.Orders; using EShopOnAbp.OrderingService.Orders.Specifications; using EShopOnAbp.OrderingService.Samples; @@ -34,6 +35,15 @@ public class OrderRepository_Tests : SampleRepository_Tests - { - /* Don't write custom repository tests here, instead write to - * the base class. - * One exception can be some specific tests related to EF core. - */ - } -} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestDataSeedContributor.cs b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestDataSeedContributor.cs index df59b49b..4b2e3aa3 100644 --- a/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestDataSeedContributor.cs +++ b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestDataSeedContributor.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using EShopOnAbp.OrderingService.Orders; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; @@ -28,7 +29,7 @@ namespace EShopOnAbp.OrderingService private async Task SeedTestOrdersAsync() { - var order1 = await _orderManager.CreateOrderAsync( + await _orderManager.CreateOrderAsync( 1, _testData.CurrentUserId, _testData.CurrentUserName, @@ -40,7 +41,7 @@ namespace EShopOnAbp.OrderingService _testData.Address.ZipCode ); - var order2 = await _orderManager.CreateOrderAsync( + await _orderManager.CreateOrderAsync( 1, _testData.CurrentUserId, _testData.CurrentUserName, _testData.CurrentUserEmail, _testProducts.GetRandomProducts(10), _testData.Address.Street, @@ -48,6 +49,24 @@ namespace EShopOnAbp.OrderingService _testData.Address.Country, _testData.Address.ZipCode ); + + await _orderManager.CreateOrderAsync( + 1, _testData.CurrentUserId, _testData.CurrentUserName, _testData.CurrentUserEmail, + _testProducts.GetRandomProducts(2), + _testData.Address.Street, + _testData.Address.City, + _testData.Address.Country, + _testData.Address.ZipCode + ); + + await _orderManager.CreateOrderAsync( + 1, _testData.TestUserId, _testData.TestUserName, _testData.TestUserEmail, + _testProducts.GetRandomProducts(7), + _testData.Address.Street, + _testData.Address.City, + _testData.Address.Country, + _testData.Address.ZipCode + ); } } } \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.TestBase/TestData.cs b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/TestData.cs index fd9a164b..506dd5e7 100644 --- a/services/ordering/test/EShopOnAbp.OrderingService.TestBase/TestData.cs +++ b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/TestData.cs @@ -8,6 +8,9 @@ public class TestData : ISingletonDependency public string CurrentUserEmail { get; set; } = "galip.erdem@volosoft.com"; public Guid CurrentUserId { get; set; } = Guid.NewGuid(); public string CurrentUserName { get; set; } = "Galip T. ERDEM"; + public Guid TestUserId { get; set; } = Guid.NewGuid(); + public string TestUserEmail { get; set; } = "test@user.com"; + public string TestUserName { get; set; } = "Test User"; public DemoAddress Address { get; set; } = new DemoAddress(); public class DemoAddress