From a3011297ca0ceb0978bd20f26140c04300465771 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Wed, 28 Aug 2024 21:51:57 +0300 Subject: [PATCH] Adds Data Access Layer integration tests --- .../Common/Factory/RepositoryFactoryTests.cs | 25 +++++++++++++ .../Core/UoW/UnitOfWorkTests.cs | 32 ++++++++++++++++ .../Lumina.DataAccess.IntegrationTests.csproj | 37 +++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/Repositories/Common/Factory/RepositoryFactoryTests.cs create mode 100644 tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/UoW/UnitOfWorkTests.cs create mode 100644 tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Lumina.DataAccess.IntegrationTests.csproj diff --git a/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/Repositories/Common/Factory/RepositoryFactoryTests.cs b/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/Repositories/Common/Factory/RepositoryFactoryTests.cs new file mode 100644 index 00000000..1382c3d0 --- /dev/null +++ b/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/Repositories/Common/Factory/RepositoryFactoryTests.cs @@ -0,0 +1,25 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.DataAccess.Core.Repositories.Common.Factory; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.DataAccess.IntegrationTests.Core.Repositories.Common.Factory; + +/// +/// Contains integration tests for the class. +/// +[ExcludeFromCodeCoverage] +public class RepositoryFactoryTests +{ + #region ===================================================================== METHODS =================================================================================== + [Fact] + public void RepositoryFactoryImplementsRepositoryFactoryInterface_InterfaceIsImplemented_ReturnsTrue() + { + // Arrange + var repositoryFactory = new RepositoryFactory(null!); + + // Assert + Assert.True(repositoryFactory is IRepositoryFactory); + } + #endregion +} diff --git a/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/UoW/UnitOfWorkTests.cs b/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/UoW/UnitOfWorkTests.cs new file mode 100644 index 00000000..4245457b --- /dev/null +++ b/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/UoW/UnitOfWorkTests.cs @@ -0,0 +1,32 @@ + +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Common.DataAccess.UoW; +using Lumina.DataAccess.Common.DependencyInjection; +using Lumina.DataAccess.Core.UoW; +using Microsoft.Extensions.DependencyInjection; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.DataAccess.IntegrationTests.Core.UoW; + +/// +/// Contains integration tests for the class. +/// +[ExcludeFromCodeCoverage] +public class UnitOfWorkTests +{ + #region ===================================================================== METHODS =================================================================================== + [Fact] + public void UnitOfWorkImplementsUnitOfWorkInterface_InterfaceIsImplemented_ReturnsTrue() + { + // Arrange + var services = new ServiceCollection(); + DataAccessLayerServices.AddDataAccessLayerServices(services); + var serviceProvider = services.BuildServiceProvider(); + var unitOfWork = (UnitOfWork)serviceProvider.GetRequiredService(); + + // Assert + Assert.True(unitOfWork is IUnitOfWork); + } + #endregion +} \ No newline at end of file diff --git a/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Lumina.DataAccess.IntegrationTests.csproj b/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Lumina.DataAccess.IntegrationTests.csproj new file mode 100644 index 00000000..e134d618 --- /dev/null +++ b/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Lumina.DataAccess.IntegrationTests.csproj @@ -0,0 +1,37 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + +