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 @@ + + + + + + + + + + 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/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 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/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 + + + + + + + + + + + + + + + + + + + + + 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