From 17ce5ca0330bbd5d00d034417a8c5e64d07f64ed Mon Sep 17 00:00:00 2001 From: PureJoyMind Date: Mon, 15 Sep 2025 01:44:47 +0330 Subject: [PATCH 1/4] test: Added Packages for test projects to Directory.Packages.props --- Directory.Packages.props | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Directory.Packages.props b/Directory.Packages.props index e027d8f..edcb29c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -21,5 +21,15 @@ + + + + + + + + + + From d9e7277ff99774ddf5c8041c52bccfb4dec09965 Mon Sep 17 00:00:00 2001 From: PureJoyMind Date: Mon, 15 Sep 2025 01:46:15 +0330 Subject: [PATCH 2/4] test: Added unit test project for FastCrud.Core project in test folder --- FastCrud.sln | 17 +++++++++++ .../FastCrud.Core.Tests.Unit.csproj | 28 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/FastCrud.Core.Tests.Unit/FastCrud.Core.Tests.Unit.csproj diff --git a/FastCrud.sln b/FastCrud.sln index 50ed60e..85badd6 100644 --- a/FastCrud.sln +++ b/FastCrud.sln @@ -32,6 +32,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CF0D1A6D-895C-4E47-8FF1-A4C7EE067309}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCrud.Core.Tests.Unit", "test\FastCrud.Core.Tests.Unit\FastCrud.Core.Tests.Unit.csproj", "{B1378196-FC23-4177-96F7-7A9672A521B9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -138,6 +142,18 @@ Global {76A2E96E-A92C-4D05-A65D-1D3DCBC8546D}.Release|x64.Build.0 = Release|Any CPU {76A2E96E-A92C-4D05-A65D-1D3DCBC8546D}.Release|x86.ActiveCfg = Release|Any CPU {76A2E96E-A92C-4D05-A65D-1D3DCBC8546D}.Release|x86.Build.0 = Release|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Debug|x64.ActiveCfg = Debug|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Debug|x64.Build.0 = Debug|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Debug|x86.ActiveCfg = Debug|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Debug|x86.Build.0 = Debug|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Release|Any CPU.Build.0 = Release|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Release|x64.ActiveCfg = Release|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Release|x64.Build.0 = Release|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Release|x86.ActiveCfg = Release|Any CPU + {B1378196-FC23-4177-96F7-7A9672A521B9}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -152,5 +168,6 @@ Global {20DCAE37-FAA8-4DB2-9756-5EB3D307843A} = {A86BA826-473E-B95F-3AC8-6831E1DD27DB} {D88FAE2D-7768-4566-8447-AD9C5C56EC45} = {A86BA826-473E-B95F-3AC8-6831E1DD27DB} {76A2E96E-A92C-4D05-A65D-1D3DCBC8546D} = {5D20AA90-6969-D8BD-9DCD-8634F4692FDA} + {B1378196-FC23-4177-96F7-7A9672A521B9} = {CF0D1A6D-895C-4E47-8FF1-A4C7EE067309} EndGlobalSection EndGlobal diff --git a/test/FastCrud.Core.Tests.Unit/FastCrud.Core.Tests.Unit.csproj b/test/FastCrud.Core.Tests.Unit/FastCrud.Core.Tests.Unit.csproj new file mode 100644 index 0000000..3135348 --- /dev/null +++ b/test/FastCrud.Core.Tests.Unit/FastCrud.Core.Tests.Unit.csproj @@ -0,0 +1,28 @@ + + + + net9.0 + enable + enable + false + + + + + + + + + + + + + + + + + + + + + From 397e520e4b3f4b94d7b1c50e9f86d722cc54166b Mon Sep 17 00:00:00 2001 From: PureJoyMind Date: Mon, 15 Sep 2025 01:47:13 +0330 Subject: [PATCH 3/4] test: Added test models and dtos for Customer --- .../Dtos/TestCustomerDtos.cs | 7 +++++++ .../FastCrud.Core.Tests.Unit/Models/TestCustomer.cs | 13 +++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/FastCrud.Core.Tests.Unit/Dtos/TestCustomerDtos.cs create mode 100644 test/FastCrud.Core.Tests.Unit/Models/TestCustomer.cs diff --git a/test/FastCrud.Core.Tests.Unit/Dtos/TestCustomerDtos.cs b/test/FastCrud.Core.Tests.Unit/Dtos/TestCustomerDtos.cs new file mode 100644 index 0000000..9988c76 --- /dev/null +++ b/test/FastCrud.Core.Tests.Unit/Dtos/TestCustomerDtos.cs @@ -0,0 +1,7 @@ +namespace FastCrud.Core.Tests.Unit.Dtos; + +public record TestCustomerCreateDto(string FirstName, string LastName, string Email); + +public record TestCustomerUpdateDto(string FirstName, string LastName, string Email); + +public record TestCustomerReadDto(Guid Id, string FirstName, string LastName, string Email); diff --git a/test/FastCrud.Core.Tests.Unit/Models/TestCustomer.cs b/test/FastCrud.Core.Tests.Unit/Models/TestCustomer.cs new file mode 100644 index 0000000..02c2965 --- /dev/null +++ b/test/FastCrud.Core.Tests.Unit/Models/TestCustomer.cs @@ -0,0 +1,13 @@ +namespace FastCrud.Core.Tests.Unit.Models; + +public sealed class TestCustomer +{ + // private Customer() + // {} + + public Guid Id { get; private set; } + public string FirstName { get; private set; } + public string LastName { get; private set; } + public string Email { get; private set; } + public DateTime CreatedUtc { get; private set; } +} \ No newline at end of file From dc878bb4dc7b9ce5c9bcf418dea5a4c71d1433c1 Mon Sep 17 00:00:00 2001 From: PureJoyMind Date: Mon, 15 Sep 2025 01:48:06 +0330 Subject: [PATCH 4/4] test: Added CreateTests class for CrudService CreateAsync method tests --- test/FastCrud.Core.Tests.Unit/CreateTests.cs | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/FastCrud.Core.Tests.Unit/CreateTests.cs diff --git a/test/FastCrud.Core.Tests.Unit/CreateTests.cs b/test/FastCrud.Core.Tests.Unit/CreateTests.cs new file mode 100644 index 0000000..e7caa5a --- /dev/null +++ b/test/FastCrud.Core.Tests.Unit/CreateTests.cs @@ -0,0 +1,39 @@ +using FastCrud.Abstractions.Abstractions; +using FastCrud.Abstractions.Query; +using FastCrud.Core.Services; +using FastCrud.Core.Tests.Unit.Dtos; +using FastCrud.Core.Tests.Unit.Models; +using NSubstitute; + +namespace FastCrud.Core.Tests.Unit; + +public class CreateTests +{ + // Service Under Test + private readonly CrudService _service; + + // Dependencies + private readonly IRepository _repository + = Substitute.For>(); + private readonly IObjectMapper _mapper + = Substitute.For(); + private readonly IEnumerable> _validators + = new List>(); + private readonly IServiceProvider _serviceProvider + = Substitute.For(); + private readonly IQueryEngine _queryEngine + = Substitute.For(); + + public CreateTests() + { + _service = new CrudService + (_repository, _mapper, _validators, _serviceProvider, _queryEngine); + } + + [Fact] + public async Task Create_ShouldThrowArgumentException_WhenInputIsNull() + { + + } +} \ No newline at end of file