Loading BusinessLayer.Tests/BusinessLayer.Tests.csproj +1 −0 Original line number Original line Diff line number Diff line Loading @@ -12,6 +12,7 @@ <ItemGroup> <ItemGroup> <PackageReference Include="coverlet.collector" Version="6.0.0"/> <PackageReference Include="coverlet.collector" Version="6.0.0"/> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/> <PackageReference Include="Moq" Version="4.20.72" /> <PackageReference Include="xunit" Version="2.9.2" /> <PackageReference Include="xunit" Version="2.9.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> </ItemGroup> </ItemGroup> Loading BusinessLayer.Tests/Services/AuditTrailServiceTests.cs +0 −1 Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,6 @@ using BusinessLayer.Services; using BusinessLayer.Services.Interfaces; using BusinessLayer.Services.Interfaces; using Commons.Enums; using Commons.Enums; using Infrastructure.Repositories; using Infrastructure.Repositories; using JuiceWorld.Data; using JuiceWorld.Entities; using JuiceWorld.Entities; using JuiceWorld.QueryObjects; using JuiceWorld.QueryObjects; using JuiceWorld.Repositories; using JuiceWorld.Repositories; Loading BusinessLayer.Tests/Services/CartItemServiceTests.cs +11 −7 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,8 @@ using BusinessLayer.Services; using BusinessLayer.Services.Interfaces; using BusinessLayer.Services.Interfaces; using JuiceWorld.Entities; using JuiceWorld.Entities; using JuiceWorld.Repositories; using JuiceWorld.Repositories; using JuiceWorld.UnitOfWork; using Microsoft.Extensions.Caching.Memory; using TestUtilities.MockedObjects; using TestUtilities.MockedObjects; using Xunit; using Xunit; using Assert = Xunit.Assert; using Assert = Xunit.Assert; Loading @@ -13,7 +15,7 @@ namespace BusinessLayer.Tests.Services; public class CartItemServiceTests public class CartItemServiceTests { { private ICartItemService _crtItemService; private ICartItemService _cartItemService; public CartItemServiceTests() public CartItemServiceTests() { { Loading @@ -22,7 +24,9 @@ public class CartItemServiceTests var crtItemRepository = new Repository<CartItem>(dbContext); var crtItemRepository = new Repository<CartItem>(dbContext); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var mapper = config.CreateMapper(); var mapper = config.CreateMapper(); _crtItemService = new CartItemService(crtItemRepository, mapper); var orderUnitOfWork = new OrderUnitOfWork(dbContext); var memorycache = new MemoryCache(new MemoryCacheOptions()); _cartItemService = new CartItemService(crtItemRepository, orderUnitOfWork, memorycache, mapper); } } [Fact] [Fact] Loading @@ -32,7 +36,7 @@ public class CartItemServiceTests var crtItemIdsToRetrieve = new[] { 1, 2, 3, 4, 5 }; var crtItemIdsToRetrieve = new[] { 1, 2, 3, 4, 5 }; // Act // Act var result = await _crtItemService.GetAllCartItemsAsync(); var result = await _cartItemService.GetAllCartItemsAsync(); // Assert // Assert var crtItemDtos = result.ToList(); var crtItemDtos = result.ToList(); Loading @@ -47,7 +51,7 @@ public class CartItemServiceTests var crtItemId = 1; var crtItemId = 1; // Act // Act var result = await _crtItemService.GetCartItemByIdAsync(crtItemId); var result = await _cartItemService.GetCartItemByIdAsync(crtItemId); // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Loading @@ -67,7 +71,7 @@ public class CartItemServiceTests }; }; // Act // Act var result = await _crtItemService.CreateCartItemAsync(crtItem); var result = await _cartItemService.CreateCartItemAsync(crtItem); // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Loading @@ -88,7 +92,7 @@ public class CartItemServiceTests }; }; // Act // Act var result = await _crtItemService.UpdateCartItemAsync(crtItem); var result = await _cartItemService.UpdateCartItemAsync(crtItem); // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Loading @@ -103,7 +107,7 @@ public class CartItemServiceTests var crtItemId = 1; var crtItemId = 1; // Act // Act var result = await _crtItemService.DeleteCartItemByIdAsync(crtItemId); var result = await _cartItemService.DeleteCartItemByIdAsync(crtItemId); // Assert // Assert Assert.True(result); Assert.True(result); Loading BusinessLayer.Tests/Services/ManufactorerServiceTests.cs +5 −2 Original line number Original line Diff line number Diff line Loading @@ -3,9 +3,10 @@ using BusinessLayer.DTOs; using BusinessLayer.Installers; using BusinessLayer.Installers; using BusinessLayer.Services; using BusinessLayer.Services; using BusinessLayer.Services.Interfaces; using BusinessLayer.Services.Interfaces; using Commons.Enums; using JuiceWorld.Entities; using JuiceWorld.Entities; using JuiceWorld.QueryObjects; using JuiceWorld.Repositories; using JuiceWorld.Repositories; using Microsoft.Extensions.Caching.Memory; using TestUtilities.MockedObjects; using TestUtilities.MockedObjects; using Xunit; using Xunit; using Assert = Xunit.Assert; using Assert = Xunit.Assert; Loading @@ -23,7 +24,9 @@ public class ManufacturerServiceTests var manufacturerRepository = new Repository<Manufacturer>(dbContext); var manufacturerRepository = new Repository<Manufacturer>(dbContext); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var mapper = config.CreateMapper(); var mapper = config.CreateMapper(); _manufacturerService = new ManufacturerService(manufacturerRepository, mapper); var manufacturerQueryObject = new QueryObject<Manufacturer>(dbContext); var cache = new MemoryCache(new MemoryCacheOptions()); _manufacturerService = new ManufacturerService(manufacturerRepository, manufacturerQueryObject, cache, mapper); } } [Fact] [Fact] Loading BusinessLayer.Tests/Services/OrderServiceTests.cs +19 −5 Original line number Original line Diff line number Diff line Loading @@ -5,8 +5,10 @@ using BusinessLayer.Services; using BusinessLayer.Services.Interfaces; using BusinessLayer.Services.Interfaces; using Commons.Enums; using Commons.Enums; using JuiceWorld.Entities; using JuiceWorld.Entities; using JuiceWorld.QueryObjects; using JuiceWorld.Repositories; using JuiceWorld.Repositories; using JuiceWorld.UnitOfWork; using JuiceWorld.UnitOfWork; using Microsoft.Extensions.Caching.Memory; using TestUtilities.MockedObjects; using TestUtilities.MockedObjects; using Xunit; using Xunit; using Assert = Xunit.Assert; using Assert = Xunit.Assert; Loading @@ -25,7 +27,9 @@ public class OrderServiceTests var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var mapper = config.CreateMapper(); var mapper = config.CreateMapper(); var orderUnitOfWork = new OrderUnitOfWork(dbContext); var orderUnitOfWork = new OrderUnitOfWork(dbContext); _orderService = new OrderService(orderRepository, orderUnitOfWork, mapper); var orderQueryObject = new QueryObject<Order>(dbContext); var cache = new MemoryCache(new MemoryCacheOptions()); _orderService = new OrderService(orderRepository, orderQueryObject, orderUnitOfWork, cache, mapper); } } [Fact] [Fact] Loading Loading @@ -66,7 +70,12 @@ public class OrderServiceTests UserId = 1, UserId = 1, AddressId = 4, AddressId = 4, DeliveryType = DeliveryType.Express, DeliveryType = DeliveryType.Express, PaymentMethodType = PaymentMethodType.Monero PaymentMethodType = PaymentMethodType.Monero, City = "Miami", Street = "Ocean Drive", HouseNumber = "4", ZipCode = "33139", Country = "USA" }; }; // Act // Act Loading @@ -74,7 +83,7 @@ public class OrderServiceTests // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Assert.True(order.UserId == result.UserId && order.AddressId == result.AddressId && Assert.True(order.UserId == result.UserId && order.DeliveryType == result.DeliveryType && order.DeliveryType == result.DeliveryType && order.PaymentMethodType == result.PaymentMethodType); order.PaymentMethodType == result.PaymentMethodType); } } Loading @@ -90,7 +99,12 @@ public class OrderServiceTests AddressId = 4, AddressId = 4, Status = OrderStatus.Pending, Status = OrderStatus.Pending, DeliveryType = DeliveryType.Express, DeliveryType = DeliveryType.Express, PaymentMethodType = PaymentMethodType.Monero PaymentMethodType = PaymentMethodType.Monero, City = "Miami", Street = "Ocean Drive", HouseNumber = "4", ZipCode = "33139", Country = "USA" }; }; // Act // Act Loading @@ -98,7 +112,7 @@ public class OrderServiceTests // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Assert.True(order.Id == result.Id && order.UserId == result.UserId && order.AddressId == result.AddressId && Assert.True(order.Id == result.Id && order.UserId == result.UserId && order.Status == result.Status && order.DeliveryType == result.DeliveryType && order.Status == result.Status && order.DeliveryType == result.DeliveryType && order.PaymentMethodType == result.PaymentMethodType); order.PaymentMethodType == result.PaymentMethodType); } } Loading Loading
BusinessLayer.Tests/BusinessLayer.Tests.csproj +1 −0 Original line number Original line Diff line number Diff line Loading @@ -12,6 +12,7 @@ <ItemGroup> <ItemGroup> <PackageReference Include="coverlet.collector" Version="6.0.0"/> <PackageReference Include="coverlet.collector" Version="6.0.0"/> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/> <PackageReference Include="Moq" Version="4.20.72" /> <PackageReference Include="xunit" Version="2.9.2" /> <PackageReference Include="xunit" Version="2.9.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> </ItemGroup> </ItemGroup> Loading
BusinessLayer.Tests/Services/AuditTrailServiceTests.cs +0 −1 Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,6 @@ using BusinessLayer.Services; using BusinessLayer.Services.Interfaces; using BusinessLayer.Services.Interfaces; using Commons.Enums; using Commons.Enums; using Infrastructure.Repositories; using Infrastructure.Repositories; using JuiceWorld.Data; using JuiceWorld.Entities; using JuiceWorld.Entities; using JuiceWorld.QueryObjects; using JuiceWorld.QueryObjects; using JuiceWorld.Repositories; using JuiceWorld.Repositories; Loading
BusinessLayer.Tests/Services/CartItemServiceTests.cs +11 −7 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,8 @@ using BusinessLayer.Services; using BusinessLayer.Services.Interfaces; using BusinessLayer.Services.Interfaces; using JuiceWorld.Entities; using JuiceWorld.Entities; using JuiceWorld.Repositories; using JuiceWorld.Repositories; using JuiceWorld.UnitOfWork; using Microsoft.Extensions.Caching.Memory; using TestUtilities.MockedObjects; using TestUtilities.MockedObjects; using Xunit; using Xunit; using Assert = Xunit.Assert; using Assert = Xunit.Assert; Loading @@ -13,7 +15,7 @@ namespace BusinessLayer.Tests.Services; public class CartItemServiceTests public class CartItemServiceTests { { private ICartItemService _crtItemService; private ICartItemService _cartItemService; public CartItemServiceTests() public CartItemServiceTests() { { Loading @@ -22,7 +24,9 @@ public class CartItemServiceTests var crtItemRepository = new Repository<CartItem>(dbContext); var crtItemRepository = new Repository<CartItem>(dbContext); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var mapper = config.CreateMapper(); var mapper = config.CreateMapper(); _crtItemService = new CartItemService(crtItemRepository, mapper); var orderUnitOfWork = new OrderUnitOfWork(dbContext); var memorycache = new MemoryCache(new MemoryCacheOptions()); _cartItemService = new CartItemService(crtItemRepository, orderUnitOfWork, memorycache, mapper); } } [Fact] [Fact] Loading @@ -32,7 +36,7 @@ public class CartItemServiceTests var crtItemIdsToRetrieve = new[] { 1, 2, 3, 4, 5 }; var crtItemIdsToRetrieve = new[] { 1, 2, 3, 4, 5 }; // Act // Act var result = await _crtItemService.GetAllCartItemsAsync(); var result = await _cartItemService.GetAllCartItemsAsync(); // Assert // Assert var crtItemDtos = result.ToList(); var crtItemDtos = result.ToList(); Loading @@ -47,7 +51,7 @@ public class CartItemServiceTests var crtItemId = 1; var crtItemId = 1; // Act // Act var result = await _crtItemService.GetCartItemByIdAsync(crtItemId); var result = await _cartItemService.GetCartItemByIdAsync(crtItemId); // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Loading @@ -67,7 +71,7 @@ public class CartItemServiceTests }; }; // Act // Act var result = await _crtItemService.CreateCartItemAsync(crtItem); var result = await _cartItemService.CreateCartItemAsync(crtItem); // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Loading @@ -88,7 +92,7 @@ public class CartItemServiceTests }; }; // Act // Act var result = await _crtItemService.UpdateCartItemAsync(crtItem); var result = await _cartItemService.UpdateCartItemAsync(crtItem); // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Loading @@ -103,7 +107,7 @@ public class CartItemServiceTests var crtItemId = 1; var crtItemId = 1; // Act // Act var result = await _crtItemService.DeleteCartItemByIdAsync(crtItemId); var result = await _cartItemService.DeleteCartItemByIdAsync(crtItemId); // Assert // Assert Assert.True(result); Assert.True(result); Loading
BusinessLayer.Tests/Services/ManufactorerServiceTests.cs +5 −2 Original line number Original line Diff line number Diff line Loading @@ -3,9 +3,10 @@ using BusinessLayer.DTOs; using BusinessLayer.Installers; using BusinessLayer.Installers; using BusinessLayer.Services; using BusinessLayer.Services; using BusinessLayer.Services.Interfaces; using BusinessLayer.Services.Interfaces; using Commons.Enums; using JuiceWorld.Entities; using JuiceWorld.Entities; using JuiceWorld.QueryObjects; using JuiceWorld.Repositories; using JuiceWorld.Repositories; using Microsoft.Extensions.Caching.Memory; using TestUtilities.MockedObjects; using TestUtilities.MockedObjects; using Xunit; using Xunit; using Assert = Xunit.Assert; using Assert = Xunit.Assert; Loading @@ -23,7 +24,9 @@ public class ManufacturerServiceTests var manufacturerRepository = new Repository<Manufacturer>(dbContext); var manufacturerRepository = new Repository<Manufacturer>(dbContext); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var mapper = config.CreateMapper(); var mapper = config.CreateMapper(); _manufacturerService = new ManufacturerService(manufacturerRepository, mapper); var manufacturerQueryObject = new QueryObject<Manufacturer>(dbContext); var cache = new MemoryCache(new MemoryCacheOptions()); _manufacturerService = new ManufacturerService(manufacturerRepository, manufacturerQueryObject, cache, mapper); } } [Fact] [Fact] Loading
BusinessLayer.Tests/Services/OrderServiceTests.cs +19 −5 Original line number Original line Diff line number Diff line Loading @@ -5,8 +5,10 @@ using BusinessLayer.Services; using BusinessLayer.Services.Interfaces; using BusinessLayer.Services.Interfaces; using Commons.Enums; using Commons.Enums; using JuiceWorld.Entities; using JuiceWorld.Entities; using JuiceWorld.QueryObjects; using JuiceWorld.Repositories; using JuiceWorld.Repositories; using JuiceWorld.UnitOfWork; using JuiceWorld.UnitOfWork; using Microsoft.Extensions.Caching.Memory; using TestUtilities.MockedObjects; using TestUtilities.MockedObjects; using Xunit; using Xunit; using Assert = Xunit.Assert; using Assert = Xunit.Assert; Loading @@ -25,7 +27,9 @@ public class OrderServiceTests var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var config = new MapperConfiguration(cfg => cfg.AddProfile<MapperProfileInstaller>()); var mapper = config.CreateMapper(); var mapper = config.CreateMapper(); var orderUnitOfWork = new OrderUnitOfWork(dbContext); var orderUnitOfWork = new OrderUnitOfWork(dbContext); _orderService = new OrderService(orderRepository, orderUnitOfWork, mapper); var orderQueryObject = new QueryObject<Order>(dbContext); var cache = new MemoryCache(new MemoryCacheOptions()); _orderService = new OrderService(orderRepository, orderQueryObject, orderUnitOfWork, cache, mapper); } } [Fact] [Fact] Loading Loading @@ -66,7 +70,12 @@ public class OrderServiceTests UserId = 1, UserId = 1, AddressId = 4, AddressId = 4, DeliveryType = DeliveryType.Express, DeliveryType = DeliveryType.Express, PaymentMethodType = PaymentMethodType.Monero PaymentMethodType = PaymentMethodType.Monero, City = "Miami", Street = "Ocean Drive", HouseNumber = "4", ZipCode = "33139", Country = "USA" }; }; // Act // Act Loading @@ -74,7 +83,7 @@ public class OrderServiceTests // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Assert.True(order.UserId == result.UserId && order.AddressId == result.AddressId && Assert.True(order.UserId == result.UserId && order.DeliveryType == result.DeliveryType && order.DeliveryType == result.DeliveryType && order.PaymentMethodType == result.PaymentMethodType); order.PaymentMethodType == result.PaymentMethodType); } } Loading @@ -90,7 +99,12 @@ public class OrderServiceTests AddressId = 4, AddressId = 4, Status = OrderStatus.Pending, Status = OrderStatus.Pending, DeliveryType = DeliveryType.Express, DeliveryType = DeliveryType.Express, PaymentMethodType = PaymentMethodType.Monero PaymentMethodType = PaymentMethodType.Monero, City = "Miami", Street = "Ocean Drive", HouseNumber = "4", ZipCode = "33139", Country = "USA" }; }; // Act // Act Loading @@ -98,7 +112,7 @@ public class OrderServiceTests // Assert // Assert Assert.NotNull(result); Assert.NotNull(result); Assert.True(order.Id == result.Id && order.UserId == result.UserId && order.AddressId == result.AddressId && Assert.True(order.Id == result.Id && order.UserId == result.UserId && order.Status == result.Status && order.DeliveryType == result.DeliveryType && order.Status == result.Status && order.DeliveryType == result.DeliveryType && order.PaymentMethodType == result.PaymentMethodType); order.PaymentMethodType == result.PaymentMethodType); } } Loading