From 2884038ec5ccafbedf182ad02ee4ea6371b89753 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Date: Sun, 10 Oct 2021 20:40:10 -0300 Subject: [PATCH 01/30] Database docs started --- docs/database.drawio | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/database.drawio diff --git a/docs/database.drawio b/docs/database.drawio new file mode 100644 index 0000000..24e8865 --- /dev/null +++ b/docs/database.drawio @@ -0,0 +1 @@ +7ZjRbpswFIafhstOgEOaXjY026pl1dROqno1OdgBaw5GxmnCnn7HcAghDKlV0yRdK3Fh/z4+2OezfyU4JFysv2iaJd8V49LxXbZ2yJXj+97A9x37uKyolPMhCrEWDIMa4U784Si6qC4F43kr0CgljcjaYqTSlEempVGt1aodNley/daMxrwj3EVUdtV7wUxSqaPAbfSvXMRJ/WbPxZEZjX7HWi1TfF+qUl6NLGidBkPzhDK12pLIxCGhVspUrcU65NKWta5YNe9zz+hmyZqn5ikTrui1XFHKfg3I2c194cYP5OEMszxSucRSXEYRbMfkuGhT1DWC9We2aejMSuPcUG0QJXFBADiGipRrELyyLyXNclGGV0oiJJvSQi1NnajujedizdltRdLGAtQpJLNdm3wOye9wMXaYShGn0I5g9/aNY81zWMuU5gYjcGdcG77uLZm3AQFnm6sFN7qAEJwwQHRFu7tqjog3Qi3ZPh5DFCkey3iTueEDDUT0DFx+B1cvJtilEVTewnWhaVwSawOxVWVaZT+pjrlBIVPC1nPyyO0RwNILKUMlleVanm8yNirDQcnn9dyZMkYtanxYjk3SshTBGB4oTuh+CpwAlhtC32v68NhwbUKV5kbDabI5OEBdcQv2aVD7T3qXNKIlT0RLXoss6ZD98e15bEtnpA3bZ2Nzd7DtXjkFZZ/L0sISwRhPX8TD/zePLQDkkPUfdOp/zY5c/9riqthxntFIpPG0mjncARQcCtC6/8IEhwQWvAkr3GX6BqxweGwrHL6Q7N4vImeizrd/HwxOywfPO8W/oQt+6k54ECSn4nx+l9GH9e3F+i6ObX3+6F15X3WST8f8/ItO+cOlhk1ExftywD4wp2KBL70mHw7Y44Cef2wL7F7B/9kBR6dlgPX32O2/wfllZMTjO/sJ2MPl9f0Pus0n4XJs65M7mfwF \ No newline at end of file From a5cd185cc5fcdf1bfa13a679ef60dcb2a7700a5e Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Date: Tue, 12 Oct 2021 17:34:03 -0300 Subject: [PATCH 02/30] Add : project basic structure --- {docs => api/docs/database}/database.drawio | 0 .../FinancialHub.Domain.csproj | 13 +++++ .../FinancialHub.Infra.csproj | 11 ++++ .../FinancialHub.WebApi.csproj | 16 ++++++ .../FinancialHub.WebApi/Program.cs | 26 +++++++++ .../Properties/launchSettings.json | 31 +++++++++++ .../FinancialHub.WebApi/Startup.cs | 55 +++++++++++++++++++ .../appsettings.Development.json | 9 +++ .../FinancialHub.WebApi/appsettings.json | 10 ++++ api/src/FinancialHub/FinancialHub.sln | 37 +++++++++++++ 10 files changed, 208 insertions(+) rename {docs => api/docs/database}/database.drawio (100%) create mode 100644 api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj create mode 100644 api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Program.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Startup.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/appsettings.json create mode 100644 api/src/FinancialHub/FinancialHub.sln diff --git a/docs/database.drawio b/api/docs/database/database.drawio similarity index 100% rename from docs/database.drawio rename to api/docs/database/database.drawio diff --git a/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj b/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj new file mode 100644 index 0000000..40c0589 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj @@ -0,0 +1,13 @@ + + + + net5.0 + + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj b/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj new file mode 100644 index 0000000..ece5b20 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj @@ -0,0 +1,11 @@ + + + + net5.0 + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj new file mode 100644 index 0000000..ba825b4 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -0,0 +1,16 @@ + + + + net5.0 + + + + + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Program.cs b/api/src/FinancialHub/FinancialHub.WebApi/Program.cs new file mode 100644 index 0000000..ebd58b7 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Program.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json b/api/src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json new file mode 100644 index 0000000..ac233d1 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:62772", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "FinancialHub.WebApi": { + "commandName": "Project", + "dotnetRunMessages": "true", + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs new file mode 100644 index 0000000..36414de --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs @@ -0,0 +1,55 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers(); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "FinancialHub.WebApi", Version = "v1" }); + }); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "FinancialHub.WebApi v1")); + } + + app.UseRouting(); + + //app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/api/src/FinancialHub/FinancialHub.sln b/api/src/FinancialHub/FinancialHub.sln new file mode 100644 index 0000000..8277e93 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31624.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.Domain", "FinancialHub.Domain\FinancialHub.Domain.csproj", "{776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.Infra", "FinancialHub.Infra\FinancialHub.Infra.csproj", "{126F1390-1B86-4ABB-9E49-E77B7857E2F0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Release|Any CPU.Build.0 = Release|Any CPU + {126F1390-1B86-4ABB-9E49-E77B7857E2F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {126F1390-1B86-4ABB-9E49-E77B7857E2F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {126F1390-1B86-4ABB-9E49-E77B7857E2F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {126F1390-1B86-4ABB-9E49-E77B7857E2F0}.Release|Any CPU.Build.0 = Release|Any CPU + {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} + EndGlobalSection +EndGlobal From ad1317a523977cf957318c9cf5dbcc29006d2581 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Thu, 10 Feb 2022 22:47:13 -0300 Subject: [PATCH 03/30] release v0.1.0 * Add : DDL Script * Add : Domain architecture * Add : Database context and startup configurations * Add: account get all endpoint * Add : Basic Accounts endpoints * Add : Repository Unit tests * Add : BaseRepository Tests : Update * Change : DDL added account creation/update time * Fix : small comment changes on AccountsController --- api/docs/database/database.drawio | 2 +- api/docs/database/financial-hub_DDL.sql | 12 ++ .../Entities/AccountEntity.cs | 17 +++ .../Entities/BaseEntity.cs | 15 ++ .../FinancialHub.Domain.csproj | 4 +- .../Repositories/IAccountsRepository.cs | 9 ++ .../Repositories/IBaseRepository.cs | 44 ++++++ .../Interfaces/Services/IAccountsService.cs | 17 +++ .../Models/AccountModel.cs | 12 ++ .../FinancialHub.Domain/Models/BaseModel.cs | 9 ++ .../Contexts/FinancialHubContext.cs | 20 +++ .../FinancialHub.Infra.csproj | 9 +- .../Repositories/AccountsRepository.cs | 15 ++ .../Repositories/BaseRepository.cs | 68 +++++++++ .../Services/AccountsService.cs | 60 ++++++++ .../Controllers/AccountsController.cs | 98 ++++++++++++ .../IServiceCollectionExtensions.cs | 36 +++++ .../FinancialHub.WebApi.csproj | 17 ++- .../FinancialHubAutoMapperProfile.cs | 14 ++ .../FinancialHub.WebApi/Program.cs | 6 - .../FinancialHub.WebApi/Startup.cs | 27 +++- .../FinancialHub.WebApi/appsettings.json | 3 + api/src/FinancialHub/FinancialHub.sln | 21 ++- .../FinancialHub.Infra.NUnitTests.csproj | 22 +++ .../Accounts/AccountsRepositoryTests.cs | 48 ++++++ .../Base/BaseRepositoryTests.create.cs | 50 +++++++ .../Repositories/Base/BaseRepositoryTests.cs | 45 ++++++ .../Base/BaseRepositoryTests.delete.cs | 46 ++++++ .../Base/BaseRepositoryTests.get.cs | 139 ++++++++++++++++++ .../Base/BaseRepositoryTests.update.cs | 54 +++++++ 30 files changed, 914 insertions(+), 25 deletions(-) create mode 100644 api/docs/database/financial-hub_DDL.sql create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs diff --git a/api/docs/database/database.drawio b/api/docs/database/database.drawio index 24e8865..19a2b87 100644 --- a/api/docs/database/database.drawio +++ b/api/docs/database/database.drawio @@ -1 +1 @@ -7ZjRbpswFIafhstOgEOaXjY026pl1dROqno1OdgBaw5GxmnCnn7HcAghDKlV0yRdK3Fh/z4+2OezfyU4JFysv2iaJd8V49LxXbZ2yJXj+97A9x37uKyolPMhCrEWDIMa4U784Si6qC4F43kr0CgljcjaYqTSlEempVGt1aodNley/daMxrwj3EVUdtV7wUxSqaPAbfSvXMRJ/WbPxZEZjX7HWi1TfF+qUl6NLGidBkPzhDK12pLIxCGhVspUrcU65NKWta5YNe9zz+hmyZqn5ikTrui1XFHKfg3I2c194cYP5OEMszxSucRSXEYRbMfkuGhT1DWC9We2aejMSuPcUG0QJXFBADiGipRrELyyLyXNclGGV0oiJJvSQi1NnajujedizdltRdLGAtQpJLNdm3wOye9wMXaYShGn0I5g9/aNY81zWMuU5gYjcGdcG77uLZm3AQFnm6sFN7qAEJwwQHRFu7tqjog3Qi3ZPh5DFCkey3iTueEDDUT0DFx+B1cvJtilEVTewnWhaVwSawOxVWVaZT+pjrlBIVPC1nPyyO0RwNILKUMlleVanm8yNirDQcnn9dyZMkYtanxYjk3SshTBGB4oTuh+CpwAlhtC32v68NhwbUKV5kbDabI5OEBdcQv2aVD7T3qXNKIlT0RLXoss6ZD98e15bEtnpA3bZ2Nzd7DtXjkFZZ/L0sISwRhPX8TD/zePLQDkkPUfdOp/zY5c/9riqthxntFIpPG0mjncARQcCtC6/8IEhwQWvAkr3GX6BqxweGwrHL6Q7N4vImeizrd/HwxOywfPO8W/oQt+6k54ECSn4nx+l9GH9e3F+i6ObX3+6F15X3WST8f8/ItO+cOlhk1ExftywD4wp2KBL70mHw7Y44Cef2wL7F7B/9kBR6dlgPX32O2/wfllZMTjO/sJ2MPl9f0Pus0n4XJs65M7mfwF \ No newline at end of file +7Zphc5owGMc/DS+7QxC1Lwt2ba+2t2u38/pqF0mE3GLChVhhn34JBBHRFafTibvjBfnn4SE8vyf/itawvVlyx0EUPjGIiGGZMDHsoWFZna5lGeowYZor/Z4WAo6hDiqFV/wTadHU6hxDFFcCBWNE4Kgq+oxS5IuKBjhni2rYlJHqXSMQoJrw6gNSV8cYijBXB45Z6vcIB2Fx546pZybA/xFwNqf6fpRRlM/MQJFGh8YhgGyxItm3hu1xxkR+Nks8RFRZi4rl133eMrtcMkdUNLlgCB7IAgD4vWtfPY9TM3iz3650lndA5roUN74vH0fEetEiLWok1x+pUwEmSnJjAbjQKG1TChKOAJgiLoVONiYERDHOwnMlxASOQMrmokhUjNwpThB8yUmqWAl1JJOpoUo+lclf9WLUNCA4oPLcl0+v7uhyFMu1jEAsdES9PsXDIi5QsiLpet0hNkOCpzJEz3Y1urQ6XJQt0hloLVxtj2stAt2WwTJzyUeeaEQ74LJquLZikg8uMCAvcrsAGmTEqkBUVSFn0VfAAyS0EDGs6nn7jlQL6NJjQjxGmOKa9bftChbpSYKmxbUTJgSbFfh0OZZJs1I4rjxkcTzzk2M4crmeHHfKsTxUOBceo7HgsptUDiShLpACuwHqb9v6Y9Iard0Qrf23yNo1sl8ed2ObOSMo2e6MzVzDtr7lmCznlGQWFmIIEW3Ow2rMYwWAvWP9dbKyKjtnA0T2PgUCucrR4xrU5Tr/nHO3xvkBnphzYaV5rBtHwMc0GOVX9tYawTlWIyTbN6Zz0MZolO4IneGchbevN88ZeHvv1N7e25PswXc8grjIt6exO41htN3Y+zXIz2CG/nVrPwr6Nlu5c4/G6SO7SdLh6FvqOE/cmmx4q7pIK6+1RlN332rl10e08o1k930BO52VfwBjex+32so3Pnb9XWyIYp/jSGBGz9fRD9gBbXb0ze8t9T/vF2nph/903rFO/fHcGpytqX/8vt1vzKNFrr65FNc1zN6cy/r56fl6+iEb4OJMfd99/9/Tt3m6c2pPr+/11lj6oDGNtjt68evx6pfp8Y0v8Hubv3dpzr9Fhi6H5S/leXj5nwj27S8= \ No newline at end of file diff --git a/api/docs/database/financial-hub_DDL.sql b/api/docs/database/financial-hub_DDL.sql new file mode 100644 index 0000000..ab194c7 --- /dev/null +++ b/api/docs/database/financial-hub_DDL.sql @@ -0,0 +1,12 @@ +CREATE DATABASE financial_hub; +USE financial_hub; + +CREATE TABLE accounts( + id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), + name VARCHAR(200) NOT NULL, + description VARCHAR(500) NULL, + currency VARCHAR(50), + active BIT DEFAULT 1, + update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), + creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), +); diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs new file mode 100644 index 0000000..79103bd --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs @@ -0,0 +1,17 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace FinancialHub.Domain.Entities +{ + [Table("accounts")] + public class AccountEntity : BaseEntity + { + [Column("name")] + public string Name { get; set; } + [Column("description")] + public string Description { get; set; } + [Column("currency")] + public string Currency { get; set; } + [Column("active")] + public bool IsActive { get; set; } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs new file mode 100644 index 0000000..eae8c3f --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs @@ -0,0 +1,15 @@ +using System; +using System.ComponentModel.DataAnnotations.Schema; + +namespace FinancialHub.Domain.Entities +{ + public abstract class BaseEntity + { + [Column("id")] + public Guid? Id { get; set; } + [Column("creation_time")] + public DateTimeOffset? CreationTime { get; set; } + [Column("update_time")] + public DateTimeOffset? UpdateTime { get; set; } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj b/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj index 40c0589..b5e5cf5 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj +++ b/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj @@ -1,12 +1,10 @@ - + net5.0 - - diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs new file mode 100644 index 0000000..4cb6ba4 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs @@ -0,0 +1,9 @@ +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Domain.Interfaces.Repositories +{ + public interface IAccountsRepository : IBaseRepository + { + //Task> GetByUserId(string userId); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs new file mode 100644 index 0000000..118cb5e --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs @@ -0,0 +1,44 @@ +using System; +using System.Threading.Tasks; +using System.Collections.Generic; +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Domain.Interfaces.Repositories +{ + /// + /// Base repository with basic CRUD methods + /// + /// Any Entity that inherits + public interface IBaseRepository + where T : BaseEntity + { + /// + /// Adds an entity to the database + /// + /// Entity to be added + Task CreateAsync(T obj); + /// + /// Updates a created entity on the database + /// + /// Entity on the database + Task UpdateAsync(T obj); + /// + /// Deletes an entity from the database + /// + /// Id of the entity to be removed + Task DeleteAsync(string id); + /// + /// Get All entities from the database + /// + Task> GetAllAsync(); + /// + /// Get All entities from the database based on a filter + /// + Task> GetAsync(Func predicate); + /// + /// Gets an entity by id + /// + /// Id of the choosen entity + Task GetByIdAsync(string id); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs new file mode 100644 index 0000000..d9bd870 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs @@ -0,0 +1,17 @@ +using FinancialHub.Domain.Models; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace FinancialHub.Domain.Interfaces.Services +{ + public interface IAccountsService + { + Task> GetAllByUserAsync(string userId); + + Task CreateAsync(AccountModel account); + + Task UpdateAsync(string id,AccountModel account); + + Task DeleteAsync(string id); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs b/api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs new file mode 100644 index 0000000..6720017 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs @@ -0,0 +1,12 @@ +using FinancialHub.Domain.Model; + +namespace FinancialHub.Domain.Models +{ + public class AccountModel : BaseModel + { + public string Name { get; set; } + public string Description { get; set; } + public string Currency { get; set; } + public bool IsActive { get; set; } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs b/api/src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs new file mode 100644 index 0000000..4277955 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs @@ -0,0 +1,9 @@ +using System; + +namespace FinancialHub.Domain.Model +{ + public abstract class BaseModel + { + public Guid? Id { get; set; } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs b/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs new file mode 100644 index 0000000..eae47b8 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs @@ -0,0 +1,20 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using System.Diagnostics.CodeAnalysis; + +namespace FinancialHub.Infra.Contexts +{ + public class FinancialHubContext : DbContext + { + public FinancialHubContext([NotNull] DbContextOptions options) : base(options) + { + } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + base.OnConfiguring(optionsBuilder); + } + + public DbSet Accounts { get; set;} + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj b/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj index ece5b20..4971597 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj +++ b/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj @@ -1,11 +1,16 @@ - + net5.0 - + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs new file mode 100644 index 0000000..b1af7e1 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs @@ -0,0 +1,15 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Infra.Contexts; +using System.ComponentModel; + +namespace FinancialHub.Infra.Repositories +{ + [Category("Repositories")] + public class AccountsRepository : BaseRepository, IAccountsRepository + { + public AccountsRepository(FinancialHubContext context) : base(context) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs new file mode 100644 index 0000000..96bdccd --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs @@ -0,0 +1,68 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using FinancialHub.Infra.Contexts; +using Microsoft.EntityFrameworkCore; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Repositories; + +namespace FinancialHub.Infra.Repositories +{ + public class BaseRepository : + IBaseRepository + where T : BaseEntity + { + private readonly FinancialHubContext context; + public BaseRepository(FinancialHubContext context) + { + this.context = context; + } + + public async Task CreateAsync(T obj) + { + obj.Id = null; + var res = await context.AddAsync(obj); + await context.SaveChangesAsync(); + return res.Entity; + } + + public async Task DeleteAsync(string id) + { + var entity = context.Set().FirstOrDefault(x => x.Id.ToString() == id); + + if(entity != null) + { + context.Set().Remove(entity); + return await context.SaveChangesAsync(); + } + else + { + return 0; + } + } + + public async Task UpdateAsync(T obj) + { + obj.UpdateTime = DateTimeOffset.Now; + var res = context.Set().Update(obj); + await context.SaveChangesAsync(); + return res.Entity; + } + + public async Task> GetAllAsync() + { + return await context.Set().ToListAsync(); + } + + public async Task> GetAsync(Func predicate) + { + return context.Set().Where(predicate).ToList(); + } + + public async Task GetByIdAsync(string id) + { + return await context.Set().FirstOrDefaultAsync(x => x.Id.ToString() == id); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs b/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs new file mode 100644 index 0000000..d4728d3 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs @@ -0,0 +1,60 @@ +using AutoMapper; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Models; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Services +{ + public class AccountsService : IAccountsService + { + private readonly IMapper mapper; + private readonly IAccountsRepository repository; + + public AccountsService(IMapper mapper,IAccountsRepository repository) + { + this.mapper = mapper; + this.repository = repository; + } + + public async Task CreateAsync(AccountModel account) + { + var entity = mapper.Map(account); + entity.CreationTime = DateTimeOffset.Now; + entity.UpdateTime = DateTimeOffset.Now; + + entity = await this.repository.CreateAsync(entity); + + return mapper.Map(entity); + } + + public async Task DeleteAsync(string id) + { + return await this.repository.DeleteAsync(id); + } + + public async Task> GetAllByUserAsync(string userId) + { + var entities = await this.repository.GetAllAsync(); + return mapper.Map>(entities); + } + + public async Task UpdateAsync(string id, AccountModel account) + { + var entity = await this.repository.GetByIdAsync(id); + + if(entity == null) + { + throw new NullReferenceException($"Not found account with id {id}"); + } + entity.Id = new Guid(id); + + entity = await this.repository.UpdateAsync(entity); + + return mapper.Map(entity); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs new file mode 100644 index 0000000..e062510 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs @@ -0,0 +1,98 @@ +using FinancialHub.Domain.Interfaces.Services; +using System.Collections.Generic; +using FinancialHub.Domain.Models; +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace FinancialHub.WebApi.Controllers +{ + [ApiController] + [Route("[controller]")] + [Produces("application/json")] + [ProducesErrorResponseType(typeof(Exception))] + public class AccountsController : Controller + { + private readonly IAccountsService service; + + public AccountsController(IAccountsService service) + { + this.service = service; + } + + /// + /// Get all accounts of the system (will be changed to only one user) + /// + [HttpGet] + [ProducesResponseType(typeof(ICollection), 200)] + public async Task GetMyAccounts() + { + try + { + var response = await service.GetAllByUserAsync("mock"); + return Ok(response); + } + catch (Exception e) + { + return BadRequest(e); + } + } + + /// + /// Creates an account on database (will be changed to only one user) + /// + /// Account to be created + [HttpPost] + [ProducesResponseType(typeof(ICollection),200)] + public async Task CreateAccount(AccountModel account) + { + try + { + var response = await service.CreateAsync(account); + return Ok(response); + } + catch (Exception e) + { + return BadRequest(e); + } + } + + /// + /// Updates an existing account on database + /// + /// id of the account + /// account changes + [HttpPut("{id}")] + [ProducesResponseType(typeof(ICollection), 200)] + public async Task UpdateAccount(string id,AccountModel account) + { + try + { + var response = await service.UpdateAsync(id,account); + return Ok(response); + } + catch (Exception e) + { + return BadRequest(e); + } + } + + /// + /// Deletes an existing account on database + /// + /// id of the account + [HttpDelete("{id}")] + public async Task DeleteAccount(string id) + { + try + { + await service.DeleteAsync(id); + return NoContent(); + } + catch (Exception e) + { + return BadRequest(e); + } + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..a36e0b7 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -0,0 +1,36 @@ +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Infra.Repositories; +using FinancialHub.Infra.Services; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; + +namespace FinancialHub.WebApi.Extensions.Configurations +{ + public static class IServiceCollectionExtensions + { + public static IServiceCollection AddApiConfigurations(this IServiceCollection services) + { + services.AddControllers(); + services.AddApiVersioning(config => + { + config.DefaultApiVersion = new ApiVersion(1, 0); + config.AssumeDefaultVersionWhenUnspecified = true; + config.ReportApiVersions = true; + }); + return services; + } + //TODO: find a better method organization + public static IServiceCollection AddRepositories(this IServiceCollection services) + { + services.AddScoped(); + return services; + } + + public static IServiceCollection AddServices(this IServiceCollection services) + { + services.AddScoped(); + return services; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj index ba825b4..ee32e78 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -5,12 +5,25 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - + diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs new file mode 100644 index 0000000..452c16d --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs @@ -0,0 +1,14 @@ +using AutoMapper; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; + +namespace FinancialHub.WebApi +{ + public class FinancialHubAutoMapperProfile : Profile + { + public FinancialHubAutoMapperProfile() + { + CreateMap().ReverseMap(); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Program.cs b/api/src/FinancialHub/FinancialHub.WebApi/Program.cs index ebd58b7..8e457c5 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Program.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Program.cs @@ -1,11 +1,5 @@ using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace FinancialHub.WebApi { diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs index 36414de..cd67adf 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs @@ -1,15 +1,13 @@ +using FinancialHub.Infra.Contexts; +using FinancialHub.WebApi.Extensions.Configurations; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace FinancialHub.WebApi { @@ -25,10 +23,23 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddControllers(); + services.AddDbContext( + provider =>{ + provider.UseSqlServer(Configuration.GetConnectionString("default")); + } + ); + + //services.AddLogging(); + + services.AddRepositories(); + services.AddServices(); + services.AddApiConfigurations(); + services.AddAutoMapper(typeof(FinancialHubAutoMapperProfile)); + + //services.AddHealthCheck(); services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "FinancialHub.WebApi", Version = "v1" }); + c.SwaggerDoc("v1", new OpenApiInfo { Title = "FinancialHub WebApi", Version = "v1" }); }); } @@ -39,7 +50,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseDeveloperExceptionPage(); app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "FinancialHub.WebApi v1")); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Financial Hub WebApi v1")); } app.UseRouting(); diff --git a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json index d9d9a9b..7106a01 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json +++ b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json @@ -6,5 +6,8 @@ "Microsoft.Hosting.Lifetime": "Information" } }, + "ConnectionStrings": { + "default": "Server=localhost;Database=financial_hub;Trusted_Connection=True;" + }, "AllowedHosts": "*" } diff --git a/api/src/FinancialHub/FinancialHub.sln b/api/src/FinancialHub/FinancialHub.sln index 8277e93..0f6abda 100644 --- a/api/src/FinancialHub/FinancialHub.sln +++ b/api/src/FinancialHub/FinancialHub.sln @@ -3,11 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31624.102 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.Domain", "FinancialHub.Domain\FinancialHub.Domain.csproj", "{776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain", "FinancialHub.Domain\FinancialHub.Domain.csproj", "{776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.Infra", "FinancialHub.Infra\FinancialHub.Infra.csproj", "{126F1390-1B86-4ABB-9E49-E77B7857E2F0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra", "FinancialHub.Infra\FinancialHub.Infra.csproj", "{126F1390-1B86-4ABB-9E49-E77B7857E2F0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{1F4F43B0-14F5-4C91-B98C-AEB8A5421258}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{2444FB9D-15D1-4193-BF04-83C4397369DA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.NUnitTests", "MyFinancialHub.Infra.NUnitTests\FinancialHub.Infra.NUnitTests.csproj", "{D88B870B-D7EF-41CF-B24F-8D85C37559E1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -27,10 +33,19 @@ Global {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Release|Any CPU.Build.0 = Release|Any CPU + {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} + {126F1390-1B86-4ABB-9E49-E77B7857E2F0} = {2444FB9D-15D1-4193-BF04-83C4397369DA} + {D88B870B-D7EF-41CF-B24F-8D85C37559E1} = {2444FB9D-15D1-4193-BF04-83C4397369DA} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} EndGlobalSection diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj new file mode 100644 index 0000000..89336fb --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj @@ -0,0 +1,22 @@ + + + + net5.0 + + false + + + + + + + + + + + + + + + + diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs new file mode 100644 index 0000000..7949183 --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs @@ -0,0 +1,48 @@ +using System; +using NUnit.Framework; +using System.Collections.Generic; +using FinancialHub.Domain.Entities; +using FinancialHub.Infra.Repositories; +using FinancialHub.Infra.NUnitTests.Repositories.Base; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Accounts +{ + public class AccountsRepositoryTests : BaseRepositoryTests + { + [SetUp] + protected override void Setup() + { + base.Setup(); + this.repository = new AccountsRepository(this.context); + } + + protected override ICollection GenerateData(int min = 1, int max = 100, params object[] props) + { + var count = random.Next(min,max); + var accounts = new AccountEntity[count]; + + for (int i = 0; i < count; i++) + { + accounts[i] = this.GenerateObject(Guid.NewGuid(), props); + } + + return accounts; + } + + protected override AccountEntity GenerateObject(Guid? id = null, params object[] props) + { + var active = random.Next(0,1); + + return new AccountEntity() + { + Id = id, + Name = props.Length > 0 ? props[0].ToString() : Guid.NewGuid().ToString(), + Description = props.Length > 1 ? props[1].ToString() : Guid.NewGuid().ToString(), + Currency = props.Length > 2 ? props[2].ToString() : Guid.NewGuid().ToString(), + IsActive = props.Length > 3 ? (bool)props[3] : active == 1, + CreationTime = DateTimeOffset.UtcNow, + UpdateTime = DateTimeOffset.UtcNow, + }; + } + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs new file mode 100644 index 0000000..8fd1c41 --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs @@ -0,0 +1,50 @@ +using FinancialHub.Domain.Entities; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T : BaseEntity + { + #region Create + [Test] + [TestCase(TestName = "Create New Item", Category = "Create")] + public async Task CreateAsync_ValidItem_AddsOneRow() + { + var item = this.GenerateObject(); + + var createdItem = await this.repository.CreateAsync(item); + + Assert.IsNotNull(createdItem); + Assert.IsNotNull(createdItem.Id); + Assert.IsNotNull(createdItem.CreationTime); + Assert.IsNotNull(createdItem.UpdateTime); + Assert.IsInstanceOf(createdItem); + } + + [Test] + [TestCase(TestName = "Create New Item With Id", Category = "Create")] + public async Task CreateAsync_ValidItemWithId_AddsOneRow() + { + var id = Guid.NewGuid(); + var item = this.GenerateObject(id); + + var createdItem = await this.repository.CreateAsync(item); + + Assert.IsNotNull(createdItem); + Assert.AreNotEqual(id,createdItem.Id); + Assert.IsNotNull(createdItem.CreationTime); + Assert.IsNotNull(createdItem.UpdateTime); + Assert.IsInstanceOf(createdItem); + } + + [Test] + [TestCase(TestName = "Create Null Item With Id", Category = "Create")] + public async Task CreateAsync_NullItem_ThrowsNullReferenceException() + { + Assert.ThrowsAsync(async () => await this.repository.CreateAsync(null)); + } + #endregion + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs new file mode 100644 index 0000000..e696055 --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs @@ -0,0 +1,45 @@ +using System; +using NUnit.Framework; +using FinancialHub.Infra.Contexts; +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using FinancialHub.Domain.Interfaces.Repositories; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T: BaseEntity + { + protected Random random; + + protected FinancialHubContext context; + protected IBaseRepository repository; + + [SetUp] + protected virtual void Setup() + { + this.context = new FinancialHubContext( + new DbContextOptionsBuilder().UseInMemoryDatabase($"Database_{Guid.NewGuid()}").Options + ); + + this.random = new Random(); + } + + [TearDown] + protected virtual void TearDown() + { + this.context.Dispose(); + } + + protected virtual async Task InsertData(ICollection items) + { + await this.context.Set().AddRangeAsync(items); + await this.context.SaveChangesAsync(); + } + + protected abstract ICollection GenerateData(int min = 1,int max = 100, params object[] props); + + protected abstract T GenerateObject(Guid? id = null, params object[] props); + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs new file mode 100644 index 0000000..3706823 --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs @@ -0,0 +1,46 @@ +using FinancialHub.Domain.Entities; +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T : BaseEntity + { + #region Delete + [Test] + [TestCase(TestName = "Delete Existing Item",Category = "Delete")] + public async Task DeleteAsync_ExistingItem_AffectsOneRow() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var affectedRows = await this.repository.DeleteAsync(items.First().Id.ToString()); + Assert.AreEqual(1,affectedRows); + } + + [Test] + [TestCase(TestName = "Delete Non Existing Item",Category = "Delete")] + public async Task DeleteAsync_NonExistingItem_AffectsNothing() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var affectedRows = await this.repository.DeleteAsync(new Guid().ToString()); + Assert.AreEqual(0, affectedRows); + } + + [Test] + [TestCase(TestName = "Delete Null id Item", Category = "Delete")] + public async Task DeleteAsync_NullId_AffectsNothing() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var affectedRows = await this.repository.DeleteAsync(null); + Assert.AreEqual(0, affectedRows); + } + #endregion + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs new file mode 100644 index 0000000..722b50d --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs @@ -0,0 +1,139 @@ +using System; +using System.Linq; +using NUnit.Framework; +using System.Threading.Tasks; +using System.Collections.Generic; +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T : BaseEntity + { + #region Get All + [Test] + [TestCase(TestName = "Get All Items without data",Category = "Get")] + public async Task GetAllAsync_NoData_ReturnsEmpty() + { + var list = await this.repository.GetAllAsync(); + + Assert.IsEmpty(list); + Assert.IsInstanceOf>(list); + } + + [Test] + [TestCase(TestName = "Get All Items with data", Category = "Get")] + public async Task GetAllAsync_Data_ReturnsItems() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var list = await this.repository.GetAllAsync(); + + Assert.IsNotEmpty(list); + Assert.AreEqual(items,list); + Assert.IsInstanceOf>(list); + } + #endregion + + #region Get + [Test] + [TestCase(TestName = "Get Items with no filter", Category = "Get")] + public async Task GetAsync_NoFilter_ReturnsAllItems() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var list = await this.repository.GetAsync((x) => true); + + Assert.IsNotEmpty(list); + Assert.AreEqual(items, list); + Assert.IsInstanceOf>(list); + } + + [Test] + [TestCase(TestName = "Get Items not setting filter", Category = "Get")] + public async Task GetAsync_NullFilter_ThrowsArgumentNullException() + { + var items = this.GenerateData(); + await this.InsertData(items); + + Assert.ThrowsAsync(typeof(ArgumentNullException), async () => await this.repository.GetAsync(null)); + } + + [Test] + [TestCase(TestName = "Get Items filtering", Category = "Get")] + public async Task GetAsync_Filter_ReturnsFilteredItems() + { + var items = this.GenerateData(10,100); + await this.InsertData(items); + + var id = items.First().Id; + Func filter = (x) => x.Id == id; + var expectedResult = items.Where(filter); + + var list = await this.repository.GetAsync(filter); + + Assert.IsNotEmpty(list); + Assert.AreEqual(expectedResult, list); + Assert.IsInstanceOf>(list); + } + + [Test] + [TestCase(TestName = "Get Items with wrong filter", Category = "Get")] + public async Task GetAsync_WrongFilter_ReturnsEmpty() + { + var items = this.GenerateData(10, 100); + await this.InsertData(items); + + Func filter = (x) => x.Id == new Guid(); + + var list = await this.repository.GetAsync(filter); + + Assert.IsEmpty(list); + Assert.IsInstanceOf>(list); + } + #endregion + + #region Get By Id + [Test] + [TestCase(TestName = "Get By Id with empty id", Category = "Get")] + public async Task GetByIdAsync_EmptyId_ReturnsNull() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var item = await this.repository.GetByIdAsync(""); + + Assert.IsNull(item); + } + + [Test] + [TestCase(TestName = "Get By Id with existing id", Category = "Get")] + public async Task GetByIdAsync_ExistingId_ReturnsItem() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var id = items.First().Id; + + var item = await this.repository.GetByIdAsync(id.ToString()); + + Assert.IsNotNull(item); + Assert.AreEqual(id,item.Id); + Assert.IsInstanceOf(item); + } + + [Test] + [TestCase(TestName = "Get By Id with non-existing id", Category = "Get")] + public async Task GetByIdAsync_NonExistingId_ReturnsNull() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var item = await this.repository.GetByIdAsync(new Guid().ToString()); + + Assert.IsNull(item); + } + #endregion + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs new file mode 100644 index 0000000..fa62250 --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs @@ -0,0 +1,54 @@ +using FinancialHub.Domain.Entities; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T : BaseEntity + { + #region Update + [Test] + [TestCase(TestName = "Update Existing Item", Category = "Update")] + public async Task UpdateAsync_ExistingItem_UpdatesItem() + { + var item = this.GenerateObject(); + await this.InsertData(new T[1] { item }); + + var oldCreationTime = item.UpdateTime.GetValueOrDefault(); + + var updatedItem = await this.repository.UpdateAsync(item); + + Assert.IsNotNull(updatedItem); + Assert.IsNotNull(updatedItem.Id); + Assert.IsNotNull(updatedItem.CreationTime); + Assert.IsNotNull(updatedItem.UpdateTime); + Assert.AreNotEqual(oldCreationTime,updatedItem.UpdateTime); + Assert.IsInstanceOf(updatedItem); + } + + [Test] + [TestCase(TestName = "Update non existing Item", Category = "Update")] + public async Task UpdateAsync_NonExistingItem_DoesNotUpdate() + { + var id = Guid.NewGuid(); + var item = this.GenerateObject(id); + + var createdItem = await this.repository.CreateAsync(item); + + Assert.IsNotNull(createdItem); + Assert.AreNotEqual(id, createdItem.Id); + Assert.IsNotNull(createdItem.CreationTime); + Assert.IsNotNull(createdItem.UpdateTime); + Assert.IsInstanceOf(createdItem); + } + + [Test] + [TestCase(TestName = "Update Null Item", Category = "Update")] + public async Task UpdateAsync_NullItem_ThrowsNullReferenceException() + { + Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(null)); + } + #endregion + } +} From b39fff3ffc71e2c64ebd0f2752eb9d3631b0a9a2 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Fri, 11 Feb 2022 00:48:41 -0300 Subject: [PATCH 04/30] release v0.2.0 * Add : DDL Script * Change : DDL added account creation/update time * Add : Domain architecture * Add : Database context and startup configurations * Add: account get all endpoint * Add : Basic Accounts endpoints * Add : Repository Unit tests * Add : BaseRepository Tests : Update * Fix : small comment changes on AccountsController * Add : category table DDL * Add : Categories CRUD * Add : Transactions endpoints * Fix : NUnit BaseRepository Update Test * Changes : BaseRepositoryTest base GenerateData method * Changes : controller params * Changes : BaseRepository methods are virtual and protected * Fix : BaseRepositoryTests typos and context verification on CreateAsync * Changes : BaseRepository Tests are now virtual * Add : Releashionship between Accounts,Category and Transaction * Change : Inherits to Create Base Repository tests * Add : TransactionEntity Relashionships * Fix : Transaction creating category and account when not found * Changes : Project using .NET 6.0 * Fix : repository create tests, delete and get by id parameters * Fix : CreateAsync Tests * Add : Faker library to generate data * Fix : All update tests * Add : Transaction Filters * Add : Transaction date Filters * Fix: Transaction Fields types * Add : Auto Include on Transactions * Add : Transaction get filters * Fix : transaction status changed --- api/docs/database/database.drawio | 2 +- api/docs/database/financial-hub_DDL.sql | 28 +++ .../Entities/AccountEntity.cs | 5 +- .../Entities/BaseEntity.cs | 2 + .../Entities/CategoryEntity.cs | 18 ++ .../Entities/TransactionEntity.cs | 38 ++++ .../Enums/TransactionStatus.cs | 10 + .../Enums/TransactionType.cs | 8 + .../Filters/TransactionFilter.cs | 49 +++++ .../FinancialHub.Domain.csproj | 2 +- .../Repositories/IBaseRepository.cs | 4 +- .../Repositories/ICategoriesRepository.cs | 8 + .../Repositories/ITransactionsRepository.cs | 8 + .../Interfaces/Services/IAccountsService.cs | 5 +- .../Interfaces/Services/ICategoriesService.cs | 18 ++ .../Services/ITransactionsService.cs | 19 ++ .../Models/CategoryModel.cs | 11 ++ .../Models/TransactionModel.cs | 26 +++ .../Queries/TransactionQuery.cs | 137 +++++++++++++ .../Contexts/FinancialHubContext.cs | 28 ++- .../FinancialHub.Infra.csproj | 4 +- .../Repositories/BaseRepository.cs | 23 ++- .../Repositories/CategoriesRepository.cs | 13 ++ .../Repositories/TransactionsRepository.cs | 35 ++++ .../Services/AccountsService.cs | 8 +- .../Services/CategoriesService.cs | 58 ++++++ .../Services/TransactionsService.cs | 64 ++++++ .../Controllers/AccountsController.cs | 6 +- .../Controllers/CategoriesController.cs | 98 +++++++++ .../Controllers/TransactionsController.cs | 102 ++++++++++ .../IServiceCollectionExtensions.cs | 4 + .../FinancialHub.WebApi.csproj | 19 +- .../FinancialHubAutoMapperProfile.cs | 10 +- .../FinancialHub.WebApi/Startup.cs | 5 +- .../FinancialHub.Infra.NUnitTests.csproj | 19 +- .../Generators/EntityGenerator.cs | 71 +++++++ .../Accounts/AccountsRepositoryTests.cs | 28 +-- .../Base/BaseRepositoryTests.create.cs | 57 ++++-- .../Repositories/Base/BaseRepositoryTests.cs | 69 ++++++- .../Base/BaseRepositoryTests.delete.cs | 25 +-- .../Base/BaseRepositoryTests.get.cs | 42 ++-- .../Base/BaseRepositoryTests.update.cs | 22 +-- .../Categories/CategoriesRepositoryTests.cs | 23 +++ .../TransactionsRepositoryTests.create.cs | 186 ++++++++++++++++++ .../TransactionsRepositoryTests.cs | 38 ++++ .../TransactionsRepositoryTests.delete.cs | 27 +++ .../TransactionsRepositoryTests.update.cs | 116 +++++++++++ 47 files changed, 1438 insertions(+), 160 deletions(-) create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra/Services/CategoriesService.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra/Services/TransactionsService.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs create mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs diff --git a/api/docs/database/database.drawio b/api/docs/database/database.drawio index 19a2b87..6dfcdca 100644 --- a/api/docs/database/database.drawio +++ b/api/docs/database/database.drawio @@ -1 +1 @@ -7Zphc5owGMc/DS+7QxC1Lwt2ba+2t2u38/pqF0mE3GLChVhhn34JBBHRFafTibvjBfnn4SE8vyf/itawvVlyx0EUPjGIiGGZMDHsoWFZna5lGeowYZor/Z4WAo6hDiqFV/wTadHU6hxDFFcCBWNE4Kgq+oxS5IuKBjhni2rYlJHqXSMQoJrw6gNSV8cYijBXB45Z6vcIB2Fx546pZybA/xFwNqf6fpRRlM/MQJFGh8YhgGyxItm3hu1xxkR+Nks8RFRZi4rl133eMrtcMkdUNLlgCB7IAgD4vWtfPY9TM3iz3650lndA5roUN74vH0fEetEiLWok1x+pUwEmSnJjAbjQKG1TChKOAJgiLoVONiYERDHOwnMlxASOQMrmokhUjNwpThB8yUmqWAl1JJOpoUo+lclf9WLUNCA4oPLcl0+v7uhyFMu1jEAsdES9PsXDIi5QsiLpet0hNkOCpzJEz3Y1urQ6XJQt0hloLVxtj2stAt2WwTJzyUeeaEQ74LJquLZikg8uMCAvcrsAGmTEqkBUVSFn0VfAAyS0EDGs6nn7jlQL6NJjQjxGmOKa9bftChbpSYKmxbUTJgSbFfh0OZZJs1I4rjxkcTzzk2M4crmeHHfKsTxUOBceo7HgsptUDiShLpACuwHqb9v6Y9Iard0Qrf23yNo1sl8ed2ObOSMo2e6MzVzDtr7lmCznlGQWFmIIEW3Ow2rMYwWAvWP9dbKyKjtnA0T2PgUCucrR4xrU5Tr/nHO3xvkBnphzYaV5rBtHwMc0GOVX9tYawTlWIyTbN6Zz0MZolO4IneGchbevN88ZeHvv1N7e25PswXc8grjIt6exO41htN3Y+zXIz2CG/nVrPwr6Nlu5c4/G6SO7SdLh6FvqOE/cmmx4q7pIK6+1RlN332rl10e08o1k930BO52VfwBjex+32so3Pnb9XWyIYp/jSGBGz9fRD9gBbXb0ze8t9T/vF2nph/903rFO/fHcGpytqX/8vt1vzKNFrr65FNc1zN6cy/r56fl6+iEb4OJMfd99/9/Tt3m6c2pPr+/11lj6oDGNtjt68evx6pfp8Y0v8Hubv3dpzr9Fhi6H5S/leXj5nwj27S8= \ No newline at end of file +7V1dd6o4FP01PvYuAbH2sdr2tuvaO3faTjudl64UImYGiSvEKv31k0DwowQviviRsJYP5iSE5OydDckh0LB6o9l3AsbDe+xCv2E23VnDumqYptEyzQb/Nd0osZy3hcEjyBWFFoZH9AmFsSmsE+TCcKUgxdinaLxqdHAQQIeu2AAheLpabID91bOOgQczhkcH+FnrC3LpMLF27ObCfguRN0zPbDRFzjtw/vMIngTifAEOYJIzAmk1omg4BC6eLpms64bVIxjT5N9o1oM+d2vqseS4m5zceZMJDGiRA67AnT8FwH1rWWc/X6Km92q9nolaPoA/Ea64dBzWHRqKRtMo9RFr/5j/peCdm7ohBYQKKK0mMzBwKEABJMxgxGnfB+MQxcUTyxD5bh9EeELTitJUd4Bm0H1IkORlGah9VhlP8soHrPJH0RieDXzkBey/w3rPz9glMGRt6YOQihJZ/6SdhYTC2ZJJ+Os7xCNIScSKiNyWgC5aTU4XFDE6wjZcpseFMAJBS29e8wIf9kdAtAFcZgauXJhYxykC/gMbLiDwYsRWAeFedQkePwHiQSoMY4y4P68/IKeAcD3y/R72Mcc15rfVpXgsMn04SI99x5TiUQqfcMe80tgVdpf9mHN6zW92w2bN7bG0sUizHy9OaA8HISWMTbwOyECdQg6sBNS1tP490gJaqyC0VlXIWhlkf/3YDNtYGcEC241ha36B7euQw8ydAz+WsCFyXRgUx8MsjMcSANaG/heVLbyycW3AZ9wPAIVdruhhBtR5O7fHuZXBmRU/LM6plCZlu+EYOCjw+smR7S9EsPdFhFn+wLR3SoxC1e2BGfZJaPtX8pyAtrcPre3tksjufMRDF6X1lRR2uzAYqgv7eQbkAIzgsUv7XqBXWcrtW/gS/cCXs+iq/1dk2/fEfJfMqmop34mUX+xRyqXIlp2AHYeUryWtVlIu9UR2LubC0CFoTBEO1FD0kgxQWdHl85bs5b2W9J1IumEe+vbc7Cgh6ut5q5Wqy11xkYHZmRDmPydSQ9PLEkA7US877mtNz9N0+9Canh3rykh6pzAaqit6Gj1eQhk4FH2ovOpSHH2V5bx9h/t3vWfndtr5eRk4Z4M/WoFk1aXHzudhgmAdzW5kotlmp6BIG+0dqLQUsbKrKQqGs9cy+yjD2dIWKxPOXstbrS7BUk/oE84uSQTtrsZ1OLsibd9nOFvaYjXC2WtJWwu7yuHsktBrJ+X1OllFUr7PcLa0xWosk60lbS3lkmUy5eLZJSmgnaQb2Ylbrek70fS9xrPlTS479TpiVZ/ztpZ1IzsPUyn6URZ+lSX94p/bh1HwPHo+f/y4/xM0W5+fhiT88URAEHJOMAnMJcVpBUAywEtiImsCINvt55tHSspItRSzOgBSBNV8uh9FAETavJMOgGyDh6n8VVjabbUDIDskgnbX43rVrCJt32cARNq801012waMjp7Cruqq2Q4poJ2k16tmVWn6PiMh8uad7qLZVmi0NFV1yaLZiL/vSC9Bz4NfO0UvvferVvRjiIPIsdXrPt3U9Ebdyt6oD1CAwuGby86rl67ncUA/Xc+Sotb13ej6Pvf2ybHNRrpuDr22Xq2yN/VU9nTMrkS447eTvh3/Ivt+KKCdsBv1iziqEvai+wGrW4PJTsbUFvaEzPoJuyF5FUeyVTfSTtnzOKCdspv1jrGKlH3+mv3D3bKf7p6xre7WbD11XfKWtJACOsl/+lBJSc+DXztJN+oXoVYl6UWfXa3uZj07OVdZ0g31dxnI+519kPXUdxnsEn7tJN20MsBD14Pp46RMCofYwwHwrxfWbvyBJOgK6BZl+jjGnI/WfyGlkdh+ACYUM9OQjnyRy8Ah0d/pOOeJV574ZqfJq9ly5lUkUvGmhkv+gShmuH5IiBYbbxDvtzjEXSnyhO9BECUZS8WSfvPO5lJHmEI8IY4ote4rGDS9kuU6O2fVj0AfxGNw+axrOPWLX9CW2bq6D8L8+r2ipAPiqAo41Ko5tAmH1r165rccyltfKMyhnLsEllx8uyxhxuLbcNb1/w== \ No newline at end of file diff --git a/api/docs/database/financial-hub_DDL.sql b/api/docs/database/financial-hub_DDL.sql index ab194c7..b35b283 100644 --- a/api/docs/database/financial-hub_DDL.sql +++ b/api/docs/database/financial-hub_DDL.sql @@ -10,3 +10,31 @@ CREATE TABLE accounts( update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), ); + +CREATE TABLE categories( + id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), + name VARCHAR(200) NOT NULL, + description VARCHAR(500) NULL, + active BIT DEFAULT 1, + update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), + creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), +); + +CREATE TABLE transactions( + id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), + description VARCHAR(500) NULL, + + amount MONEY NOT NULL, + target_date DATETIMEOFFSET NOT NULL, + finish_date DATETIMEOFFSET NOT NULL, + + account_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES accounts(id) NOT NULL, + category_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES categories(id) NOT NULL, + + status INT NOT NULL, + type INT NOT NULL, + active BIT DEFAULT 1, + + update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), + creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), +); \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs index 79103bd..a3040ec 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.DataAnnotations.Schema; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; namespace FinancialHub.Domain.Entities { @@ -13,5 +14,7 @@ public class AccountEntity : BaseEntity public string Currency { get; set; } [Column("active")] public bool IsActive { get; set; } + + public ICollection Transactions { get; set; } } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs index eae8c3f..8962c0c 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs @@ -7,8 +7,10 @@ public abstract class BaseEntity { [Column("id")] public Guid? Id { get; set; } + [Column("creation_time")] public DateTimeOffset? CreationTime { get; set; } + [Column("update_time")] public DateTimeOffset? UpdateTime { get; set; } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs new file mode 100644 index 0000000..94218ca --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; + +namespace FinancialHub.Domain.Entities +{ + [Table("categories")] + public class CategoryEntity : BaseEntity + { + [Column("name")] + public string Name { get; set; } + [Column("description")] + public string Description { get; set; } + [Column("active")] + public bool IsActive { get; set; } + + public ICollection Transactions { get; set; } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs new file mode 100644 index 0000000..f612ad8 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs @@ -0,0 +1,38 @@ +using System; +using FinancialHub.Domain.Enums; +using System.ComponentModel.DataAnnotations.Schema; + +namespace FinancialHub.Domain.Entities +{ + [Table("transactions")] + public class TransactionEntity : BaseEntity + { + [Column("description")] + public string Description { get; set; } + + [Column("amount")] + public decimal Amount { get; set; } + + [Column("target_date")] + public DateTimeOffset TargetDate { get; set; } + [Column("finish_date")] + public DateTimeOffset FinishDate { get; set; } + + [Column("account_id")] + public Guid AccountId { get; set; } + public AccountEntity Account { get; set; } + + [Column("category_id")] + [ForeignKey("category_id")] + public Guid CategoryId { get; set; } + public CategoryEntity Category { get; set; } + + [Column("active")] + public bool IsActive { get; set; } + + [Column("status")] + public TransactionStatus Status { get; set; } + [Column("type")] + public TransactionType Type { get; set; } + } +} \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs b/api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs new file mode 100644 index 0000000..be0f978 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs @@ -0,0 +1,10 @@ +namespace FinancialHub.Domain.Enums +{ + public enum TransactionStatus + { + NotCommitted = 0, + Committed = 1, + //Aborted = 2, + //Rollback = 3 + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs b/api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs new file mode 100644 index 0000000..5b9f784 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs @@ -0,0 +1,8 @@ +namespace FinancialHub.Domain.Enums +{ + public enum TransactionType + { + Earn = 1, + Expense = 2 + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs b/api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs new file mode 100644 index 0000000..23483c6 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs @@ -0,0 +1,49 @@ +using System; +using FinancialHub.Domain.Enums; + +namespace FinancialHub.Domain.Filters +{ + public class TransactionFilter + { + public DateTime? StartDate { get; set; } + public DateTime? EndDate { get; set; } + + public TransactionType[] Types { get; set; } + public TransactionStatus[] Status { get; set; } + + //TODO: get a better way to add/get array queries + public Guid[] Accounts { get; set; } + public Guid[] Categories { get; set; } + + //public string Accounts { get; set; } + //public string Categories { get; set; } + + //public Guid[] AccountsIds + //{ + // get + // { + // return this.GetIds(Accounts); + // } + //} + //public Guid[] CategoriesId + //{ + // get + // { + // return this.GetIds(Categories); + // } + //} + + //public Guid[] GetIds(string value) + //{ + // var arr = value?.Split(',') ?? Array.Empty(); + // var res = new Guid[arr.Length]; + + // for (var i = 0; i < arr.Length; i++) + // { + // res[i] = new Guid(arr[i]); + // } + + // return res; + //} + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj b/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj index b5e5cf5..4f9a474 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj +++ b/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs index 118cb5e..aebca4d 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs @@ -26,7 +26,7 @@ public interface IBaseRepository /// Deletes an entity from the database /// /// Id of the entity to be removed - Task DeleteAsync(string id); + Task DeleteAsync(Guid id); /// /// Get All entities from the database /// @@ -39,6 +39,6 @@ public interface IBaseRepository /// Gets an entity by id /// /// Id of the choosen entity - Task GetByIdAsync(string id); + Task GetByIdAsync(Guid id); } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs new file mode 100644 index 0000000..2aeee11 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs @@ -0,0 +1,8 @@ +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Domain.Interfaces.Repositories +{ + public interface ICategoriesRepository : IBaseRepository + { + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs new file mode 100644 index 0000000..932a798 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs @@ -0,0 +1,8 @@ +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Domain.Interfaces.Repositories +{ + public interface ITransactionsRepository : IBaseRepository + { + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs index d9bd870..c7f28d9 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs @@ -1,4 +1,5 @@ using FinancialHub.Domain.Models; +using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -10,8 +11,8 @@ public interface IAccountsService Task CreateAsync(AccountModel account); - Task UpdateAsync(string id,AccountModel account); + Task UpdateAsync(Guid id,AccountModel account); - Task DeleteAsync(string id); + Task DeleteAsync(Guid id); } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs new file mode 100644 index 0000000..1d5c830 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs @@ -0,0 +1,18 @@ +using FinancialHub.Domain.Models; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace FinancialHub.Domain.Interfaces.Services +{ + public interface ICategoriesService + { + Task> GetAllByUserAsync(string userId); + + Task CreateAsync(CategoryModel category); + + Task UpdateAsync(Guid id, CategoryModel category); + + Task DeleteAsync(Guid id); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs new file mode 100644 index 0000000..2802005 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs @@ -0,0 +1,19 @@ +using System; +using System.Threading.Tasks; +using System.Collections.Generic; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Filters; + +namespace FinancialHub.Domain.Interfaces.Services +{ + public interface ITransactionsService + { + Task> GetAllByUserAsync(string userId, TransactionFilter filter); + + Task CreateAsync(TransactionModel account); + + Task UpdateAsync(Guid id, TransactionModel account); + + Task DeleteAsync(Guid id); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs b/api/src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs new file mode 100644 index 0000000..da2e449 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs @@ -0,0 +1,11 @@ +using FinancialHub.Domain.Model; + +namespace FinancialHub.Domain.Models +{ + public class CategoryModel : BaseModel + { + public string Name { get; set; } + public string Description { get; set; } + public bool IsActive { get; set; } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs b/api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs new file mode 100644 index 0000000..7c47c33 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs @@ -0,0 +1,26 @@ +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Model; +using System; + +namespace FinancialHub.Domain.Models +{ + public class TransactionModel : BaseModel + { + public string Description { get; set; } + public decimal Amount { get; set; } + + public DateTimeOffset TargetDate { get; set; } + public DateTimeOffset FinishDate { get; set; } + + public Guid AccountId { get; set; } + public AccountModel Account { get; set; } + + public Guid CategoryId { get; set; } + public CategoryModel Category { get; set; } + + public bool IsActive { get; set; } + + public TransactionStatus Status { get; set; } + public TransactionType Type { get ; set ;} + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs b/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs new file mode 100644 index 0000000..b3de0ac --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs @@ -0,0 +1,137 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; + +namespace FinancialHub.Domain.Queries +{ + public class TransactionQuery + { + [Obsolete("Not Used yet")] + public string UserId { get; set; } + public DateTime? StartDate { get; set; } + public DateTime? EndDate { get; set; } + + public Guid[] Accounts { get; set; } + public Guid[] Categories { get; set; } + + public TransactionType[] Types { get; set; } + public TransactionStatus[] Status { get; set; } + + //public Guid[] AccountsIds { get; set; } + //public Guid[] CategoriesIds { get; set; } + + public Func Query() + { + //TODO: compare performance + return this.QueryFuncs(); + } + + private Func QueryFuncs() + { + var queries = new List>(); + + queries.Add((ent) => ent.IsActive); + + if (StartDate != null) + { + if (EndDate == null) + { + StartDate = new DateTime(StartDate.Value.Year, StartDate.Value.Month,1); + EndDate = StartDate.Value.AddMonths(2).AddSeconds(-1); + } + queries.Add((ent) => ent.TargetDate >= StartDate && ent.TargetDate <= EndDate); + } + + if (Accounts.Length > 0) + { + queries.Add((ent) => Accounts.Contains(ent.AccountId)); + } + + if (Categories.Length > 0) + { + queries.Add((ent) => Categories.Contains(ent.CategoryId)); + } + + if (Types.Length > 0) + { + queries.Add((ent) => Types.Contains(ent.Type)); + } + + if (Status.Length > 0) + { + queries.Add((ent) => Status.Contains(ent.Status)); + } + + return (ent) => queries.All(query => query(ent)); + } + + private Func QueryFunc() + { + Func query; + + if (EndDate == null) + { + query = (ent) => ent.TargetDate == StartDate; + } + else + { + query = (ent) => ent.TargetDate >= StartDate && ent.TargetDate <= EndDate; + } + + //TODO: idk how to add it + if (Accounts.Length > 0) + { + + } + + if (Categories.Length > 0) + { + + } + + return query; + } + + [Obsolete("Not working : exception at Expression.And")] + private Func QueryExpression() + { + //TODO: do a better filter system (IQueryable Results on repository) + var expressions = new List>>(); + expressions.Add((ent) => ent.IsActive); + + if (EndDate == null) + { + expressions.Add((ent) => ent.TargetDate == StartDate); + } + else + { + expressions.Add((ent) => ent.TargetDate >= StartDate && ent.TargetDate <= EndDate); + } + + if (Accounts.Length > 0) + { + expressions.Add((ent) => Accounts.Contains(ent.AccountId)); + } + + if (Categories.Length > 0) + { + expressions.Add((ent) => Accounts.Contains(ent.CategoryId)); + } + + Expression expression = expressions.First(); + + foreach (var exp in expressions.Skip(1)) + { + expression = Expression.And(expression, exp); + } + + var parameter = Expression.Parameter(typeof(TransactionEntity), "ent"); + var query = Expression.Lambda>(expression, parameter); + + return query.Compile(); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs b/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs index eae47b8..726501e 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs +++ b/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs @@ -10,11 +10,33 @@ public FinancialHubContext([NotNull] DbContextOptions options) : base(options) { } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + protected override void OnModelCreating(ModelBuilder modelBuilder) { - base.OnConfiguring(optionsBuilder); + modelBuilder.Entity(table => + { + table.HasKey(t => t.Id); + table.HasIndex(t => t.Id) + .IsUnique(true); + + table.HasOne(x => x.Account) + .WithMany(x => x.Transactions) + .HasForeignKey(x => x.AccountId) + .HasPrincipalKey(x => x.Id) + .IsRequired(true); + table.Navigation(t => t.Account).AutoInclude(); + + table.HasOne(x => x.Category) + .WithMany(x => x.Transactions) + .HasForeignKey(x => x.CategoryId) + .HasPrincipalKey(x => x.Id) + .IsRequired(true); + table.Navigation(t => t.Category).AutoInclude(); + }); + base.OnModelCreating(modelBuilder); } - public DbSet Accounts { get; set;} + public DbSet Accounts { get; set; } + public DbSet Transactions { get; set; } + public DbSet Categories { get; set; } } } diff --git a/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj b/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj index 4971597..67a1bde 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj +++ b/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj @@ -1,12 +1,12 @@  - net5.0 + net6.0 - + diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs index 96bdccd..17208f9 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs +++ b/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs @@ -13,23 +13,26 @@ public class BaseRepository : IBaseRepository where T : BaseEntity { - private readonly FinancialHubContext context; + protected readonly FinancialHubContext context; public BaseRepository(FinancialHubContext context) { this.context = context; } - public async Task CreateAsync(T obj) + public virtual async Task CreateAsync(T obj) { obj.Id = null; - var res = await context.AddAsync(obj); + obj.CreationTime = DateTimeOffset.Now; + obj.UpdateTime = DateTimeOffset.Now; + + var res = await context.Set().AddAsync(obj); await context.SaveChangesAsync(); return res.Entity; } - public async Task DeleteAsync(string id) + public virtual async Task DeleteAsync(Guid id) { - var entity = context.Set().FirstOrDefault(x => x.Id.ToString() == id); + var entity = context.Set().FirstOrDefault(x => x.Id == id); if(entity != null) { @@ -42,7 +45,7 @@ public async Task DeleteAsync(string id) } } - public async Task UpdateAsync(T obj) + public virtual async Task UpdateAsync(T obj) { obj.UpdateTime = DateTimeOffset.Now; var res = context.Set().Update(obj); @@ -50,19 +53,19 @@ public async Task UpdateAsync(T obj) return res.Entity; } - public async Task> GetAllAsync() + public virtual async Task> GetAllAsync() { return await context.Set().ToListAsync(); } - public async Task> GetAsync(Func predicate) + public virtual async Task> GetAsync(Func predicate) { return context.Set().Where(predicate).ToList(); } - public async Task GetByIdAsync(string id) + public virtual async Task GetByIdAsync(Guid id) { - return await context.Set().FirstOrDefaultAsync(x => x.Id.ToString() == id); + return await context.Set().FirstOrDefaultAsync(x => x.Id == id); } } } diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs new file mode 100644 index 0000000..31b0757 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs @@ -0,0 +1,13 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Infra.Contexts; + +namespace FinancialHub.Infra.Repositories +{ + public class CategoriesRepository : BaseRepository, ICategoriesRepository + { + public CategoriesRepository(FinancialHubContext context) : base(context) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs new file mode 100644 index 0000000..2e2ede4 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs @@ -0,0 +1,35 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Infra.Contexts; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Repositories +{ + public class TransactionsRepository : BaseRepository, ITransactionsRepository + { + public TransactionsRepository(FinancialHubContext context) : base(context) + { + } + + public override async Task CreateAsync(TransactionEntity obj) + { + #warning This is not a good practice, remove this later + if(obj == null) + { + throw new ArgumentNullException(nameof(obj)); + } + + obj.Category = null; + obj.Account = null; + return await base.CreateAsync(obj); + } + + public override async Task UpdateAsync(TransactionEntity obj) + { + obj.Category = null; + obj.Account = null; + return await base.UpdateAsync(obj); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs b/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs index d4728d3..5d6c445 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs +++ b/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs @@ -23,15 +23,13 @@ public AccountsService(IMapper mapper,IAccountsRepository repository) public async Task CreateAsync(AccountModel account) { var entity = mapper.Map(account); - entity.CreationTime = DateTimeOffset.Now; - entity.UpdateTime = DateTimeOffset.Now; entity = await this.repository.CreateAsync(entity); return mapper.Map(entity); } - public async Task DeleteAsync(string id) + public async Task DeleteAsync(Guid id) { return await this.repository.DeleteAsync(id); } @@ -42,7 +40,7 @@ public async Task> GetAllByUserAsync(string userId) return mapper.Map>(entities); } - public async Task UpdateAsync(string id, AccountModel account) + public async Task UpdateAsync(Guid id, AccountModel account) { var entity = await this.repository.GetByIdAsync(id); @@ -50,7 +48,7 @@ public async Task UpdateAsync(string id, AccountModel account) { throw new NullReferenceException($"Not found account with id {id}"); } - entity.Id = new Guid(id); + entity.Id = id; entity = await this.repository.UpdateAsync(entity); diff --git a/api/src/FinancialHub/FinancialHub.Infra/Services/CategoriesService.cs b/api/src/FinancialHub/FinancialHub.Infra/Services/CategoriesService.cs new file mode 100644 index 0000000..d65fff8 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra/Services/CategoriesService.cs @@ -0,0 +1,58 @@ +using System; +using AutoMapper; +using System.Threading.Tasks; +using FinancialHub.Domain.Models; +using System.Collections.Generic; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Interfaces.Repositories; + +namespace FinancialHub.Infra.Services +{ + public class CategoriesService : ICategoriesService + { + private readonly IMapper mapper; + private readonly ICategoriesRepository repository; + + public CategoriesService(IMapper mapper, ICategoriesRepository repository) + { + this.mapper = mapper; + this.repository = repository; + } + + public async Task CreateAsync(CategoryModel category) + { + var entity = mapper.Map(category); + + entity = await this.repository.CreateAsync(entity); + + return mapper.Map(entity); + } + + public async Task DeleteAsync(Guid id) + { + return await this.repository.DeleteAsync(id); + } + + public async Task> GetAllByUserAsync(string userId) + { + var entities = await this.repository.GetAllAsync(); + return mapper.Map>(entities); + } + + public async Task UpdateAsync(Guid id, CategoryModel category) + { + var entity = await this.repository.GetByIdAsync(id); + + if (entity == null) + { + throw new NullReferenceException($"Not found category with id {id}"); + } + entity.Id = id; + + entity = await this.repository.UpdateAsync(entity); + + return mapper.Map(entity); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Services/TransactionsService.cs b/api/src/FinancialHub/FinancialHub.Infra/Services/TransactionsService.cs new file mode 100644 index 0000000..48224bd --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra/Services/TransactionsService.cs @@ -0,0 +1,64 @@ +using AutoMapper; +using FinancialHub.Domain.Entities; +using System; +using System.Threading.Tasks; +using System.Collections.Generic; +using FinancialHub.Domain.Filters; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Queries; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Interfaces.Repositories; + +namespace FinancialHub.Infra.Services +{ + public class TransactionsService : ITransactionsService + { + private readonly IMapper mapper; + private readonly ITransactionsRepository repository; + + public TransactionsService(IMapper mapper, ITransactionsRepository repository)//TODO: custom mapper + { + this.mapper = mapper; + this.repository = repository; + } + + public async Task CreateAsync(TransactionModel category) + { + var entity = mapper.Map(category); + + entity = await this.repository.CreateAsync(entity); + + return mapper.Map(entity); + } + + public async Task DeleteAsync(Guid id) + { + return await this.repository.DeleteAsync(id); + } + + public async Task> GetAllByUserAsync(string userId, TransactionFilter filter) + { + var query = mapper.Map(filter); + //query.UserId = userId; + + var entities = await this.repository.GetAsync(query.Query()); + + return mapper.Map>(entities); + } + + public async Task UpdateAsync(Guid id, TransactionModel category) + { + var entity = await this.repository.GetByIdAsync(id); + + if (entity == null) + { + throw new NullReferenceException($"Not found category with id {id}"); + } + entity.Id = id; + + entity = await this.repository.UpdateAsync(entity); + + return mapper.Map(entity); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs index e062510..c8b56e5 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs @@ -44,7 +44,7 @@ public async Task GetMyAccounts() /// Account to be created [HttpPost] [ProducesResponseType(typeof(ICollection),200)] - public async Task CreateAccount(AccountModel account) + public async Task CreateAccount([FromBody] AccountModel account) { try { @@ -64,7 +64,7 @@ public async Task CreateAccount(AccountModel account) /// account changes [HttpPut("{id}")] [ProducesResponseType(typeof(ICollection), 200)] - public async Task UpdateAccount(string id,AccountModel account) + public async Task UpdateAccount([FromRoute] Guid id, [FromBody] AccountModel account) { try { @@ -82,7 +82,7 @@ public async Task UpdateAccount(string id,AccountModel account) /// /// id of the account [HttpDelete("{id}")] - public async Task DeleteAccount(string id) + public async Task DeleteAccount([FromRoute] Guid id) { try { diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs new file mode 100644 index 0000000..7bf194d --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs @@ -0,0 +1,98 @@ +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Models; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.Controllers +{ + [ApiController] + [Route("[controller]")] + [Produces("application/json")] + [ProducesErrorResponseType(typeof(Exception))] + public class CategoriesController : Controller + { + private readonly ICategoriesService service; + + public CategoriesController(ICategoriesService service) + { + this.service = service; + } + + [HttpGet] + [ProducesResponseType(typeof(ICollection), 200)] + /// + /// Get all categorys of the system (will be changed to only one user) + /// + public async Task GetMyCategories() + { + try + { + var response = await service.GetAllByUserAsync("mock"); + return Ok(response); + } + catch (Exception e) + { + return BadRequest(e); + } + } + + [HttpPost] + [ProducesResponseType(typeof(ICollection), 200)] + /// + /// Creates an category on database (will be changed to only one user) + /// + /// Account to be created + public async Task CreateCategory([FromBody] CategoryModel category) + { + try + { + var response = await service.CreateAsync(category); + return Ok(response); + } + catch (Exception e) + { + return BadRequest(e); + } + } + + [HttpPut("{id}")] + [ProducesResponseType(typeof(ICollection), 200)] + /// + /// Updates an existing category on database + /// + /// id of the category + /// category changes + public async Task UpdateCategory([FromRoute] Guid id, [FromBody] CategoryModel category) + { + try + { + var response = await service.UpdateAsync(id, category); + return Ok(response); + } + catch (Exception e) + { + return BadRequest(e); + } + } + + [HttpDelete("{id}")] + /// + /// Deletes an existing category on database + /// + /// id of the category + public async Task DeleteCategory([FromRoute] Guid id) + { + try + { + await service.DeleteAsync(id); + return NoContent(); + } + catch (Exception e) + { + return BadRequest(e); + } + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs new file mode 100644 index 0000000..ef21932 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs @@ -0,0 +1,102 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using FinancialHub.Domain.Models; +using System.Collections.Generic; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Filters; + +namespace FinancialHub.WebApi.Controllers +{ + [ApiController] + [Route("[controller]")] + [Produces("application/json")] + [ProducesErrorResponseType(typeof(Exception))]//TODO: custom exceptions + public class TransactionsController : Controller + { + private readonly ITransactionsService service; + + public TransactionsController(ITransactionsService service) + { + this.service = service; + } + + [HttpGet] + [ProducesResponseType(typeof(ICollection), 200)] + /// + /// Get all transaction of the system (will be changed to only one user and added filters) + /// + public async Task GetMyTransactions( + [FromQuery] TransactionFilter filter + ) + { + try + { + var response = await service.GetAllByUserAsync("mock", filter); + return Ok(response); + } + catch (Exception e) + { + return BadRequest(e); + } + } + + [HttpPost] + [ProducesResponseType(typeof(ICollection), 200)] + /// + /// Creates an transaction on database (will be changed to only one user) + /// + /// Transaction to be created + public async Task CreateTransaction([FromBody] TransactionModel transaction) + { + try + { + var response = await service.CreateAsync(transaction); + return Ok(response); + } + catch (Exception e) + { + return BadRequest(e); + } + } + + [HttpPut("{id}")] + [ProducesResponseType(typeof(ICollection), 200)] + /// + /// Updates an existing transaction on database + /// + /// id of the transaction + /// transaction changes + public async Task UpdateTransaction([FromRoute] Guid id, [FromBody] TransactionModel transaction) + { + try + { + var response = await service.UpdateAsync(id, transaction); + return Ok(response); + } + catch (Exception e) + { + return BadRequest(e); + } + } + + [HttpDelete("{id}")] + [ProducesResponseType(204)] + /// + /// Deletes an existing transaction on database + /// + /// id of the transaction + public async Task DeleteTransaction([FromRoute] Guid id) + { + try + { + await service.DeleteAsync(id); + return NoContent(); + } + catch (Exception e) + { + return BadRequest(e); + } + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs index a36e0b7..fc46e58 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -24,12 +24,16 @@ public static IServiceCollection AddApiConfigurations(this IServiceCollection se public static IServiceCollection AddRepositories(this IServiceCollection services) { services.AddScoped(); + services.AddScoped(); + services.AddScoped(); return services; } public static IServiceCollection AddServices(this IServiceCollection services) { services.AddScoped(); + services.AddScoped(); + services.AddScoped(); return services; } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj index ee32e78..58a3ac6 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -1,25 +1,28 @@ - net5.0 + net6.0 + - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + + diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs index 452c16d..6fa98d6 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs @@ -1,6 +1,8 @@ using AutoMapper; -using FinancialHub.Domain.Entities; using FinancialHub.Domain.Models; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Filters; +using FinancialHub.Domain.Queries; namespace FinancialHub.WebApi { @@ -8,7 +10,13 @@ public class FinancialHubAutoMapperProfile : Profile { public FinancialHubAutoMapperProfile() { + //Entities CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + + //Queries + CreateMap().ReverseMap(); } } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs index cd67adf..e0a9478 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs @@ -2,7 +2,6 @@ using FinancialHub.WebApi.Extensions.Configurations; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -39,8 +38,10 @@ public void ConfigureServices(IServiceCollection services) //services.AddHealthCheck(); services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "FinancialHub WebApi", Version = "v1" }); + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Financial Hub WebApi", Version = "v1" }); }); + + services.AddMvc().AddNewtonsoftJson(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj index 89336fb..bb0dc2e 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj @@ -1,17 +1,22 @@ - + - net5.0 + net6.0 false - - - - - + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs new file mode 100644 index 0000000..a63e0a3 --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs @@ -0,0 +1,71 @@ +using Bogus; +using System; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Enums; + +namespace FinancialHub.Infra.NUnitTests.Generators +{ + public class EntityGenerator + { + private readonly Random random; + + public EntityGenerator(Random random) + { + this.random = random; + } + + public AccountEntity GenerateAccount(Guid? id = null) + { + var fake = new Faker(); + + fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) + .RuleFor(x => x.Name, fake => fake.Finance.AccountName()) + .RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code) + .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1,5))) + .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) + .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) + .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); + + return fake.Generate(); + } + + public CategoryEntity GenerateCategory(Guid? id = null) + { + var fake = new Faker(); + + fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) + .RuleFor(x => x.Name, fake => fake.Finance.Random.Word()) + .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) + .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) + .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) + .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); + + return fake.Generate(); + } + + public TransactionEntity GenerateTransaction(Guid? id = null, Guid? accountId = null, Guid? categoryId = null) + { + var account = this.GenerateAccount(accountId); + var category = this.GenerateCategory(categoryId); + + var fake = new Faker(); + + fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) + .RuleFor(x => x.Amount , fake => fake.Random.Decimal(0,10000)) + .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) + .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) + .RuleFor(x => x.Type, fake => fake.PickRandom()) + .RuleFor(x => x.Status , fake => fake.PickRandom()) + .RuleFor(x => x.AccountId, fake => account.Id) + .RuleFor(x => x.Account, fake => account) + .RuleFor(x => x.CategoryId, fake => category.Id) + .RuleFor(x => x.Category, fake => category) + .RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset()) + .RuleFor(x => x.FinishDate, fake => fake.Date.RecentOffset()) + .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) + .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); + + return fake.Generate(); + } + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs index 7949183..43ede64 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs @@ -1,6 +1,5 @@ using System; using NUnit.Framework; -using System.Collections.Generic; using FinancialHub.Domain.Entities; using FinancialHub.Infra.Repositories; using FinancialHub.Infra.NUnitTests.Repositories.Base; @@ -16,33 +15,10 @@ protected override void Setup() this.repository = new AccountsRepository(this.context); } - protected override ICollection GenerateData(int min = 1, int max = 100, params object[] props) + protected override AccountEntity GenerateObject(Guid? id = null) { - var count = random.Next(min,max); - var accounts = new AccountEntity[count]; - for (int i = 0; i < count; i++) - { - accounts[i] = this.GenerateObject(Guid.NewGuid(), props); - } - - return accounts; - } - - protected override AccountEntity GenerateObject(Guid? id = null, params object[] props) - { - var active = random.Next(0,1); - - return new AccountEntity() - { - Id = id, - Name = props.Length > 0 ? props[0].ToString() : Guid.NewGuid().ToString(), - Description = props.Length > 1 ? props[1].ToString() : Guid.NewGuid().ToString(), - Currency = props.Length > 2 ? props[2].ToString() : Guid.NewGuid().ToString(), - IsActive = props.Length > 3 ? (bool)props[3] : active == 1, - CreationTime = DateTimeOffset.UtcNow, - UpdateTime = DateTimeOffset.UtcNow, - }; + return this.generator.GenerateAccount(id); } } } diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs index 8fd1c41..25bd5fe 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs @@ -1,49 +1,64 @@ -using FinancialHub.Domain.Entities; +using System; +using System.Linq; using NUnit.Framework; -using System; using System.Threading.Tasks; +using FinancialHub.Domain.Entities; namespace FinancialHub.Infra.NUnitTests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity { - #region Create - [Test] - [TestCase(TestName = "Create New Item", Category = "Create")] - public async Task CreateAsync_ValidItem_AddsOneRow() + protected virtual void AssertCreated(T createdItem) { - var item = this.GenerateObject(); - - var createdItem = await this.repository.CreateAsync(item); - Assert.IsNotNull(createdItem); Assert.IsNotNull(createdItem.Id); Assert.IsNotNull(createdItem.CreationTime); Assert.IsNotNull(createdItem.UpdateTime); Assert.IsInstanceOf(createdItem); + + Assert.IsNotEmpty(context.Set().ToList()); } + #region Create [Test] - [TestCase(TestName = "Create New Item With Id", Category = "Create")] - public async Task CreateAsync_ValidItemWithId_AddsOneRow() + [TestCase(TestName = "Create new Item", Category = "Create")] + public virtual async Task CreateAsync_ValidItem_AddsOneRow(T item = null) { - var id = Guid.NewGuid(); - var item = this.GenerateObject(id); + item ??= this.GenerateObject(); var createdItem = await this.repository.CreateAsync(item); - Assert.IsNotNull(createdItem); + this.AssertCreated(createdItem); + } + + [Test] + [TestCase(TestName = "Create new Item with id", Category = "Create")] + public virtual async Task CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(T item = null) + { + var id = item == null ? Guid.NewGuid() : item.Id.GetValueOrDefault(); + item ??= this.GenerateObject(id); + + var createdItem = await this.repository.CreateAsync(item); + + this.AssertCreated(createdItem); Assert.AreNotEqual(id,createdItem.Id); - Assert.IsNotNull(createdItem.CreationTime); - Assert.IsNotNull(createdItem.UpdateTime); - Assert.IsInstanceOf(createdItem); } [Test] - [TestCase(TestName = "Create Null Item With Id", Category = "Create")] - public async Task CreateAsync_NullItem_ThrowsNullReferenceException() + [TestCase(TestName = "Create item with existing id", Category = "Create")] + public virtual async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithTheDifferentId(T item = null) { - Assert.ThrowsAsync(async () => await this.repository.CreateAsync(null)); + var id = item == null ? Guid.NewGuid() : item.Id.GetValueOrDefault(); + + item ??= this.GenerateObject(id); + await this.InsertData(item); + + item ??= this.GenerateObject(id); + + var result = await this.repository.CreateAsync(item); + + this.AssertCreated(result); + Assert.AreEqual(2,context.Set().Count()); } #endregion } diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs index e696055..f95891e 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs @@ -6,24 +6,41 @@ using FinancialHub.Domain.Interfaces.Repositories; using System.Collections.Generic; using System.Threading.Tasks; +using Microsoft.Data.Sqlite; +using FinancialHub.Infra.NUnitTests.Generators; namespace FinancialHub.Infra.NUnitTests.Repositories.Base { - public abstract partial class BaseRepositoryTests where T: BaseEntity + public abstract partial class BaseRepositoryTests where T : BaseEntity { protected Random random; - + protected EntityGenerator generator; protected FinancialHubContext context; + protected IBaseRepository repository; - [SetUp] - protected virtual void Setup() + protected FinancialHubContext GetContext() { - this.context = new FinancialHubContext( - new DbContextOptionsBuilder().UseInMemoryDatabase($"Database_{Guid.NewGuid()}").Options + var conn = new SqliteConnection("DataSource=:memory:"); + conn.Open(); + + var cfg = new DbContextOptionsBuilder().UseSqlite(conn); + cfg.EnableSensitiveDataLogging(true); + + return new FinancialHubContext( + cfg.Options ); + } + + [SetUp] + protected virtual void Setup() + { + this.context = this.GetContext(); + context.Database.EnsureCreated(); this.random = new Random(); + + this.generator = new EntityGenerator(random); } [TearDown] @@ -32,14 +49,46 @@ protected virtual void TearDown() this.context.Dispose(); } - protected virtual async Task InsertData(ICollection items) + #region Generics + protected virtual async Task> InsertData(ICollection items) + where Y : BaseEntity { - await this.context.Set().AddRangeAsync(items); + var list = new List(); + foreach (var item in items) + { + var entity = await this.context.Set().AddAsync(item); + await this.context.SaveChangesAsync(); + list.Add(entity.Entity); + } await this.context.SaveChangesAsync(); + return list; } - protected abstract ICollection GenerateData(int min = 1,int max = 100, params object[] props); + protected virtual async Task InsertData(Y item) + where Y : BaseEntity + { + var res = await this.context.Set().AddAsync(item); + item.Id = res.Entity.Id; + await this.context.SaveChangesAsync(); + + return res.Entity; + } + + #endregion + + protected virtual ICollection GenerateData(int min = 1, int max = 100) + { + var count = random.Next(min, max); + var data = new T[count]; + + for (int i = 0; i < count; i++) + { + data[i] = this.GenerateObject(Guid.NewGuid()); + } + + return data; + } - protected abstract T GenerateObject(Guid? id = null, params object[] props); + protected abstract T GenerateObject(Guid? id = null); } } diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs index 3706823..a52c470 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs @@ -10,36 +10,27 @@ public abstract partial class BaseRepositoryTests where T : BaseEntity { #region Delete [Test] - [TestCase(TestName = "Delete Existing Item",Category = "Delete")] - public async Task DeleteAsync_ExistingItem_AffectsOneRow() + [TestCase(TestName = "Delete existing Item",Category = "Delete")] + public virtual async Task DeleteAsync_ExistingItem_AffectsOneRow() { var items = this.GenerateData(); await this.InsertData(items); - var affectedRows = await this.repository.DeleteAsync(items.First().Id.ToString()); + var affectedRows = await this.repository.DeleteAsync(items.First().Id.Value); Assert.AreEqual(1,affectedRows); + Assert.AreEqual(items.Count - 1,context.Set().ToList().Count); } [Test] - [TestCase(TestName = "Delete Non Existing Item",Category = "Delete")] - public async Task DeleteAsync_NonExistingItem_AffectsNothing() + [TestCase(TestName = "Delete non existing Item",Category = "Delete")] + public virtual async Task DeleteAsync_NonExistingItem_AffectsNothing() { var items = this.GenerateData(); await this.InsertData(items); - var affectedRows = await this.repository.DeleteAsync(new Guid().ToString()); - Assert.AreEqual(0, affectedRows); - } - - [Test] - [TestCase(TestName = "Delete Null id Item", Category = "Delete")] - public async Task DeleteAsync_NullId_AffectsNothing() - { - var items = this.GenerateData(); - await this.InsertData(items); - - var affectedRows = await this.repository.DeleteAsync(null); + var affectedRows = await this.repository.DeleteAsync(new Guid()); Assert.AreEqual(0, affectedRows); + Assert.IsNotEmpty(context.Set().ToList()); } #endregion } diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs index 722b50d..2a52636 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs @@ -12,7 +12,7 @@ public abstract partial class BaseRepositoryTests where T : BaseEntity #region Get All [Test] [TestCase(TestName = "Get All Items without data",Category = "Get")] - public async Task GetAllAsync_NoData_ReturnsEmpty() + public virtual async Task GetAllAsync_NoData_ReturnsEmpty() { var list = await this.repository.GetAllAsync(); @@ -22,10 +22,10 @@ public async Task GetAllAsync_NoData_ReturnsEmpty() [Test] [TestCase(TestName = "Get All Items with data", Category = "Get")] - public async Task GetAllAsync_Data_ReturnsItems() + public virtual async Task GetAllAsync_Data_ReturnsItems() { var items = this.GenerateData(); - await this.InsertData(items); + items = await this.InsertData(items); var list = await this.repository.GetAllAsync(); @@ -38,10 +38,10 @@ public async Task GetAllAsync_Data_ReturnsItems() #region Get [Test] [TestCase(TestName = "Get Items with no filter", Category = "Get")] - public async Task GetAsync_NoFilter_ReturnsAllItems() + public virtual async Task GetAsync_NoFilter_ReturnsAllItems() { var items = this.GenerateData(); - await this.InsertData(items); + items = await this.InsertData(items); var list = await this.repository.GetAsync((x) => true); @@ -52,20 +52,20 @@ public async Task GetAsync_NoFilter_ReturnsAllItems() [Test] [TestCase(TestName = "Get Items not setting filter", Category = "Get")] - public async Task GetAsync_NullFilter_ThrowsArgumentNullException() + public virtual async Task GetAsync_NullFilter_ThrowsArgumentNullException() { var items = this.GenerateData(); - await this.InsertData(items); + items = await this.InsertData(items); Assert.ThrowsAsync(typeof(ArgumentNullException), async () => await this.repository.GetAsync(null)); } [Test] [TestCase(TestName = "Get Items filtering", Category = "Get")] - public async Task GetAsync_Filter_ReturnsFilteredItems() + public virtual async Task GetAsync_Filter_ReturnsFilteredItems() { var items = this.GenerateData(10,100); - await this.InsertData(items); + items = await this.InsertData(items); var id = items.First().Id; Func filter = (x) => x.Id == id; @@ -80,10 +80,10 @@ public async Task GetAsync_Filter_ReturnsFilteredItems() [Test] [TestCase(TestName = "Get Items with wrong filter", Category = "Get")] - public async Task GetAsync_WrongFilter_ReturnsEmpty() + public virtual async Task GetAsync_WrongFilter_ReturnsEmpty() { var items = this.GenerateData(10, 100); - await this.InsertData(items); + items = await this.InsertData(items); Func filter = (x) => x.Id == new Guid(); @@ -97,26 +97,26 @@ public async Task GetAsync_WrongFilter_ReturnsEmpty() #region Get By Id [Test] [TestCase(TestName = "Get By Id with empty id", Category = "Get")] - public async Task GetByIdAsync_EmptyId_ReturnsNull() + public virtual async Task GetByIdAsync_EmptyId_ReturnsNull() { var items = this.GenerateData(); - await this.InsertData(items); + items = await this.InsertData(items); - var item = await this.repository.GetByIdAsync(""); + var item = await this.repository.GetByIdAsync(Guid.Empty); Assert.IsNull(item); } [Test] [TestCase(TestName = "Get By Id with existing id", Category = "Get")] - public async Task GetByIdAsync_ExistingId_ReturnsItem() + public virtual async Task GetByIdAsync_ExistingId_ReturnsItem() { - var items = this.GenerateData(); - await this.InsertData(items); + var items = this.GenerateData(1); + items = await this.InsertData(items); var id = items.First().Id; - var item = await this.repository.GetByIdAsync(id.ToString()); + var item = await this.repository.GetByIdAsync(id.Value); Assert.IsNotNull(item); Assert.AreEqual(id,item.Id); @@ -125,12 +125,12 @@ public async Task GetByIdAsync_ExistingId_ReturnsItem() [Test] [TestCase(TestName = "Get By Id with non-existing id", Category = "Get")] - public async Task GetByIdAsync_NonExistingId_ReturnsNull() + public virtual async Task GetByIdAsync_NonExistingId_ReturnsNull() { var items = this.GenerateData(); - await this.InsertData(items); + items = await this.InsertData(items); - var item = await this.repository.GetByIdAsync(new Guid().ToString()); + var item = await this.repository.GetByIdAsync(new Guid()); Assert.IsNull(item); } diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs index fa62250..8aaa7fd 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs @@ -1,4 +1,5 @@ using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; using NUnit.Framework; using System; using System.Threading.Tasks; @@ -9,8 +10,8 @@ public abstract partial class BaseRepositoryTests where T : BaseEntity { #region Update [Test] - [TestCase(TestName = "Update Existing Item", Category = "Update")] - public async Task UpdateAsync_ExistingItem_UpdatesItem() + [TestCase(TestName = "Update existing Item", Category = "Update")] + public virtual async Task UpdateAsync_ExistingItem_UpdatesItem() { var item = this.GenerateObject(); await this.InsertData(new T[1] { item }); @@ -29,25 +30,12 @@ public async Task UpdateAsync_ExistingItem_UpdatesItem() [Test] [TestCase(TestName = "Update non existing Item", Category = "Update")] - public async Task UpdateAsync_NonExistingItem_DoesNotUpdate() + public virtual async Task UpdateAsync_NonExistingItem_ThrowsDbUpdateConcurrencyException() { var id = Guid.NewGuid(); var item = this.GenerateObject(id); - var createdItem = await this.repository.CreateAsync(item); - - Assert.IsNotNull(createdItem); - Assert.AreNotEqual(id, createdItem.Id); - Assert.IsNotNull(createdItem.CreationTime); - Assert.IsNotNull(createdItem.UpdateTime); - Assert.IsInstanceOf(createdItem); - } - - [Test] - [TestCase(TestName = "Update Null Item", Category = "Update")] - public async Task UpdateAsync_NullItem_ThrowsNullReferenceException() - { - Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(null)); + Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(item)); } #endregion } diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs new file mode 100644 index 0000000..baf334b --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs @@ -0,0 +1,23 @@ +using System; +using FinancialHub.Domain.Entities; +using FinancialHub.Infra.NUnitTests.Repositories.Base; +using FinancialHub.Infra.Repositories; +using NUnit.Framework; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Categories +{ + public class CategoriesRepositoryTests : BaseRepositoryTests + { + [SetUp] + protected override void Setup() + { + base.Setup(); + this.repository = new CategoriesRepository(this.context); + } + + protected override CategoryEntity GenerateObject(Guid? id = null) + { + return this.generator.GenerateCategory(id); + } + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs new file mode 100644 index 0000000..6f87ccb --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs @@ -0,0 +1,186 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Transactions +{ + public partial class TransactionsRepositoryTests + { + protected override void AssertCreated(TransactionEntity createdItem) + { + base.AssertCreated(createdItem); + + Assert.IsNotNull(createdItem.Account); + Assert.IsNotNull(createdItem.Category); + Assert.AreEqual(createdItem.AccountId, createdItem.Account.Id); + Assert.AreEqual(createdItem.CategoryId, createdItem.Category.Id); + } + + [Test] + [TestCase(TestName = "Create new Transaction with valid Category and Account", Category = "Create")] + public override async Task CreateAsync_ValidItem_AddsOneRow(TransactionEntity item = null) + { + var entity = this.GenerateObject(); + + entity.Category = await this.InsertData(entity.Category); + entity.Account = await this.InsertData(entity.Account); + + await base.CreateAsync_ValidItem_AddsOneRow(entity); + } + + [Test] + [TestCase(TestName = "Create new Item with id", Category = "Create")] + public async override Task CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(TransactionEntity item = null) + { + var entity = this.GenerateObject(); + + var generatedAccount = this.GenerateAccount(entity.AccountId); + var generatedCategory = this.GenerateCategory(entity.CategoryId); + + await this.InsertData(generatedAccount); + await this.InsertData(generatedCategory); + + await base.CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(entity); + } + + [Test] + [TestCase(TestName = "Create item with existing id", Category = "Create")] + public override async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithTheDifferentId(TransactionEntity item = null) + { + var id = Guid.NewGuid(); + item = this.GenerateObject(id); + + //INSERTS ACCOUNT AND CATEGORY + var generatedAccount = this.GenerateAccount(item.AccountId); + var generatedCategory = this.GenerateCategory(item.CategoryId); + + await this.InsertData(generatedAccount); + await this.InsertData(generatedCategory); + + item.Category = null; + item.Account = null; + item = await this.InsertData(item); + + var newItem = this.GenerateObject(id); + newItem.CategoryId = generatedCategory.Id.GetValueOrDefault(); + newItem.AccountId = generatedAccount.Id.GetValueOrDefault(); + + var result = await this.repository.CreateAsync(newItem); + + Assert.AreNotEqual(item.Id,newItem.Id); + this.AssertCreated(result); + Assert.AreEqual(2, context.Set().Count()); + } + + [Test] + [TestCase(TestName = "Create new Transaction without Updates/Creates Account or Category", Category = "Create")] + public async Task CreateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() + { + #warning this test is too complex + + /***** ARRANGE *****/ + var entity = this.GenerateObject(); + + //INSERTS ACCOUNT AND CATEGORY + var oldAccount = this.GenerateAccount(entity.AccountId); + var oldCategory = this.GenerateCategory(entity.CategoryId); + + await this.InsertData(oldAccount); + await this.InsertData(oldCategory); + + //CHANGES TRANSACTION'S CATEGORY AND ACCOUNT + entity.Account.Name = Guid.NewGuid().ToString(); + entity.Category.Name = Guid.NewGuid().ToString(); + + /***** ACT *****/ + + var result = await this.repository.CreateAsync(entity); + + /***** ASSERT *****/ + + this.AssertCreated(result); + + //SHOULD NOT CREATE ACCOUNTS OR CATEGORIES + Assert.AreEqual(1,this.context.Accounts.Count()); + Assert.AreEqual(1,this.context.Categories.Count()); + + var account = this.context.Accounts.FirstOrDefault(x => x.Id == entity.AccountId); + var category = this.context.Categories.FirstOrDefault(x => x.Id == entity.CategoryId); + + //SHOULD NOT UPDATE DATABASE + Assert.AreEqual(oldAccount, account); + Assert.AreEqual(oldCategory, category); + + //SHOULD NOT RETURN THE WRONG ITEM + Assert.AreEqual(oldAccount, result.Account); + Assert.AreEqual(oldCategory, result.Category); + } + + [Test] + [TestCase(TestName = "Create new Transaction with invalid Account", Category = "Create")] + public async Task CreateAsync_InvalidAccountId_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + + await this.InsertData(this.GenerateAccount()); + + entity.Category = await this.InsertData(entity.Category); + entity.CategoryId = entity.Category.Id.GetValueOrDefault(); + + Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); + + Assert.IsEmpty(this.context.Transactions); + Assert.AreEqual(1, this.context.Accounts.Count()); + Assert.AreEqual(1, this.context.Categories.Count()); + } + + [Test] + [TestCase(TestName = "Create new Transaction with invalid Category", Category = "Create")] + public async Task CreateAsync_InvalidCategoryId_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + + await this.InsertData(entity.Account); + await this.InsertData(this.GenerateCategory()); + + Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); + + Assert.IsEmpty(this.context.Transactions); + Assert.AreEqual(1, this.context.Accounts.Count()); + Assert.AreEqual(1, this.context.Categories.Count()); + } + + [Test] + [TestCase(TestName = "Create new Transaction with no Account", Category = "Create")] + public async Task CreateAsync_NoAccount_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + + await this.InsertData(entity.Category); + + entity.Account = null; + + Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); + + Assert.IsEmpty(this.context.Transactions.ToList()); + } + + [Test] + [TestCase(TestName = "Create new Transaction with no Category", Category = "Create")] + public async Task CreateAsync_NoCategory_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + + await this.InsertData(entity.Account); + + entity.Category = null; + + Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); + + Assert.IsEmpty(this.context.Transactions.ToList()); + } + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs new file mode 100644 index 0000000..d9bb897 --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs @@ -0,0 +1,38 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Infra.NUnitTests.Repositories.Base; +using FinancialHub.Infra.Repositories; +using NUnit.Framework; +using System; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Transactions +{ + public partial class TransactionsRepositoryTests : BaseRepositoryTests + { + [SetUp] + protected override void Setup() + { + base.Setup(); + this.repository = new TransactionsRepository(this.context); + } + + protected override TransactionEntity GenerateObject(Guid? id = null) + { + return this.generator.GenerateTransaction(id); + } + + protected TransactionEntity GenerateTransaction(Guid? id = null,Guid? accountId = null, Guid? categoryId = null) + { + return this.generator.GenerateTransaction(id,accountId,categoryId); + } + + protected CategoryEntity GenerateCategory(Guid? id = null) + { + return this.generator.GenerateCategory(id); + } + + protected AccountEntity GenerateAccount(Guid? id = null) + { + return this.generator.GenerateAccount(id); + } + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs new file mode 100644 index 0000000..54d2131 --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs @@ -0,0 +1,27 @@ +using NUnit.Framework; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Transactions +{ + public partial class TransactionsRepositoryTests + { + [Test] + [TestCase(TestName = "Delete a Transaction without delete Category or Account", Category = "Delete")] + public async Task DeleteAsync_ValidItemWithNestChild_DoesNotDeleteNestChild() + { + var entity = this.GenerateObject(); + + await this.InsertData(entity.Account); + await this.InsertData(entity.Category); + await this.InsertData(entity); + + var result = await this.repository.DeleteAsync(entity.Id.Value); + + Assert.AreEqual(1,result); + + Assert.IsEmpty(this.context.Transactions.Local); + Assert.AreEqual(1, this.context.Accounts.Local.Count); + Assert.AreEqual(1, this.context.Categories.Local.Count); + } + } +} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs new file mode 100644 index 0000000..b4f1f6f --- /dev/null +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs @@ -0,0 +1,116 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.NUnitTests.Repositories.Transactions +{ + public partial class TransactionsRepositoryTests + { + protected async Task InsertTransaction(TransactionEntity entity) + { + await this.InsertData(entity.Account); + await this.InsertData(entity.Category); + await this.InsertData(entity); + + context.Entry(entity).State = EntityState.Detached; + } + + [Test] + [TestCase(TestName = "Update Transaction but no Accounts or Category", Category = "Update")] + public async Task UpdateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() + { + var entity = this.GenerateObject(); + await this.InsertTransaction(entity); + + var changedEntity = this.GenerateTransaction(entity.Id, entity.AccountId, entity.CategoryId); + + var result = await this.repository.UpdateAsync(changedEntity); + + this.AssertCreated(result); + + //SHOULD NOT CREATE + Assert.AreEqual(1, this.context.Accounts.Local.Count); + Assert.AreEqual(1, this.context.Categories.Local.Count); + + var account = this.context.Accounts.FirstOrDefault(x => x.Id == changedEntity.AccountId); + var category = this.context.Categories.FirstOrDefault(x => x.Id == changedEntity.CategoryId); + + //SHOULD NOT UPDATE DATABASE + Assert.AreEqual(account, result.Account); + Assert.AreEqual(category, result.Category); + } + + [Test] + [TestCase(TestName = "Update Transaction changing Account", Category = "Update")] + public async Task UpdateAsync_ChangeAccountId_ChangesAccount() + { + var entity = this.GenerateObject(); + await this.InsertTransaction(entity); + + var newAccount = this.GenerateAccount(); + await this.InsertData(newAccount); + + entity.AccountId = (Guid)newAccount.Id; + + var result = await this.repository.CreateAsync(entity); + + this.AssertCreated(result); + + Assert.AreEqual(newAccount.Id, result.AccountId); + Assert.AreEqual(newAccount, result.Account); + } + + [Test] + [TestCase(TestName = "Update Transaction changing Category", Category = "Update")] + public async Task UpdateAsync_ChangeCategoryId_ChangesCategory() + { + var entity = this.GenerateObject(); + await this.InsertTransaction(entity); + + var newCategory = this.GenerateCategory(); + await this.InsertData(newCategory); + + entity.CategoryId = (Guid)newCategory.Id; + + var result = await this.repository.CreateAsync(entity); + + this.AssertCreated(result); + + Assert.AreEqual(newCategory.Id, result.CategoryId); + Assert.AreEqual(newCategory, result.Category); + } + + [Test] + [TestCase(TestName = "Update Transaction with invalid Account", Category = "Update")] + public async Task UpdateAsync_InvalidAccountId_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + var oldCategoryId = entity.Category.Id; + + await this.InsertTransaction(entity); + + var newCategory = this.GenerateCategory(); + entity.CategoryId = (Guid)newCategory.Id; + + Assert.ThrowsAsync( async () =>await this.repository.UpdateAsync(entity)); + } + + [Test] + [TestCase(TestName = "Update Transaction with invalid Category", Category = "Update")] + public async Task UpdateAsync_InvalidCategoryId_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + var newCategory = this.GenerateCategory(); + + await this.InsertTransaction(entity); + + entity.CategoryId = (Guid)newCategory.Id; + entity.Category = newCategory; + + Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(entity)); + } + } +} From c7b3057fde81d9c9b80fc9f7bc478541a49d0582 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Sat, 12 Feb 2022 22:28:25 -0300 Subject: [PATCH 05/30] Release v0.2.1 * Add : DDL Script * Add : Services Project * Add : Domain architecture * Add : Database context and startup configurations * Add: account get all endpoint * Add : Basic Accounts endpoints * Add : Repository Unit tests * Add : BaseRepository Tests : Update * Add : Auto Include on Transactions * Add : Transaction get filters * Add : category table DDL * Add : Categories CRUD * Add : Transactions endpoints * Add : Transaction Filters * Add : Transaction date Filters * Add : Faker library to generate data * Add : Releashionship between Accounts,Category and Transaction * Add : TransactionEntity Relashionships * Change : DDL added account creation/update time * Changes : BaseRepositoryTest base GenerateData method * Changes : controller params * Changes : BaseRepository methods are virtual and protected * Changes : BaseRepository Tests are now virtual * Change : Inherits to Create Base Repository tests * Changes : Project using .NET 6.0 * Changes : IMapper to IMapperWrapper on services * Changes : Infra project to Infra.Data * Changes : removed auto mapper & updated entityframework * Fix : repository create tests, delete and get by id parameters * Fix : CreateAsync Tests * Fix : BaseRepositoryTests typos and context verification on CreateAsync * Fix : All update tests * Fix: Transaction Fields types * Fix : Transaction creating category and account when not found * Fix : api usings & moved mapper * Fix : NUnit BaseRepository Update Test * Fix : transaction status changed * Fix : small comment changes on AccountsController --- .../Interfaces/Mappers/IMapperWrapper.cs | 11 ++++ .../Contexts/FinancialHubContext.cs | 2 +- ....csproj => FinancialHub.Infra.Data.csproj} | 3 +- .../Repositories/AccountsRepository.cs | 4 +- .../Repositories/BaseRepository.cs | 4 +- .../Repositories/CategoriesRepository.cs | 4 +- .../Repositories/TransactionsRepository.cs | 4 +- .../FinancialHub.Services.csproj | 17 ++++++ .../Mappers/FinancialHubAutoMapperProfile.cs | 22 +++++++ .../Mappers/FinancialHubMapperWrapper.cs | 25 ++++++++ .../Services/AccountsService.cs | 56 +++++++++++++++++ .../Services/CategoriesService.cs | 55 +++++++++++++++++ .../Services/TransactionsService.cs | 61 +++++++++++++++++++ .../IServiceCollectionExtensions.cs | 11 +++- .../FinancialHub.WebApi.csproj | 15 ++--- .../FinancialHub.WebApi/Startup.cs | 3 +- api/src/FinancialHub/FinancialHub.sln | 15 ++++- .../FinancialHub.Infra.NUnitTests.csproj | 2 +- .../Generators/EntityGenerator.cs | 2 +- .../Accounts/AccountsRepositoryTests.cs | 6 +- .../Base/BaseRepositoryTests.create.cs | 2 +- .../Repositories/Base/BaseRepositoryTests.cs | 6 +- .../Base/BaseRepositoryTests.delete.cs | 2 +- .../Base/BaseRepositoryTests.get.cs | 2 +- .../Base/BaseRepositoryTests.update.cs | 2 +- .../Categories/CategoriesRepositoryTests.cs | 6 +- .../TransactionsRepositoryTests.create.cs | 2 +- .../TransactionsRepositoryTests.cs | 6 +- .../TransactionsRepositoryTests.delete.cs | 2 +- .../TransactionsRepositoryTests.update.cs | 2 +- 30 files changed, 308 insertions(+), 46 deletions(-) create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs rename api/src/FinancialHub/FinancialHub.Infra/{FinancialHub.Infra.csproj => FinancialHub.Infra.Data.csproj} (81%) create mode 100644 api/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj create mode 100644 api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs new file mode 100644 index 0000000..b1560aa --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs @@ -0,0 +1,11 @@ +namespace FinancialHub.Domain.Interfaces.Mappers +{ + /// + /// Wrapper interface for Mapper Classes + /// + public interface IMapperWrapper + { + Y Map(T ent); + Y Map(object ent); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs b/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs index 726501e..eaa1803 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs +++ b/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using System.Diagnostics.CodeAnalysis; -namespace FinancialHub.Infra.Contexts +namespace FinancialHub.Infra.Data.Contexts { public class FinancialHubContext : DbContext { diff --git a/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj b/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.Data.csproj similarity index 81% rename from api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj rename to api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.Data.csproj index 67a1bde..b84f938 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.csproj +++ b/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.Data.csproj @@ -5,8 +5,7 @@ - - + diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs index b1af7e1..64fdba3 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs +++ b/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs @@ -1,9 +1,9 @@ using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Contexts; +using FinancialHub.Infra.Data.Contexts; using System.ComponentModel; -namespace FinancialHub.Infra.Repositories +namespace FinancialHub.Infra.Data.Repositories { [Category("Repositories")] public class AccountsRepository : BaseRepository, IAccountsRepository diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs index 17208f9..d409f6d 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs +++ b/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs @@ -2,12 +2,12 @@ using System.Linq; using System.Threading.Tasks; using System.Collections.Generic; -using FinancialHub.Infra.Contexts; +using FinancialHub.Infra.Data.Contexts; using Microsoft.EntityFrameworkCore; using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Repositories; -namespace FinancialHub.Infra.Repositories +namespace FinancialHub.Infra.Data.Repositories { public class BaseRepository : IBaseRepository diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs index 31b0757..5d422c5 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs +++ b/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs @@ -1,8 +1,8 @@ using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Contexts; +using FinancialHub.Infra.Data.Contexts; -namespace FinancialHub.Infra.Repositories +namespace FinancialHub.Infra.Data.Repositories { public class CategoriesRepository : BaseRepository, ICategoriesRepository { diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs index 2e2ede4..a19ae0f 100644 --- a/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs +++ b/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs @@ -1,10 +1,10 @@ using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Contexts; +using FinancialHub.Infra.Data.Contexts; using System; using System.Threading.Tasks; -namespace FinancialHub.Infra.Repositories +namespace FinancialHub.Infra.Data.Repositories { public class TransactionsRepository : BaseRepository, ITransactionsRepository { diff --git a/api/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj b/api/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj new file mode 100644 index 0000000..815baab --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs b/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs new file mode 100644 index 0000000..4bb5246 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs @@ -0,0 +1,22 @@ +using AutoMapper; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Filters; +using FinancialHub.Domain.Queries; + +namespace FinancialHub.Services.Mappers +{ + public class FinancialHubAutoMapperProfile : Profile + { + public FinancialHubAutoMapperProfile() + { + //Entities + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + + //Queries + CreateMap().ReverseMap(); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs b/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs new file mode 100644 index 0000000..821cc34 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs @@ -0,0 +1,25 @@ +using AutoMapper; +using FinancialHub.Domain.Interfaces.Mappers; + +namespace FinancialHub.Domain.Mappers +{ + public class FinancialHubMapperWrapper : IMapperWrapper + { + private readonly IMapper mapper; + + public FinancialHubMapperWrapper(IMapper mapper) + { + this.mapper = mapper; + } + + public Y Map(T ent) + { + return this.mapper.Map(ent); + } + + public Y Map(object ent) + { + return this.mapper.Map(ent); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs new file mode 100644 index 0000000..4c29b70 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs @@ -0,0 +1,56 @@ +using AutoMapper; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Models; + +namespace FinancialHub.Services.Services +{ + public class AccountsService : IAccountsService + { + private readonly IMapperWrapper mapper; + private readonly IAccountsRepository repository; + + public AccountsService(IMapperWrapper mapper,IAccountsRepository repository) + { + this.mapper = mapper; + this.repository = repository; + } + + public async Task CreateAsync(AccountModel account) + { + var entity = mapper.Map(account); + + entity = await this.repository.CreateAsync(entity); + + return mapper.Map(entity); + } + + public async Task DeleteAsync(Guid id) + { + return await this.repository.DeleteAsync(id); + } + + public async Task> GetAllByUserAsync(string userId) + { + var entities = await this.repository.GetAllAsync(); + return mapper.Map>(entities); + } + + public async Task UpdateAsync(Guid id, AccountModel account) + { + var entity = await this.repository.GetByIdAsync(id); + + if(entity == null) + { + throw new NullReferenceException($"Not found account with id {id}"); + } + entity.Id = id; + + entity = await this.repository.UpdateAsync(entity); + + return mapper.Map(entity); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs new file mode 100644 index 0000000..ea97f66 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs @@ -0,0 +1,55 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Mappers; + +namespace FinancialHub.Services.Services +{ + public class CategoriesService : ICategoriesService + { + private readonly IMapperWrapper mapper; + private readonly ICategoriesRepository repository; + + public CategoriesService(IMapperWrapper mapper, ICategoriesRepository repository) + { + this.mapper = mapper; + this.repository = repository; + } + + public async Task CreateAsync(CategoryModel category) + { + var entity = mapper.Map(category); + + entity = await this.repository.CreateAsync(entity); + + return mapper.Map(entity); + } + + public async Task DeleteAsync(Guid id) + { + return await this.repository.DeleteAsync(id); + } + + public async Task> GetAllByUserAsync(string userId) + { + var entities = await this.repository.GetAllAsync(); + return mapper.Map>(entities); + } + + public async Task UpdateAsync(Guid id, CategoryModel category) + { + var entity = await this.repository.GetByIdAsync(id); + + if (entity == null) + { + throw new NullReferenceException($"Not found category with id {id}"); + } + entity.Id = id; + + entity = await this.repository.UpdateAsync(entity); + + return mapper.Map(entity); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs new file mode 100644 index 0000000..0617274 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs @@ -0,0 +1,61 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Filters; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Queries; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Mappers; + +namespace FinancialHub.Services.Services +{ + public class TransactionsService : ITransactionsService + { + private readonly IMapperWrapper mapper; + private readonly ITransactionsRepository repository; + + public TransactionsService(IMapperWrapper mapper, ITransactionsRepository repository) + { + this.mapper = mapper; + this.repository = repository; + } + + public async Task CreateAsync(TransactionModel category) + { + var entity = mapper.Map(category); + + entity = await this.repository.CreateAsync(entity); + + return mapper.Map(entity); + } + + public async Task DeleteAsync(Guid id) + { + return await this.repository.DeleteAsync(id); + } + + public async Task> GetAllByUserAsync(string userId, TransactionFilter filter) + { + var query = mapper.Map(filter); + //query.UserId = userId; + + var entities = await this.repository.GetAsync(query.Query()); + + return mapper.Map>(entities); + } + + public async Task UpdateAsync(Guid id, TransactionModel category) + { + var entity = await this.repository.GetByIdAsync(id); + + if (entity == null) + { + throw new NullReferenceException($"Not found category with id {id}"); + } + entity.Id = id; + + entity = await this.repository.UpdateAsync(entity); + + return mapper.Map(entity); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs index fc46e58..69ac8b9 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -1,9 +1,13 @@ using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Infra.Repositories; -using FinancialHub.Infra.Services; +using FinancialHub.Services.Services; +using FinancialHub.Infra.Data.Repositories; + using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; +using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Services.Mappers; +using FinancialHub.Domain.Mappers; namespace FinancialHub.WebApi.Extensions.Configurations { @@ -31,6 +35,9 @@ public static IServiceCollection AddRepositories(this IServiceCollection service public static IServiceCollection AddServices(this IServiceCollection services) { + services.AddAutoMapper(typeof(FinancialHubAutoMapperProfile)); + services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj index 58a3ac6..31ce0de 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -6,16 +6,16 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -26,7 +26,8 @@ - + + diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs index e0a9478..bce2b89 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs @@ -1,4 +1,4 @@ -using FinancialHub.Infra.Contexts; +using FinancialHub.Infra.Data.Contexts; using FinancialHub.WebApi.Extensions.Configurations; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -33,7 +33,6 @@ public void ConfigureServices(IServiceCollection services) services.AddRepositories(); services.AddServices(); services.AddApiConfigurations(); - services.AddAutoMapper(typeof(FinancialHubAutoMapperProfile)); //services.AddHealthCheck(); services.AddSwaggerGen(c => diff --git a/api/src/FinancialHub/FinancialHub.sln b/api/src/FinancialHub/FinancialHub.sln index 0f6abda..99844d1 100644 --- a/api/src/FinancialHub/FinancialHub.sln +++ b/api/src/FinancialHub/FinancialHub.sln @@ -1,11 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31624.102 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain", "FinancialHub.Domain\FinancialHub.Domain.csproj", "{776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra", "FinancialHub.Infra\FinancialHub.Infra.csproj", "{126F1390-1B86-4ABB-9E49-E77B7857E2F0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data", "FinancialHub.Infra\FinancialHub.Infra.Data.csproj", "{126F1390-1B86-4ABB-9E49-E77B7857E2F0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}" EndProject @@ -15,6 +15,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{2444FB9D EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.NUnitTests", "MyFinancialHub.Infra.NUnitTests\FinancialHub.Infra.NUnitTests.csproj", "{D88B870B-D7EF-41CF-B24F-8D85C37559E1}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{91A212DC-1D96-43DD-B1A0-153ACB6980D5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.Services", "FinancialHub.Services\FinancialHub.Services.csproj", "{7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -37,6 +41,10 @@ Global {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Release|Any CPU.ActiveCfg = Release|Any CPU {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Release|Any CPU.Build.0 = Release|Any CPU + {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -45,6 +53,7 @@ Global {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {126F1390-1B86-4ABB-9E49-E77B7857E2F0} = {2444FB9D-15D1-4193-BF04-83C4397369DA} {D88B870B-D7EF-41CF-B24F-8D85C37559E1} = {2444FB9D-15D1-4193-BF04-83C4397369DA} + {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj index bb0dc2e..04d6db4 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj @@ -21,7 +21,7 @@ - + diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs index a63e0a3..f96696c 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs @@ -3,7 +3,7 @@ using FinancialHub.Domain.Entities; using FinancialHub.Domain.Enums; -namespace FinancialHub.Infra.NUnitTests.Generators +namespace FinancialHub.Infra.Data.NUnitTests.Generators { public class EntityGenerator { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs index 43ede64..3c42bdb 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs @@ -1,10 +1,10 @@ using System; using NUnit.Framework; using FinancialHub.Domain.Entities; -using FinancialHub.Infra.Repositories; -using FinancialHub.Infra.NUnitTests.Repositories.Base; +using FinancialHub.Infra.Data.Repositories; +using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; -namespace FinancialHub.Infra.NUnitTests.Repositories.Accounts +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Accounts { public class AccountsRepositoryTests : BaseRepositoryTests { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs index 25bd5fe..9791475 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using FinancialHub.Domain.Entities; -namespace FinancialHub.Infra.NUnitTests.Repositories.Base +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs index f95891e..5a87f1b 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs @@ -1,15 +1,15 @@ using System; using NUnit.Framework; -using FinancialHub.Infra.Contexts; +using FinancialHub.Infra.Data.Contexts; using FinancialHub.Domain.Entities; using Microsoft.EntityFrameworkCore; using FinancialHub.Domain.Interfaces.Repositories; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Data.Sqlite; -using FinancialHub.Infra.NUnitTests.Generators; +using FinancialHub.Infra.Data.NUnitTests.Generators; -namespace FinancialHub.Infra.NUnitTests.Repositories.Base +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs index a52c470..f15f22d 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Threading.Tasks; -namespace FinancialHub.Infra.NUnitTests.Repositories.Base +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs index 2a52636..c580c4e 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using FinancialHub.Domain.Entities; -namespace FinancialHub.Infra.NUnitTests.Repositories.Base +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs index 8aaa7fd..7cce1a0 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; -namespace FinancialHub.Infra.NUnitTests.Repositories.Base +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs index baf334b..a33c90b 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs @@ -1,10 +1,10 @@ using System; using FinancialHub.Domain.Entities; -using FinancialHub.Infra.NUnitTests.Repositories.Base; -using FinancialHub.Infra.Repositories; +using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Infra.Data.Repositories; using NUnit.Framework; -namespace FinancialHub.Infra.NUnitTests.Repositories.Categories +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Categories { public class CategoriesRepositoryTests : BaseRepositoryTests { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs index 6f87ccb..fbd89da 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Threading.Tasks; -namespace FinancialHub.Infra.NUnitTests.Repositories.Transactions +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Transactions { public partial class TransactionsRepositoryTests { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs index d9bb897..9b1a604 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs @@ -1,10 +1,10 @@ using FinancialHub.Domain.Entities; -using FinancialHub.Infra.NUnitTests.Repositories.Base; -using FinancialHub.Infra.Repositories; +using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Infra.Data.Repositories; using NUnit.Framework; using System; -namespace FinancialHub.Infra.NUnitTests.Repositories.Transactions +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Transactions { public partial class TransactionsRepositoryTests : BaseRepositoryTests { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs index 54d2131..56ab497 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs @@ -1,7 +1,7 @@ using NUnit.Framework; using System.Threading.Tasks; -namespace FinancialHub.Infra.NUnitTests.Repositories.Transactions +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Transactions { public partial class TransactionsRepositoryTests { diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs index b4f1f6f..0e2f8e4 100644 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs +++ b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Threading.Tasks; -namespace FinancialHub.Infra.NUnitTests.Repositories.Transactions +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Transactions { public partial class TransactionsRepositoryTests { From d5d8d5f792b67c986adc4c097162ed6d12539d13 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Sun, 13 Feb 2022 01:17:02 -0300 Subject: [PATCH 06/30] Release v0.2.2 * Add : Standard API Response * Add : Standard Service Result * Add : Api Test Project * Add : Accounts , Transaction and Categories Controller Unit Tests --- api/src/FinancialHub/.editorconfig | 4 + .../FinancialHub.Domain.NUnitTests.csproj | 22 +++ .../Generators/EntityGenerator.cs | 71 +++++++ .../Generators/ModelGenerator.cs | 65 ++++++ .../Interfaces/Services/IAccountsService.cs | 13 +- .../Interfaces/Services/ICategoriesService.cs | 9 +- .../Services/ITransactionsService.cs | 9 +- .../Queries/TransactionQuery.cs | 1 + .../Responses/Errors/BaseErrorResponse.cs | 14 ++ .../Responses/Errors/NotFoundErrorResponse.cs | 9 + .../Errors/ValidationErrorResponse.cs | 9 + .../Responses/Success/BaseResponse.cs | 11 ++ .../Responses/Success/ListResponse.cs | 11 ++ .../Success/PaginatedListResponse.cs | 18 ++ .../Responses/Success/SaveResponse.cs | 9 + .../Results/Errors/InvalidDataError.cs | 12 ++ .../Results/Errors/NotFoundError.cs | 12 ++ .../Results/Errors/ServiceError.cs | 19 ++ .../Results/ServiceResult.cs | 27 +++ .../FinancialHub.Infra.Data.NUnitTests.csproj | 28 +++ .../Accounts/AccountsRepositoryTests.cs | 24 +++ .../Base/BaseRepositoryTests.create.cs | 65 ++++++ .../Repositories/Base/BaseRepositoryTests.cs | 94 +++++++++ .../Base/BaseRepositoryTests.delete.cs | 37 ++++ .../Base/BaseRepositoryTests.get.cs | 139 +++++++++++++ .../Base/BaseRepositoryTests.update.cs | 42 ++++ .../Categories/CategoriesRepositoryTests.cs | 23 +++ .../TransactionsRepositoryTests.create.cs | 186 ++++++++++++++++++ .../TransactionsRepositoryTests.cs | 38 ++++ .../TransactionsRepositoryTests.delete.cs | 27 +++ .../TransactionsRepositoryTests.update.cs | 116 +++++++++++ .../Contexts/FinancialHubContext.cs | 42 ++++ .../FinancialHub.Infra.Data.csproj | 15 ++ .../Repositories/AccountsRepository.cs | 15 ++ .../Repositories/BaseRepository.cs | 71 +++++++ .../Repositories/CategoriesRepository.cs | 13 ++ .../Repositories/TransactionsRepository.cs | 35 ++++ .../FinancialHub.Services.NUnitTests.csproj | 25 +++ .../Accounts/AccountsServiceTests.create.cs | 74 +++++++ .../Services/Accounts/AccountsServiceTests.cs | 51 +++++ .../Accounts/AccountsServiceTests.delete.cs | 49 +++++ .../Accounts/AccountsServiceTests.get.cs | 67 +++++++ .../Accounts/AccountsServiceTests.update.cs | 111 +++++++++++ .../CategoriesServiceTests.create.cs | 74 +++++++ .../Categories/CategoriesServiceTests.cs | 51 +++++ .../CategoriesServiceTests.delete.cs | 49 +++++ .../Categories/CategoriesServiceTests.get.cs | 67 +++++++ .../CategoriesServiceTests.update.cs | 111 +++++++++++ .../TransactionsServiceTests.create.cs | 74 +++++++ .../Transactions/TransactionsServiceTests.cs | 51 +++++ .../TransactionsServiceTests.delete.cs | 49 +++++ .../TransactionsServiceTests.get.cs | 87 ++++++++ .../TransactionsServiceTests.update.cs | 111 +++++++++++ .../Services/AccountsService.cs | 33 +++- .../Services/CategoriesService.cs | 18 +- .../Services/TransactionsService.cs | 19 +- .../AccountsControllerTests.create.cs | 67 +++++++ .../Accounts/AccountsControllerTests.cs | 35 ++++ .../AccountsControllerTests.delete.cs | 20 ++ .../Accounts/AccountsControllerTests.get.cs | 42 ++++ .../AccountsControllerTests.update.cs | 69 +++++++ .../CategoriesControllerTests.create.cs | 67 +++++++ .../Categories/CategoriesControllerTests.cs | 28 +++ .../CategoriesControllerTests.delete.cs | 20 ++ .../CategoriesControllerTests.get.cs | 40 ++++ .../CategoriesControllerTests.update.cs | 69 +++++++ .../TransactionsControllerTests.create.cs | 67 +++++++ .../TransactionsControllerTests.cs | 28 +++ .../TransactionsControllerTests.delete.cs | 20 ++ .../TransactionsControllerTests.get.cs | 42 ++++ .../TransactionsControllerTests.update.cs | 69 +++++++ .../FinancialHub.WebApi.NUnitTests.csproj | 24 +++ .../Controllers/AccountsController.cs | 75 ++++--- .../Controllers/Base/BaseController.cs | 27 +++ .../Controllers/CategoriesController.cs | 77 ++++---- .../Controllers/TransactionsController.cs | 73 +++---- .../FinancialHub.WebApi.csproj | 6 +- api/src/FinancialHub/FinancialHub.sln | 50 +++-- 78 files changed, 3368 insertions(+), 173 deletions(-) create mode 100644 api/src/FinancialHub/.editorconfig create mode 100644 api/src/FinancialHub/FinancialHub.Domain.NUnitTests/FinancialHub.Domain.NUnitTests.csproj create mode 100644 api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/EntityGenerator.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/ModelGenerator.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs diff --git a/api/src/FinancialHub/.editorconfig b/api/src/FinancialHub/.editorconfig new file mode 100644 index 0000000..d43247d --- /dev/null +++ b/api/src/FinancialHub/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CS8618: O campo não anulável precisa conter um valor não nulo ao sair do construtor. Considere declará-lo como anulável. +dotnet_diagnostic.CS8618.severity = none diff --git a/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/FinancialHub.Domain.NUnitTests.csproj b/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/FinancialHub.Domain.NUnitTests.csproj new file mode 100644 index 0000000..7eeae5b --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/FinancialHub.Domain.NUnitTests.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + enable + + false + + + + + + + + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/EntityGenerator.cs b/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/EntityGenerator.cs new file mode 100644 index 0000000..13b359f --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/EntityGenerator.cs @@ -0,0 +1,71 @@ +using Bogus; +using System; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Enums; + +namespace FinancialHub.Domain.NUnitTests.Generators +{ + public class EntityGenerator + { + private readonly Random random; + + public EntityGenerator(Random random) + { + this.random = random; + } + + public AccountEntity GenerateAccount(Guid? id = null) + { + var fake = new Faker(); + + fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) + .RuleFor(x => x.Name, fake => fake.Finance.AccountName()) + .RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code) + .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1,5))) + .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) + .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) + .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); + + return fake.Generate(); + } + + public CategoryEntity GenerateCategory(Guid? id = null) + { + var fake = new Faker(); + + fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) + .RuleFor(x => x.Name, fake => fake.Finance.Random.Word()) + .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) + .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) + .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) + .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); + + return fake.Generate(); + } + + public TransactionEntity GenerateTransaction(Guid? id = null, Guid? accountId = null, Guid? categoryId = null) + { + var account = this.GenerateAccount(accountId); + var category = this.GenerateCategory(categoryId); + + var fake = new Faker(); + + fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) + .RuleFor(x => x.Amount , fake => fake.Random.Decimal(0,10000)) + .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) + .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) + .RuleFor(x => x.Type, fake => fake.PickRandom()) + .RuleFor(x => x.Status , fake => fake.PickRandom()) + .RuleFor(x => x.AccountId, fake => account.Id) + .RuleFor(x => x.Account, fake => account) + .RuleFor(x => x.CategoryId, fake => category.Id) + .RuleFor(x => x.Category, fake => category) + .RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset()) + .RuleFor(x => x.FinishDate, fake => fake.Date.RecentOffset()) + .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) + .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); + + return fake.Generate(); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/ModelGenerator.cs b/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/ModelGenerator.cs new file mode 100644 index 0000000..e5dbc92 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/ModelGenerator.cs @@ -0,0 +1,65 @@ +using Bogus; +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Models; +using System; + +namespace FinancialHub.Domain.NUnitTests.Generators +{ + public class ModelGenerator + { + private readonly Random random; + + public ModelGenerator(Random random) + { + this.random = random; + } + + public AccountModel GenerateAccount(Guid? id = null) + { + var fake = new Faker(); + + fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) + .RuleFor(x => x.Name, fake => fake.Finance.AccountName()) + .RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code) + .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) + .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); + + return fake.Generate(); + } + + public CategoryModel GenerateCategory(Guid? id = null) + { + var fake = new Faker(); + + fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) + .RuleFor(x => x.Name, fake => fake.Finance.Random.Word()) + .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) + .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); + + return fake.Generate(); + } + + public TransactionModel GenerateTransaction(Guid? id = null, Guid? accountId = null, Guid? categoryId = null) + { + var account = this.GenerateAccount(accountId); + var category = this.GenerateCategory(categoryId); + + var fake = new Faker(); + + fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) + .RuleFor(x => x.Amount, fake => fake.Random.Decimal(0, 10000)) + .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) + .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) + .RuleFor(x => x.Type, fake => fake.PickRandom()) + .RuleFor(x => x.Status, fake => fake.PickRandom()) + .RuleFor(x => x.AccountId, fake => account.Id) + .RuleFor(x => x.Account, fake => account) + .RuleFor(x => x.CategoryId, fake => category.Id) + .RuleFor(x => x.Category, fake => category) + .RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset()) + .RuleFor(x => x.FinishDate, fake => fake.Date.RecentOffset()); + + return fake.Generate(); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs index c7f28d9..5fd3765 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs @@ -2,17 +2,22 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using System.Collections.Generic; namespace FinancialHub.Domain.Interfaces.Services { public interface IAccountsService { - Task> GetAllByUserAsync(string userId); + Task>> GetAllByUserAsync(string userId); + + Task> GetByIdAsync(Guid id); - Task CreateAsync(AccountModel account); + Task> CreateAsync(AccountModel account); - Task UpdateAsync(Guid id,AccountModel account); + Task> UpdateAsync(Guid id,AccountModel account); - Task DeleteAsync(Guid id); + Task> DeleteAsync(Guid id); } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs index 1d5c830..959db36 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs @@ -1,4 +1,5 @@ using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -7,12 +8,12 @@ namespace FinancialHub.Domain.Interfaces.Services { public interface ICategoriesService { - Task> GetAllByUserAsync(string userId); + Task>> GetAllByUserAsync(string userId); - Task CreateAsync(CategoryModel category); + Task> CreateAsync(CategoryModel category); - Task UpdateAsync(Guid id, CategoryModel category); + Task> UpdateAsync(Guid id, CategoryModel category); - Task DeleteAsync(Guid id); + Task> DeleteAsync(Guid id); } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs index 2802005..9136a7d 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs @@ -3,17 +3,18 @@ using System.Collections.Generic; using FinancialHub.Domain.Models; using FinancialHub.Domain.Filters; +using FinancialHub.Domain.Results; namespace FinancialHub.Domain.Interfaces.Services { public interface ITransactionsService { - Task> GetAllByUserAsync(string userId, TransactionFilter filter); + Task>> GetAllByUserAsync(string userId, TransactionFilter filter); - Task CreateAsync(TransactionModel account); + Task> CreateAsync(TransactionModel account); - Task UpdateAsync(Guid id, TransactionModel account); + Task> UpdateAsync(Guid id, TransactionModel account); - Task DeleteAsync(Guid id); + Task> DeleteAsync(Guid id); } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs b/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs index b3de0ac..c2760bb 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs @@ -68,6 +68,7 @@ private Func QueryFuncs() return (ent) => queries.All(query => query(ent)); } + [Obsolete("Not working : no accounts/types/status filters")] private Func QueryFunc() { Func query; diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs b/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs new file mode 100644 index 0000000..9dbe61e --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs @@ -0,0 +1,14 @@ +namespace FinancialHub.Domain.Responses.Errors +{ + public abstract class BaseErrorResponse + { + public int Code { get; protected set; } + public string Message { get; protected set; } + + public BaseErrorResponse(int code, string message) + { + Code = code; + Message = message; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs b/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs new file mode 100644 index 0000000..ffb1a2e --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs @@ -0,0 +1,9 @@ +namespace FinancialHub.Domain.Responses.Errors +{ + public class NotFoundErrorResponse : BaseErrorResponse + { + public NotFoundErrorResponse(string message) : base(404, message) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs b/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs new file mode 100644 index 0000000..495405d --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs @@ -0,0 +1,9 @@ +namespace FinancialHub.Domain.Responses.Errors +{ + public class ValidationErrorResponse : BaseErrorResponse + { + public ValidationErrorResponse(string message) : base(400, message) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs b/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs new file mode 100644 index 0000000..71caed6 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs @@ -0,0 +1,11 @@ +namespace FinancialHub.Domain.Responses.Success +{ + public abstract class BaseResponse + { + public T Data { get; } + public BaseResponse(T data) + { + this.Data = data; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs b/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs new file mode 100644 index 0000000..f3a1dba --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace FinancialHub.Domain.Responses.Success +{ + public class ListResponse : BaseResponse> + { + public ListResponse(ICollection data) : base(data) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs b/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs new file mode 100644 index 0000000..4a1ae7e --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace FinancialHub.Domain.Responses.Success +{ + public class PaginatedListResponse : BaseResponse> + { + public int Page { get; } + public int PageSize { get; } + public int LastPage { get; } + + public PaginatedListResponse(IEnumerable data, int page, int pageSize, int lastPage) : base(data) + { + Page = page; + PageSize = pageSize; + LastPage = lastPage; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs b/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs new file mode 100644 index 0000000..331f574 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs @@ -0,0 +1,9 @@ +namespace FinancialHub.Domain.Responses.Success +{ + public class SaveResponse : BaseResponse + { + public SaveResponse(T data) : base(data) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs b/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs new file mode 100644 index 0000000..e585406 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs @@ -0,0 +1,12 @@ +using System; + +namespace FinancialHub.Domain.Results.Errors +{ + public class InvalidDataError : ServiceError + { + private const int code = 400; + public InvalidDataError(string message, Exception error = null) : base(code, message, error) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs b/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs new file mode 100644 index 0000000..a2093e4 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs @@ -0,0 +1,12 @@ +using System; + +namespace FinancialHub.Domain.Results.Errors +{ + public class NotFoundError : ServiceError + { + private const int code = 404; + public NotFoundError(string message, Exception error = null) : base(code, message, error) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs b/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs new file mode 100644 index 0000000..dbf2828 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs @@ -0,0 +1,19 @@ +using System; + +namespace FinancialHub.Domain.Results.Errors +{ + public class ServiceError + { + #warning it can be changed to an enum or use a different value from https codes + public int Code { get; protected set; } + public string Message { get; protected set; } + public Exception Error { get; protected set; } + + public ServiceError(int code,string message, Exception error = null) + { + this.Code = code; + this.Message = message; + this.Error = error; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs b/api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs new file mode 100644 index 0000000..b52668d --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs @@ -0,0 +1,27 @@ +using FinancialHub.Domain.Results.Errors; + +namespace FinancialHub.Domain.Results +{ + public class ServiceResult + { + public bool HasError => this.Error != null; + public ServiceError Error { get; protected set; } + public T Data { get; protected set; } + + public ServiceResult(T data = default,ServiceError error = null) + { + this.Data = data; + this.Error = error; + } + + public static implicit operator ServiceResult(T result) + { + return new ServiceResult(result); + } + + public static implicit operator ServiceResult(ServiceError error) + { + return new ServiceResult(error: error); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj new file mode 100644 index 0000000..01d19f4 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj @@ -0,0 +1,28 @@ + + + + net6.0 + + false + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs new file mode 100644 index 0000000..cf5ab0b --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs @@ -0,0 +1,24 @@ +using System; +using NUnit.Framework; +using FinancialHub.Domain.Entities; +using FinancialHub.Infra.Data.Repositories; +using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories +{ + public class AccountsRepositoryTests : BaseRepositoryTests + { + [SetUp] + protected override void Setup() + { + base.Setup(); + this.repository = new AccountsRepository(this.context); + } + + protected override AccountEntity GenerateObject(Guid? id = null) + { + + return this.generator.GenerateAccount(id); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs new file mode 100644 index 0000000..9791475 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs @@ -0,0 +1,65 @@ +using System; +using System.Linq; +using NUnit.Framework; +using System.Threading.Tasks; +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T : BaseEntity + { + protected virtual void AssertCreated(T createdItem) + { + Assert.IsNotNull(createdItem); + Assert.IsNotNull(createdItem.Id); + Assert.IsNotNull(createdItem.CreationTime); + Assert.IsNotNull(createdItem.UpdateTime); + Assert.IsInstanceOf(createdItem); + + Assert.IsNotEmpty(context.Set().ToList()); + } + + #region Create + [Test] + [TestCase(TestName = "Create new Item", Category = "Create")] + public virtual async Task CreateAsync_ValidItem_AddsOneRow(T item = null) + { + item ??= this.GenerateObject(); + + var createdItem = await this.repository.CreateAsync(item); + + this.AssertCreated(createdItem); + } + + [Test] + [TestCase(TestName = "Create new Item with id", Category = "Create")] + public virtual async Task CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(T item = null) + { + var id = item == null ? Guid.NewGuid() : item.Id.GetValueOrDefault(); + item ??= this.GenerateObject(id); + + var createdItem = await this.repository.CreateAsync(item); + + this.AssertCreated(createdItem); + Assert.AreNotEqual(id,createdItem.Id); + } + + [Test] + [TestCase(TestName = "Create item with existing id", Category = "Create")] + public virtual async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithTheDifferentId(T item = null) + { + var id = item == null ? Guid.NewGuid() : item.Id.GetValueOrDefault(); + + item ??= this.GenerateObject(id); + await this.InsertData(item); + + item ??= this.GenerateObject(id); + + var result = await this.repository.CreateAsync(item); + + this.AssertCreated(result); + Assert.AreEqual(2,context.Set().Count()); + } + #endregion + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs new file mode 100644 index 0000000..e426835 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs @@ -0,0 +1,94 @@ +using System; +using NUnit.Framework; +using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using FinancialHub.Domain.Interfaces.Repositories; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.Data.Sqlite; +using FinancialHub.Domain.NUnitTests.Generators; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T : BaseEntity + { + protected Random random; + protected EntityGenerator generator; + protected FinancialHubContext context; + + protected IBaseRepository repository; + + protected FinancialHubContext GetContext() + { + var conn = new SqliteConnection("DataSource=:memory:"); + conn.Open(); + + var cfg = new DbContextOptionsBuilder().UseSqlite(conn); + cfg.EnableSensitiveDataLogging(true); + + return new FinancialHubContext( + cfg.Options + ); + } + + [SetUp] + protected virtual void Setup() + { + this.context = this.GetContext(); + context.Database.EnsureCreated(); + + this.random = new Random(); + + this.generator = new EntityGenerator(random); + } + + [TearDown] + protected virtual void TearDown() + { + this.context.Dispose(); + } + + #region Generics + protected virtual async Task> InsertData(ICollection items) + where Y : BaseEntity + { + var list = new List(); + foreach (var item in items) + { + var entity = await this.context.Set().AddAsync(item); + await this.context.SaveChangesAsync(); + list.Add(entity.Entity); + } + await this.context.SaveChangesAsync(); + return list; + } + + protected virtual async Task InsertData(Y item) + where Y : BaseEntity + { + var res = await this.context.Set().AddAsync(item); + item.Id = res.Entity.Id; + await this.context.SaveChangesAsync(); + + return res.Entity; + } + + #endregion + + protected virtual ICollection GenerateData(int min = 1, int max = 100) + { + var count = random.Next(min, max); + var data = new T[count]; + + for (int i = 0; i < count; i++) + { + data[i] = this.GenerateObject(Guid.NewGuid()); + } + + return data; + } + + protected abstract T GenerateObject(Guid? id = null); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs new file mode 100644 index 0000000..f15f22d --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs @@ -0,0 +1,37 @@ +using FinancialHub.Domain.Entities; +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T : BaseEntity + { + #region Delete + [Test] + [TestCase(TestName = "Delete existing Item",Category = "Delete")] + public virtual async Task DeleteAsync_ExistingItem_AffectsOneRow() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var affectedRows = await this.repository.DeleteAsync(items.First().Id.Value); + Assert.AreEqual(1,affectedRows); + Assert.AreEqual(items.Count - 1,context.Set().ToList().Count); + } + + [Test] + [TestCase(TestName = "Delete non existing Item",Category = "Delete")] + public virtual async Task DeleteAsync_NonExistingItem_AffectsNothing() + { + var items = this.GenerateData(); + await this.InsertData(items); + + var affectedRows = await this.repository.DeleteAsync(new Guid()); + Assert.AreEqual(0, affectedRows); + Assert.IsNotEmpty(context.Set().ToList()); + } + #endregion + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs new file mode 100644 index 0000000..c580c4e --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs @@ -0,0 +1,139 @@ +using System; +using System.Linq; +using NUnit.Framework; +using System.Threading.Tasks; +using System.Collections.Generic; +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T : BaseEntity + { + #region Get All + [Test] + [TestCase(TestName = "Get All Items without data",Category = "Get")] + public virtual async Task GetAllAsync_NoData_ReturnsEmpty() + { + var list = await this.repository.GetAllAsync(); + + Assert.IsEmpty(list); + Assert.IsInstanceOf>(list); + } + + [Test] + [TestCase(TestName = "Get All Items with data", Category = "Get")] + public virtual async Task GetAllAsync_Data_ReturnsItems() + { + var items = this.GenerateData(); + items = await this.InsertData(items); + + var list = await this.repository.GetAllAsync(); + + Assert.IsNotEmpty(list); + Assert.AreEqual(items,list); + Assert.IsInstanceOf>(list); + } + #endregion + + #region Get + [Test] + [TestCase(TestName = "Get Items with no filter", Category = "Get")] + public virtual async Task GetAsync_NoFilter_ReturnsAllItems() + { + var items = this.GenerateData(); + items = await this.InsertData(items); + + var list = await this.repository.GetAsync((x) => true); + + Assert.IsNotEmpty(list); + Assert.AreEqual(items, list); + Assert.IsInstanceOf>(list); + } + + [Test] + [TestCase(TestName = "Get Items not setting filter", Category = "Get")] + public virtual async Task GetAsync_NullFilter_ThrowsArgumentNullException() + { + var items = this.GenerateData(); + items = await this.InsertData(items); + + Assert.ThrowsAsync(typeof(ArgumentNullException), async () => await this.repository.GetAsync(null)); + } + + [Test] + [TestCase(TestName = "Get Items filtering", Category = "Get")] + public virtual async Task GetAsync_Filter_ReturnsFilteredItems() + { + var items = this.GenerateData(10,100); + items = await this.InsertData(items); + + var id = items.First().Id; + Func filter = (x) => x.Id == id; + var expectedResult = items.Where(filter); + + var list = await this.repository.GetAsync(filter); + + Assert.IsNotEmpty(list); + Assert.AreEqual(expectedResult, list); + Assert.IsInstanceOf>(list); + } + + [Test] + [TestCase(TestName = "Get Items with wrong filter", Category = "Get")] + public virtual async Task GetAsync_WrongFilter_ReturnsEmpty() + { + var items = this.GenerateData(10, 100); + items = await this.InsertData(items); + + Func filter = (x) => x.Id == new Guid(); + + var list = await this.repository.GetAsync(filter); + + Assert.IsEmpty(list); + Assert.IsInstanceOf>(list); + } + #endregion + + #region Get By Id + [Test] + [TestCase(TestName = "Get By Id with empty id", Category = "Get")] + public virtual async Task GetByIdAsync_EmptyId_ReturnsNull() + { + var items = this.GenerateData(); + items = await this.InsertData(items); + + var item = await this.repository.GetByIdAsync(Guid.Empty); + + Assert.IsNull(item); + } + + [Test] + [TestCase(TestName = "Get By Id with existing id", Category = "Get")] + public virtual async Task GetByIdAsync_ExistingId_ReturnsItem() + { + var items = this.GenerateData(1); + items = await this.InsertData(items); + + var id = items.First().Id; + + var item = await this.repository.GetByIdAsync(id.Value); + + Assert.IsNotNull(item); + Assert.AreEqual(id,item.Id); + Assert.IsInstanceOf(item); + } + + [Test] + [TestCase(TestName = "Get By Id with non-existing id", Category = "Get")] + public virtual async Task GetByIdAsync_NonExistingId_ReturnsNull() + { + var items = this.GenerateData(); + items = await this.InsertData(items); + + var item = await this.repository.GetByIdAsync(new Guid()); + + Assert.IsNull(item); + } + #endregion + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs new file mode 100644 index 0000000..7cce1a0 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs @@ -0,0 +1,42 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +{ + public abstract partial class BaseRepositoryTests where T : BaseEntity + { + #region Update + [Test] + [TestCase(TestName = "Update existing Item", Category = "Update")] + public virtual async Task UpdateAsync_ExistingItem_UpdatesItem() + { + var item = this.GenerateObject(); + await this.InsertData(new T[1] { item }); + + var oldCreationTime = item.UpdateTime.GetValueOrDefault(); + + var updatedItem = await this.repository.UpdateAsync(item); + + Assert.IsNotNull(updatedItem); + Assert.IsNotNull(updatedItem.Id); + Assert.IsNotNull(updatedItem.CreationTime); + Assert.IsNotNull(updatedItem.UpdateTime); + Assert.AreNotEqual(oldCreationTime,updatedItem.UpdateTime); + Assert.IsInstanceOf(updatedItem); + } + + [Test] + [TestCase(TestName = "Update non existing Item", Category = "Update")] + public virtual async Task UpdateAsync_NonExistingItem_ThrowsDbUpdateConcurrencyException() + { + var id = Guid.NewGuid(); + var item = this.GenerateObject(id); + + Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(item)); + } + #endregion + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs new file mode 100644 index 0000000..378e290 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs @@ -0,0 +1,23 @@ +using System; +using FinancialHub.Domain.Entities; +using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Infra.Data.Repositories; +using NUnit.Framework; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories +{ + public class CategoriesRepositoryTests : BaseRepositoryTests + { + [SetUp] + protected override void Setup() + { + base.Setup(); + this.repository = new CategoriesRepository(this.context); + } + + protected override CategoryEntity GenerateObject(Guid? id = null) + { + return this.generator.GenerateCategory(id); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs new file mode 100644 index 0000000..9ab06be --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs @@ -0,0 +1,186 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories +{ + public partial class TransactionsRepositoryTests + { + protected override void AssertCreated(TransactionEntity createdItem) + { + base.AssertCreated(createdItem); + + Assert.IsNotNull(createdItem.Account); + Assert.IsNotNull(createdItem.Category); + Assert.AreEqual(createdItem.AccountId, createdItem.Account.Id); + Assert.AreEqual(createdItem.CategoryId, createdItem.Category.Id); + } + + [Test] + [TestCase(TestName = "Create new Transaction with valid Category and Account", Category = "Create")] + public override async Task CreateAsync_ValidItem_AddsOneRow(TransactionEntity item = null) + { + var entity = this.GenerateObject(); + + entity.Category = await this.InsertData(entity.Category); + entity.Account = await this.InsertData(entity.Account); + + await base.CreateAsync_ValidItem_AddsOneRow(entity); + } + + [Test] + [TestCase(TestName = "Create new Item with id", Category = "Create")] + public async override Task CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(TransactionEntity item = null) + { + var entity = this.GenerateObject(); + + var generatedAccount = this.GenerateAccount(entity.AccountId); + var generatedCategory = this.GenerateCategory(entity.CategoryId); + + await this.InsertData(generatedAccount); + await this.InsertData(generatedCategory); + + await base.CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(entity); + } + + [Test] + [TestCase(TestName = "Create item with existing id", Category = "Create")] + public override async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithTheDifferentId(TransactionEntity item = null) + { + var id = Guid.NewGuid(); + item = this.GenerateObject(id); + + //INSERTS ACCOUNT AND CATEGORY + var generatedAccount = this.GenerateAccount(item.AccountId); + var generatedCategory = this.GenerateCategory(item.CategoryId); + + await this.InsertData(generatedAccount); + await this.InsertData(generatedCategory); + + item.Category = null; + item.Account = null; + item = await this.InsertData(item); + + var newItem = this.GenerateObject(id); + newItem.CategoryId = generatedCategory.Id.GetValueOrDefault(); + newItem.AccountId = generatedAccount.Id.GetValueOrDefault(); + + var result = await this.repository.CreateAsync(newItem); + + Assert.AreNotEqual(item.Id,newItem.Id); + this.AssertCreated(result); + Assert.AreEqual(2, context.Set().Count()); + } + + [Test] + [TestCase(TestName = "Create new Transaction without Updates/Creates Account or Category", Category = "Create")] + public async Task CreateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() + { + #warning this test is too complex + + /***** ARRANGE *****/ + var entity = this.GenerateObject(); + + //INSERTS ACCOUNT AND CATEGORY + var oldAccount = this.GenerateAccount(entity.AccountId); + var oldCategory = this.GenerateCategory(entity.CategoryId); + + await this.InsertData(oldAccount); + await this.InsertData(oldCategory); + + //CHANGES TRANSACTION'S CATEGORY AND ACCOUNT + entity.Account.Name = Guid.NewGuid().ToString(); + entity.Category.Name = Guid.NewGuid().ToString(); + + /***** ACT *****/ + + var result = await this.repository.CreateAsync(entity); + + /***** ASSERT *****/ + + this.AssertCreated(result); + + //SHOULD NOT CREATE ACCOUNTS OR CATEGORIES + Assert.AreEqual(1,this.context.Accounts.Count()); + Assert.AreEqual(1,this.context.Categories.Count()); + + var account = this.context.Accounts.FirstOrDefault(x => x.Id == entity.AccountId); + var category = this.context.Categories.FirstOrDefault(x => x.Id == entity.CategoryId); + + //SHOULD NOT UPDATE DATABASE + Assert.AreEqual(oldAccount, account); + Assert.AreEqual(oldCategory, category); + + //SHOULD NOT RETURN THE WRONG ITEM + Assert.AreEqual(oldAccount, result.Account); + Assert.AreEqual(oldCategory, result.Category); + } + + [Test] + [TestCase(TestName = "Create new Transaction with invalid Account", Category = "Create")] + public async Task CreateAsync_InvalidAccountId_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + + await this.InsertData(this.GenerateAccount()); + + entity.Category = await this.InsertData(entity.Category); + entity.CategoryId = entity.Category.Id.GetValueOrDefault(); + + Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); + + Assert.IsEmpty(this.context.Transactions); + Assert.AreEqual(1, this.context.Accounts.Count()); + Assert.AreEqual(1, this.context.Categories.Count()); + } + + [Test] + [TestCase(TestName = "Create new Transaction with invalid Category", Category = "Create")] + public async Task CreateAsync_InvalidCategoryId_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + + await this.InsertData(entity.Account); + await this.InsertData(this.GenerateCategory()); + + Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); + + Assert.IsEmpty(this.context.Transactions); + Assert.AreEqual(1, this.context.Accounts.Count()); + Assert.AreEqual(1, this.context.Categories.Count()); + } + + [Test] + [TestCase(TestName = "Create new Transaction with no Account", Category = "Create")] + public async Task CreateAsync_NoAccount_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + + await this.InsertData(entity.Category); + + entity.Account = null; + + Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); + + Assert.IsEmpty(this.context.Transactions.ToList()); + } + + [Test] + [TestCase(TestName = "Create new Transaction with no Category", Category = "Create")] + public async Task CreateAsync_NoCategory_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + + await this.InsertData(entity.Account); + + entity.Category = null; + + Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); + + Assert.IsEmpty(this.context.Transactions.ToList()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs new file mode 100644 index 0000000..b09bde5 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs @@ -0,0 +1,38 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Infra.Data.Repositories; +using NUnit.Framework; +using System; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories +{ + public partial class TransactionsRepositoryTests : BaseRepositoryTests + { + [SetUp] + protected override void Setup() + { + base.Setup(); + this.repository = new TransactionsRepository(this.context); + } + + protected override TransactionEntity GenerateObject(Guid? id = null) + { + return this.generator.GenerateTransaction(id); + } + + protected TransactionEntity GenerateTransaction(Guid? id = null,Guid? accountId = null, Guid? categoryId = null) + { + return this.generator.GenerateTransaction(id,accountId,categoryId); + } + + protected CategoryEntity GenerateCategory(Guid? id = null) + { + return this.generator.GenerateCategory(id); + } + + protected AccountEntity GenerateAccount(Guid? id = null) + { + return this.generator.GenerateAccount(id); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs new file mode 100644 index 0000000..0480651 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs @@ -0,0 +1,27 @@ +using NUnit.Framework; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories +{ + public partial class TransactionsRepositoryTests + { + [Test] + [TestCase(TestName = "Delete a Transaction without delete Category or Account", Category = "Delete")] + public async Task DeleteAsync_ValidItemWithNestChild_DoesNotDeleteNestChild() + { + var entity = this.GenerateObject(); + + await this.InsertData(entity.Account); + await this.InsertData(entity.Category); + await this.InsertData(entity); + + var result = await this.repository.DeleteAsync(entity.Id.Value); + + Assert.AreEqual(1,result); + + Assert.IsEmpty(this.context.Transactions.Local); + Assert.AreEqual(1, this.context.Accounts.Local.Count); + Assert.AreEqual(1, this.context.Categories.Local.Count); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs new file mode 100644 index 0000000..3d55f77 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs @@ -0,0 +1,116 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories +{ + public partial class TransactionsRepositoryTests + { + protected async Task InsertTransaction(TransactionEntity entity) + { + await this.InsertData(entity.Account); + await this.InsertData(entity.Category); + await this.InsertData(entity); + + context.Entry(entity).State = EntityState.Detached; + } + + [Test] + [TestCase(TestName = "Update Transaction but no Accounts or Category", Category = "Update")] + public async Task UpdateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() + { + var entity = this.GenerateObject(); + await this.InsertTransaction(entity); + + var changedEntity = this.GenerateTransaction(entity.Id, entity.AccountId, entity.CategoryId); + + var result = await this.repository.UpdateAsync(changedEntity); + + this.AssertCreated(result); + + //SHOULD NOT CREATE + Assert.AreEqual(1, this.context.Accounts.Local.Count); + Assert.AreEqual(1, this.context.Categories.Local.Count); + + var account = this.context.Accounts.FirstOrDefault(x => x.Id == changedEntity.AccountId); + var category = this.context.Categories.FirstOrDefault(x => x.Id == changedEntity.CategoryId); + + //SHOULD NOT UPDATE DATABASE + Assert.AreEqual(account, result.Account); + Assert.AreEqual(category, result.Category); + } + + [Test] + [TestCase(TestName = "Update Transaction changing Account", Category = "Update")] + public async Task UpdateAsync_ChangeAccountId_ChangesAccount() + { + var entity = this.GenerateObject(); + await this.InsertTransaction(entity); + + var newAccount = this.GenerateAccount(); + await this.InsertData(newAccount); + + entity.AccountId = (Guid)newAccount.Id; + + var result = await this.repository.CreateAsync(entity); + + this.AssertCreated(result); + + Assert.AreEqual(newAccount.Id, result.AccountId); + Assert.AreEqual(newAccount, result.Account); + } + + [Test] + [TestCase(TestName = "Update Transaction changing Category", Category = "Update")] + public async Task UpdateAsync_ChangeCategoryId_ChangesCategory() + { + var entity = this.GenerateObject(); + await this.InsertTransaction(entity); + + var newCategory = this.GenerateCategory(); + await this.InsertData(newCategory); + + entity.CategoryId = (Guid)newCategory.Id; + + var result = await this.repository.CreateAsync(entity); + + this.AssertCreated(result); + + Assert.AreEqual(newCategory.Id, result.CategoryId); + Assert.AreEqual(newCategory, result.Category); + } + + [Test] + [TestCase(TestName = "Update Transaction with invalid Account", Category = "Update")] + public async Task UpdateAsync_InvalidAccountId_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + var oldCategoryId = entity.Category.Id; + + await this.InsertTransaction(entity); + + var newCategory = this.GenerateCategory(); + entity.CategoryId = (Guid)newCategory.Id; + + Assert.ThrowsAsync( async () =>await this.repository.UpdateAsync(entity)); + } + + [Test] + [TestCase(TestName = "Update Transaction with invalid Category", Category = "Update")] + public async Task UpdateAsync_InvalidCategoryId_ThrowsDbUpdateException() + { + var entity = this.GenerateObject(); + var newCategory = this.GenerateCategory(); + + await this.InsertTransaction(entity); + + entity.CategoryId = (Guid)newCategory.Id; + entity.Category = newCategory; + + Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(entity)); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs new file mode 100644 index 0000000..eaa1803 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs @@ -0,0 +1,42 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using System.Diagnostics.CodeAnalysis; + +namespace FinancialHub.Infra.Data.Contexts +{ + public class FinancialHubContext : DbContext + { + public FinancialHubContext([NotNull] DbContextOptions options) : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(table => + { + table.HasKey(t => t.Id); + table.HasIndex(t => t.Id) + .IsUnique(true); + + table.HasOne(x => x.Account) + .WithMany(x => x.Transactions) + .HasForeignKey(x => x.AccountId) + .HasPrincipalKey(x => x.Id) + .IsRequired(true); + table.Navigation(t => t.Account).AutoInclude(); + + table.HasOne(x => x.Category) + .WithMany(x => x.Transactions) + .HasForeignKey(x => x.CategoryId) + .HasPrincipalKey(x => x.Id) + .IsRequired(true); + table.Navigation(t => t.Category).AutoInclude(); + }); + base.OnModelCreating(modelBuilder); + } + + public DbSet Accounts { get; set; } + public DbSet Transactions { get; set; } + public DbSet Categories { get; set; } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj b/api/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj new file mode 100644 index 0000000..b84f938 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj @@ -0,0 +1,15 @@ + + + + net6.0 + + + + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs new file mode 100644 index 0000000..64fdba3 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs @@ -0,0 +1,15 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Infra.Data.Contexts; +using System.ComponentModel; + +namespace FinancialHub.Infra.Data.Repositories +{ + [Category("Repositories")] + public class AccountsRepository : BaseRepository, IAccountsRepository + { + public AccountsRepository(FinancialHubContext context) : base(context) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs new file mode 100644 index 0000000..d409f6d --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs @@ -0,0 +1,71 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using FinancialHub.Infra.Data.Contexts; +using Microsoft.EntityFrameworkCore; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Repositories; + +namespace FinancialHub.Infra.Data.Repositories +{ + public class BaseRepository : + IBaseRepository + where T : BaseEntity + { + protected readonly FinancialHubContext context; + public BaseRepository(FinancialHubContext context) + { + this.context = context; + } + + public virtual async Task CreateAsync(T obj) + { + obj.Id = null; + obj.CreationTime = DateTimeOffset.Now; + obj.UpdateTime = DateTimeOffset.Now; + + var res = await context.Set().AddAsync(obj); + await context.SaveChangesAsync(); + return res.Entity; + } + + public virtual async Task DeleteAsync(Guid id) + { + var entity = context.Set().FirstOrDefault(x => x.Id == id); + + if(entity != null) + { + context.Set().Remove(entity); + return await context.SaveChangesAsync(); + } + else + { + return 0; + } + } + + public virtual async Task UpdateAsync(T obj) + { + obj.UpdateTime = DateTimeOffset.Now; + var res = context.Set().Update(obj); + await context.SaveChangesAsync(); + return res.Entity; + } + + public virtual async Task> GetAllAsync() + { + return await context.Set().ToListAsync(); + } + + public virtual async Task> GetAsync(Func predicate) + { + return context.Set().Where(predicate).ToList(); + } + + public virtual async Task GetByIdAsync(Guid id) + { + return await context.Set().FirstOrDefaultAsync(x => x.Id == id); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs new file mode 100644 index 0000000..5d422c5 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs @@ -0,0 +1,13 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Infra.Data.Contexts; + +namespace FinancialHub.Infra.Data.Repositories +{ + public class CategoriesRepository : BaseRepository, ICategoriesRepository + { + public CategoriesRepository(FinancialHubContext context) : base(context) + { + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs new file mode 100644 index 0000000..a19ae0f --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs @@ -0,0 +1,35 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Infra.Data.Contexts; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Data.Repositories +{ + public class TransactionsRepository : BaseRepository, ITransactionsRepository + { + public TransactionsRepository(FinancialHubContext context) : base(context) + { + } + + public override async Task CreateAsync(TransactionEntity obj) + { + #warning This is not a good practice, remove this later + if(obj == null) + { + throw new ArgumentNullException(nameof(obj)); + } + + obj.Category = null; + obj.Account = null; + return await base.CreateAsync(obj); + } + + public override async Task UpdateAsync(TransactionEntity obj) + { + obj.Category = null; + obj.Account = null; + return await base.UpdateAsync(obj); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj new file mode 100644 index 0000000..25abc01 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj @@ -0,0 +1,25 @@ + + + + net6.0 + enable + + false + + + + + + + + + + + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs new file mode 100644 index 0000000..eb68365 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs @@ -0,0 +1,74 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class AccountsServiceTests + { + [Test] + [TestCase(Description = "Create valid account", Category = "Create")] + public async Task CreateAsync_ValidAccountModel_ReturnsAccountModel() + { + var model = this.modelGenerator.GenerateAccount(); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var result = await this.service.CreateAsync(model); + + Assert.IsNotNull(result.Data); + Assert.IsInstanceOf>(result); + + this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); + this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); + this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); + } + + [Test] + [TestCase(Description = "Create repository exception", Category = "Create")] + public async Task CreateAsync_RepositoryException_ThrowsException() + { + var model = this.modelGenerator.GenerateAccount(); + var exc = new Exception("mock"); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Throws(exc) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async () => await this.service.CreateAsync(model) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs new file mode 100644 index 0000000..5c3367b --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs @@ -0,0 +1,51 @@ +using AutoMapper; +using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Services.Mappers; +using FinancialHub.Services.Services; +using Moq; +using NUnit.Framework; +using System; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class AccountsServiceTests + { + protected Random random; + protected EntityGenerator entityGenerator; + protected ModelGenerator modelGenerator; + + private IAccountsService service; + + private IMapper mapper; + private Mock mapperWrapper; + private Mock repository; + + private void MockMapper() + { + mapper = new MapperConfiguration(mc => + { + mc.AddProfile(new FinancialHubAutoMapperProfile()); + } + ).CreateMapper(); + + this.mapperWrapper = new Mock(); + } + + [SetUp] + public void Setup() + { + this.MockMapper(); + + this.repository = new Mock(); + this.service = new AccountsService(mapperWrapper.Object,repository.Object); + + this.random = new Random(); + + this.entityGenerator = new EntityGenerator(random); + this.modelGenerator = new ModelGenerator(random); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs new file mode 100644 index 0000000..1bd5df7 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs @@ -0,0 +1,49 @@ +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class AccountsServiceTests + { + [Test] + [TestCase(Description = "Update valid account", Category = "Delete")] + public async Task DeleteAsync_RepositorySuccess_ReturnsAccountModel() + { + var expectedResult = random.Next(1,100); + var guid = Guid.NewGuid(); + this.repository + .Setup(x => x.DeleteAsync(guid)) + .Returns(async () => await Task.FromResult(expectedResult)) + .Verifiable(); + + var result = await this.service.DeleteAsync(guid); + + Assert.IsInstanceOf>(result); + Assert.AreEqual(expectedResult,result.Data); + this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); + } + + [Test] + [TestCase(Description = "Update repository exception", Category = "Delete")] + public async Task DeleteAsync_RepositoryException_ThrowsException() + { + var guid = Guid.NewGuid(); + var exc = new Exception("mock"); + + this.repository + .Setup(x => x.DeleteAsync(guid)) + .Throws(exc) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async () => await this.service.DeleteAsync(guid) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.DeleteAsync(guid), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs new file mode 100644 index 0000000..9e867f0 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs @@ -0,0 +1,67 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class AccountsServiceTests + { + //TODO: change mock when filter by user + [Test] + [TestCase(Description = "Get by user sucess return",Category = "Get")] + public async Task GetByUsersAsync_ValidUser_ReturnsAccounts() + { + var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateAccount(),random.Next(10,100)); + + this.repository + .Setup(x => x.GetAllAsync()) + .ReturnsAsync(entitiesMock.ToArray()) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map>(It.IsAny>())) + .Returns>((ent) => this.mapper.Map>(ent)) + .Verifiable(); + + var result = await this.service.GetAllByUserAsync(string.Empty); + + Assert.IsInstanceOf>>(result); + Assert.IsFalse(result.HasError); + Assert.AreEqual(entitiesMock.Count(), result.Data.Count()); + + this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); + this.repository.Verify(x => x.GetAllAsync(),Times.Once()); + } + + + [Test] + [TestCase(Description = "Get by user repository exception", Category = "Get")] + public async Task GetByUsersAsync_RepositoryException_ThrowsException() + { + var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateAccount(), random.Next(10, 100)); + var exc = new Exception("mock"); + this.repository + .Setup(x => x.GetAllAsync()) + .Throws(exc) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map>(It.IsAny>())) + .Returns>((ent) => this.mapper.Map>(ent)) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async ()=> await this.service.GetAllByUserAsync(string.Empty) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.GetAllAsync(), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs new file mode 100644 index 0000000..d41784f --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs @@ -0,0 +1,111 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class AccountsServiceTests + { + [Test] + [TestCase(Description = "Update valid account", Category = "Update")] + public async Task UpdateAsync_ValidAccountModel_ReturnsAccountModel() + { + var model = this.modelGenerator.GenerateAccount(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsNotNull(result); + Assert.IsInstanceOf>(result); + + this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); + + this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); + this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); + } + + [Test] + [TestCase(Description = "Update non existing account", Category = "Update")] + public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() + { + var model = this.modelGenerator.GenerateAccount(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync((AccountEntity)null) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsInstanceOf>(result); + Assert.IsTrue(result.HasError); + + this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); + } + + [Test] + [TestCase(Description = "Update repository exception", Category = "Update")] + public async Task UpdateAsync_RepositoryException_ThrowsException() + { + var model = this.modelGenerator.GenerateAccount(); + var exc = new Exception("mock"); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Throws(exc) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async () => await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs new file mode 100644 index 0000000..0eefe98 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs @@ -0,0 +1,74 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class CategoriesServiceTests + { + [Test] + [TestCase(Description = "Create valid Category", Category = "Create")] + public async Task CreateAsync_ValidCategoryModel_ReturnsCategoryModel() + { + var model = this.modelGenerator.GenerateCategory(); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var result = await this.service.CreateAsync(model); + + Assert.IsNotNull(result.Data); + Assert.IsInstanceOf>(result); + + this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); + this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); + this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); + } + + [Test] + [TestCase(Description = "Create repository exception", Category = "Create")] + public async Task CreateAsync_RepositoryException_ThrowsException() + { + var model = this.modelGenerator.GenerateCategory(); + var exc = new Exception("mock"); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Throws(exc) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async () => await this.service.CreateAsync(model) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs new file mode 100644 index 0000000..d560d1c --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs @@ -0,0 +1,51 @@ +using AutoMapper; +using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Services.Mappers; +using FinancialHub.Services.Services; +using Moq; +using NUnit.Framework; +using System; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class CategoriesServiceTests + { + protected Random random; + protected EntityGenerator entityGenerator; + protected ModelGenerator modelGenerator; + + private ICategoriesService service; + + private IMapper mapper; + private Mock mapperWrapper; + private Mock repository; + + private void MockMapper() + { + mapper = new MapperConfiguration(mc => + { + mc.AddProfile(new FinancialHubAutoMapperProfile()); + } + ).CreateMapper(); + + this.mapperWrapper = new Mock(); + } + + [SetUp] + public void Setup() + { + this.MockMapper(); + + this.repository = new Mock(); + this.service = new CategoriesService(mapperWrapper.Object,repository.Object); + + this.random = new Random(); + + this.entityGenerator = new EntityGenerator(random); + this.modelGenerator = new ModelGenerator(random); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs new file mode 100644 index 0000000..fdf3858 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs @@ -0,0 +1,49 @@ +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class CategoriesServiceTests + { + [Test] + [TestCase(Description = "Update valid Category", Category = "Delete")] + public async Task DeleteAsync_RepositorySuccess_ReturnsCategoryModel() + { + var expectedResult = random.Next(1,100); + var guid = Guid.NewGuid(); + this.repository + .Setup(x => x.DeleteAsync(guid)) + .Returns(async () => await Task.FromResult(expectedResult)) + .Verifiable(); + + var result = await this.service.DeleteAsync(guid); + + Assert.IsInstanceOf>(result); + Assert.AreEqual(expectedResult,result.Data); + this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); + } + + [Test] + [TestCase(Description = "Update repository exception", Category = "Delete")] + public async Task DeleteAsync_RepositoryException_ThrowsException() + { + var guid = Guid.NewGuid(); + var exc = new Exception("mock"); + + this.repository + .Setup(x => x.DeleteAsync(guid)) + .Throws(exc) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async () => await this.service.DeleteAsync(guid) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.DeleteAsync(guid), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs new file mode 100644 index 0000000..8a9ac8d --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs @@ -0,0 +1,67 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class CategoriesServiceTests + { + //TODO: change mock when filter by user + [Test] + [TestCase(Description = "Get by user sucess return",Category = "Get")] + public async Task GetByUsersAsync_ValidUser_ReturnsCategories() + { + var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateCategory(),random.Next(10,100)); + + this.repository + .Setup(x => x.GetAllAsync()) + .ReturnsAsync(entitiesMock.ToArray()) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map>(It.IsAny>())) + .Returns>((ent) => this.mapper.Map>(ent)) + .Verifiable(); + + var result = await this.service.GetAllByUserAsync(string.Empty); + + Assert.IsInstanceOf>>(result); + Assert.IsFalse(result.HasError); + Assert.AreEqual(entitiesMock.Count(), result.Data.Count); + + this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); + this.repository.Verify(x => x.GetAllAsync(),Times.Once()); + } + + + [Test] + [TestCase(Description = "Get by user repository exception", Category = "Get")] + public async Task GetByUsersAsync_RepositoryException_ThrowsException() + { + var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateCategory(), random.Next(10, 100)); + var exc = new Exception("mock"); + this.repository + .Setup(x => x.GetAllAsync()) + .Throws(exc) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map>(It.IsAny>())) + .Returns>((ent) => this.mapper.Map>(ent)) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async ()=> await this.service.GetAllByUserAsync(string.Empty) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.GetAllAsync(), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs new file mode 100644 index 0000000..605c90c --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs @@ -0,0 +1,111 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class CategoriesServiceTests + { + [Test] + [TestCase(Description = "Update valid Category", Category = "Update")] + public async Task UpdateAsync_ValidCategoryModel_ReturnsCategoryModel() + { + var model = this.modelGenerator.GenerateCategory(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsNotNull(result); + Assert.IsInstanceOf>(result); + + this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); + + this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); + this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); + } + + [Test] + [TestCase(Description = "Update non existing Category", Category = "Update")] + public async Task UpdateAsync_NonExistingCategoryId_ReturnsResultError() + { + var model = this.modelGenerator.GenerateCategory(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync((CategoryEntity)null) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsInstanceOf>(result); + Assert.IsTrue(result.HasError); + + this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); + } + + [Test] + [TestCase(Description = "Update repository exception", Category = "Update")] + public async Task UpdateAsync_RepositoryException_ThrowsException() + { + var model = this.modelGenerator.GenerateCategory(); + var exc = new Exception("mock"); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Throws(exc) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async () => await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs new file mode 100644 index 0000000..b190145 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs @@ -0,0 +1,74 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionsServiceTests + { + [Test] + [TestCase(Description = "Create valid Transaction", Category = "Create")] + public async Task CreateAsync_ValidTransactionModel_ReturnsTransactionModel() + { + var model = this.modelGenerator.GenerateTransaction(); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var result = await this.service.CreateAsync(model); + + Assert.IsNotNull(result.Data); + Assert.IsInstanceOf>(result); + + this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); + this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); + this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); + } + + [Test] + [TestCase(Description = "Create repository exception", Category = "Create")] + public async Task CreateAsync_RepositoryException_ThrowsException() + { + var model = this.modelGenerator.GenerateTransaction(); + var exc = new Exception("mock"); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Throws(exc) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async () => await this.service.CreateAsync(model) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs new file mode 100644 index 0000000..e3e6be6 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs @@ -0,0 +1,51 @@ +using AutoMapper; +using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Services.Mappers; +using FinancialHub.Services.Services; +using Moq; +using NUnit.Framework; +using System; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionsServiceTests + { + protected Random random; + protected EntityGenerator entityGenerator; + protected ModelGenerator modelGenerator; + + private ITransactionsService service; + + private IMapper mapper; + private Mock mapperWrapper; + private Mock repository; + + private void MockMapper() + { + mapper = new MapperConfiguration(mc => + { + mc.AddProfile(new FinancialHubAutoMapperProfile()); + } + ).CreateMapper(); + + this.mapperWrapper = new Mock(); + } + + [SetUp] + public void Setup() + { + this.MockMapper(); + + this.repository = new Mock(); + this.service = new TransactionsService(mapperWrapper.Object,repository.Object); + + this.random = new Random(); + + this.entityGenerator = new EntityGenerator(random); + this.modelGenerator = new ModelGenerator(random); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs new file mode 100644 index 0000000..bb3f960 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs @@ -0,0 +1,49 @@ +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionsServiceTests + { + [Test] + [TestCase(Description = "Update valid Transaction", Category = "Delete")] + public async Task DeleteAsync_RepositorySuccess_ReturnsTransactionModel() + { + var expectedResult = random.Next(1,100); + var guid = Guid.NewGuid(); + this.repository + .Setup(x => x.DeleteAsync(guid)) + .Returns(async () => await Task.FromResult(expectedResult)) + .Verifiable(); + + var result = await this.service.DeleteAsync(guid); + + Assert.IsInstanceOf>(result); + Assert.AreEqual(expectedResult,result.Data); + this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); + } + + [Test] + [TestCase(Description = "Update repository exception", Category = "Delete")] + public async Task DeleteAsync_RepositoryException_ThrowsException() + { + var guid = Guid.NewGuid(); + var exc = new Exception("mock"); + + this.repository + .Setup(x => x.DeleteAsync(guid)) + .Throws(exc) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async () => await this.service.DeleteAsync(guid) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.DeleteAsync(guid), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs new file mode 100644 index 0000000..10c1305 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs @@ -0,0 +1,87 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Filters; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Queries; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionsServiceTests + { + //TODO: change mock when filter by user + //TODO: add validation tests + //TODO: add filter validation tests + [Test] + [TestCase(Description = "Get by user sucess return",Category = "Get")] + public async Task GetByUsersAsync_ValidUser_ReturnsTransactions() + { + var filter = new TransactionFilter(); + var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateTransaction(),random.Next(10,100)); + + this.repository + .Setup(x => x.GetAsync(It.IsAny>())) + .ReturnsAsync(entitiesMock.ToArray()) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map>(It.IsAny>())) + .Returns>((ent) => this.mapper.Map>(ent)) + .Verifiable(); + + var result = await this.service.GetAllByUserAsync(string.Empty, filter); + + Assert.IsInstanceOf>>(result); + Assert.IsFalse(result.HasError); + Assert.AreEqual(entitiesMock.Count(), result.Data.Count); + + this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); + this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); + this.repository.Verify(x => x.GetAsync(It.IsAny>()), Times.Once()); + } + + + [Test] + [TestCase(Description = "Get by user repository exception", Category = "Get")] + public async Task GetByUsersAsync_RepositoryException_ThrowsException() + { + var filter = new TransactionFilter(); + + var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateTransaction(), random.Next(10, 100)); + var exc = new Exception("mock"); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.repository + .Setup(x => x.GetAsync(It.IsAny>())) + .Throws(exc) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map>(It.IsAny>())) + .Returns>((ent) => this.mapper.Map>(ent)) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async ()=> await this.service.GetAllByUserAsync(string.Empty, filter) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); + this.repository.Verify(x => x.GetAsync(It.IsAny>()), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs new file mode 100644 index 0000000..07e3119 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs @@ -0,0 +1,111 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionsServiceTests + { + [Test] + [TestCase(Description = "Update valid Transaction", Category = "Update")] + public async Task UpdateAsync_ValidTransactionModel_ReturnsTransactionModel() + { + var model = this.modelGenerator.GenerateTransaction(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsNotNull(result); + Assert.IsInstanceOf>(result); + + this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); + + this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); + this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); + } + + [Test] + [TestCase(Description = "Update non existing Transaction", Category = "Update")] + public async Task UpdateAsync_NonExistingTransactionId_ReturnsResultError() + { + var model = this.modelGenerator.GenerateTransaction(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync((TransactionEntity)null) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsInstanceOf>(result); + Assert.IsTrue(result.HasError); + + this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); + } + + [Test] + [TestCase(Description = "Update repository exception", Category = "Update")] + public async Task UpdateAsync_RepositoryException_ThrowsException() + { + var model = this.modelGenerator.GenerateTransaction(); + var exc = new Exception("mock"); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Throws(exc) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + + var exception = Assert.ThrowsAsync( + async () => await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model) + ); + + Assert.IsInstanceOf(exc.GetType(), exception); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once()); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs index 4c29b70..fdd916e 100644 --- a/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs +++ b/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs @@ -4,6 +4,8 @@ using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Domain.Interfaces.Services; using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Results.Errors; namespace FinancialHub.Services.Services { @@ -18,7 +20,7 @@ public AccountsService(IMapperWrapper mapper,IAccountsRepository repository) this.repository = repository; } - public async Task CreateAsync(AccountModel account) + public async Task> CreateAsync(AccountModel account) { var entity = mapper.Map(account); @@ -27,26 +29,39 @@ public async Task CreateAsync(AccountModel account) return mapper.Map(entity); } - public async Task DeleteAsync(Guid id) + public async Task> DeleteAsync(Guid id) { - return await this.repository.DeleteAsync(id); + var count = await this.repository.DeleteAsync(id); + + return new ServiceResult(count); } - public async Task> GetAllByUserAsync(string userId) + public async Task>> GetAllByUserAsync(string userId) { var entities = await this.repository.GetAllAsync(); - return mapper.Map>(entities); + + var list = this.mapper.Map>(entities); + + return list.ToArray(); } - public async Task UpdateAsync(Guid id, AccountModel account) + public async Task> GetByIdAsync(Guid id) { var entity = await this.repository.GetByIdAsync(id); - if(entity == null) + return this.mapper.Map(entity); + } + + public async Task> UpdateAsync(Guid id, AccountModel account) + { + var entity = await this.repository.GetByIdAsync(id); + + if (entity == null) { - throw new NullReferenceException($"Not found account with id {id}"); + return new NotFoundError($"Not found account with id {id}"); } - entity.Id = id; + + entity = this.mapper.Map(account); entity = await this.repository.UpdateAsync(entity); diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs index ea97f66..c782c2a 100644 --- a/api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs +++ b/api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs @@ -3,6 +3,8 @@ using FinancialHub.Domain.Interfaces.Services; using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Results.Errors; namespace FinancialHub.Services.Services { @@ -17,7 +19,7 @@ public CategoriesService(IMapperWrapper mapper, ICategoriesRepository repository this.repository = repository; } - public async Task CreateAsync(CategoryModel category) + public async Task> CreateAsync(CategoryModel category) { var entity = mapper.Map(category); @@ -26,27 +28,31 @@ public async Task CreateAsync(CategoryModel category) return mapper.Map(entity); } - public async Task DeleteAsync(Guid id) + public async Task> DeleteAsync(Guid id) { return await this.repository.DeleteAsync(id); } - public async Task> GetAllByUserAsync(string userId) + public async Task>> GetAllByUserAsync(string userId) { var entities = await this.repository.GetAllAsync(); - return mapper.Map>(entities); + + var list = this.mapper.Map>(entities); + + return list.ToArray(); } - public async Task UpdateAsync(Guid id, CategoryModel category) + public async Task> UpdateAsync(Guid id, CategoryModel category) { var entity = await this.repository.GetByIdAsync(id); if (entity == null) { - throw new NullReferenceException($"Not found category with id {id}"); + return new NotFoundError($"Not found category with id {id}"); } entity.Id = id; + entity = this.mapper.Map(category); entity = await this.repository.UpdateAsync(entity); return mapper.Map(entity); diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs index 0617274..d714f67 100644 --- a/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs +++ b/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs @@ -5,6 +5,8 @@ using FinancialHub.Domain.Interfaces.Services; using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Results.Errors; namespace FinancialHub.Services.Services { @@ -19,7 +21,7 @@ public TransactionsService(IMapperWrapper mapper, ITransactionsRepository reposi this.repository = repository; } - public async Task CreateAsync(TransactionModel category) + public async Task> CreateAsync(TransactionModel category) { var entity = mapper.Map(category); @@ -28,30 +30,33 @@ public async Task CreateAsync(TransactionModel category) return mapper.Map(entity); } - public async Task DeleteAsync(Guid id) + public async Task> DeleteAsync(Guid id) { return await this.repository.DeleteAsync(id); } - public async Task> GetAllByUserAsync(string userId, TransactionFilter filter) + public async Task>> GetAllByUserAsync(string userId, TransactionFilter filter) { var query = mapper.Map(filter); //query.UserId = userId; var entities = await this.repository.GetAsync(query.Query()); - return mapper.Map>(entities); + var models = mapper.Map>(entities); + + return models.ToArray(); } - public async Task UpdateAsync(Guid id, TransactionModel category) + public async Task> UpdateAsync(Guid id, TransactionModel transaction) { var entity = await this.repository.GetByIdAsync(id); if (entity == null) { - throw new NullReferenceException($"Not found category with id {id}"); + return new NotFoundError($"Not found transaction with id {id}"); } - entity.Id = id; + + entity = this.mapper.Map(transaction); entity = await this.repository.UpdateAsync(entity); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs new file mode 100644 index 0000000..2d2cfc5 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs @@ -0,0 +1,67 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results.Errors; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class AccountsControllerTests + { + [Test] + public async Task CreateAccount_Valid_ReturnsOk() + { + var body = this.modelGenerator.GenerateAccount(); + var mockResult = new ServiceResult(body); + + this.mockService + .Setup(x => x.CreateAsync(body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.CreateAccount(body); + + var result = response as ObjectResult; + + Assert.AreEqual(200, result?.StatusCode); + Assert.IsInstanceOf>(result?.Value); + + var listResponse = result?.Value as SaveResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + } + + [Test] + public async Task CreateAccount_Invalid_ReturnsBadRequest() + { + var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; + var body = this.modelGenerator.GenerateAccount(); + + var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); + + this.mockService + .Setup(x => x.CreateAsync(body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.CreateAccount(body); + + var result = response as ObjectResult; + + Assert.AreEqual(400, result?.StatusCode); + Assert.IsInstanceOf(result?.Value); + + var listResponse = result?.Value as ValidationErrorResponse; + Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + + this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs new file mode 100644 index 0000000..48170e8 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs @@ -0,0 +1,35 @@ +using Moq; +using System; +using NUnit.Framework; +using FinancialHub.WebApi.Controllers; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.NUnitTests.Generators; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + //TODO: create default controller test + //TODO: create integration test for controllers + + //TODO: start to use : + //https://docs.educationsmediagroup.com/unit-testing-csharp/nunit/parameterized-tests + //or + //https://docs.nunit.org/articles/nunit/writing-tests/attributes/theory.html + public partial class AccountsControllerTests + { + private Random random; + private ModelGenerator modelGenerator; + + private AccountsController controller; + private Mock mockService; + + [SetUp] + public void Setup() + { + this.random = new Random(); + this.modelGenerator = new ModelGenerator(random); + + this.mockService = new Mock(); + this.controller = new AccountsController(this.mockService.Object); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs new file mode 100644 index 0000000..bbd76ee --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Mvc; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class AccountsControllerTests + { + [Test] + public async Task DeleteMyAccounts_ServiceSuccess_ReturnsNoContent() + { + var mock = this.modelGenerator.GenerateAccount(); + var response = await this.controller.DeleteAccount(mock.Id.GetValueOrDefault()); + + var result = response as ObjectResult; + + Assert.IsNull(result?.Value); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs new file mode 100644 index 0000000..5251def --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs @@ -0,0 +1,42 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class AccountsControllerTests + { + + [Test] + public async Task GetMyAccounts_ServiceSuccess_ReturnsOk( + //ServiceResult> mockResult + ) + { + var mockResult = new ServiceResult>( + Enumerable.Repeat(modelGenerator.GenerateAccount(), random.Next(0, 10)).ToArray() + ); + + this.mockService + .Setup(x => x.GetAllByUserAsync(It.IsAny())) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.GetMyAccounts(); + var result = (ObjectResult)response; + + Assert.AreEqual(200, result.StatusCode); + Assert.IsInstanceOf>(result.Value); + + var listResponse = result.Value as ListResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.GetAllByUserAsync(It.IsAny()), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs new file mode 100644 index 0000000..93e0950 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs @@ -0,0 +1,69 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Results.Errors; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class AccountsControllerTests + { + [Test] + public async Task UpdateAccount_Valid_ReturnsOk() + { + var body = this.modelGenerator.GenerateAccount(); + var guid = body.Id.GetValueOrDefault(); + var mockResult = new ServiceResult(body); + + this.mockService + .Setup(x => x.UpdateAsync(guid, body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.UpdateAccount(guid, body); + + var result = response as ObjectResult; + + Assert.AreEqual(200, result?.StatusCode); + Assert.IsInstanceOf>(result?.Value); + + var listResponse = result?.Value as SaveResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); + } + + [Test] + public async Task UpdateAccount_Invalid_ReturnsBadRequest() + { + var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; + var body = this.modelGenerator.GenerateAccount(); + var guid = body.Id.GetValueOrDefault(); + + var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); + + this.mockService + .Setup(x => x.UpdateAsync(guid,body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.UpdateAccount(guid,body); + + var result = response as ObjectResult; + + Assert.AreEqual(400, result?.StatusCode); + Assert.IsInstanceOf(result?.Value); + + var listResponse = result?.Value as ValidationErrorResponse; + Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + + this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs new file mode 100644 index 0000000..3e2e987 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs @@ -0,0 +1,67 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results.Errors; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class CategoriesControllerTests + { + [Test] + public async Task CreateCategory_Valid_ReturnsOk() + { + var body = this.modelGenerator.GenerateCategory(); + var mockResult = new ServiceResult(body); + + this.mockService + .Setup(x => x.CreateAsync(body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.CreateCategory(body); + + var result = response as ObjectResult; + + Assert.AreEqual(200, result?.StatusCode); + Assert.IsInstanceOf>(result?.Value); + + var listResponse = result?.Value as SaveResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + } + + [Test] + public async Task CreateCategory_Invalid_ReturnsBadRequest() + { + var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; + var body = this.modelGenerator.GenerateCategory(); + + var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); + + this.mockService + .Setup(x => x.CreateAsync(body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.CreateCategory(body); + + var result = response as ObjectResult; + + Assert.AreEqual(400, result?.StatusCode); + Assert.IsInstanceOf(result?.Value); + + var listResponse = result?.Value as ValidationErrorResponse; + Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + + this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs new file mode 100644 index 0000000..194769c --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs @@ -0,0 +1,28 @@ +using Moq; +using System; +using NUnit.Framework; +using FinancialHub.WebApi.Controllers; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.NUnitTests.Generators; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class CategoriesControllerTests + { + private Random random; + private ModelGenerator modelGenerator; + + private CategoriesController controller; + private Mock mockService; + + [SetUp] + public void Setup() + { + this.random = new Random(); + this.modelGenerator = new ModelGenerator(random); + + this.mockService = new Mock(); + this.controller = new CategoriesController(this.mockService.Object); + } + } +} \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs new file mode 100644 index 0000000..5ec35a7 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Mvc; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class CategoriesControllerTests + { + [Test] + public async Task DeleteMyCategories_ServiceSuccess_ReturnsNoContent() + { + var mock = this.modelGenerator.GenerateAccount(); + var response = await this.controller.DeleteCategory(mock.Id.GetValueOrDefault()); + + var result = response as ObjectResult; + + Assert.IsNull(result?.Value); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs new file mode 100644 index 0000000..c1c30a2 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs @@ -0,0 +1,40 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class CategoriesControllerTests + { + + [Test] + public async Task GetMyCategories_ServiceSuccess_ReturnsOk() + { + var mockResult = new ServiceResult>( + Enumerable.Repeat(modelGenerator.GenerateCategory(), random.Next(0, 10)).ToArray() + ); + + this.mockService + .Setup(x => x.GetAllByUserAsync(It.IsAny())) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.GetMyCategories(); + var result = (ObjectResult)response; + + Assert.AreEqual(200, result.StatusCode); + Assert.IsInstanceOf>(result.Value); + + var listResponse = result.Value as ListResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.GetAllByUserAsync(It.IsAny()), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs new file mode 100644 index 0000000..e4a93a2 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs @@ -0,0 +1,69 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Results.Errors; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class CategoriesControllerTests + { + [Test] + public async Task UpdateCategory_Valid_ReturnsOk() + { + var body = this.modelGenerator.GenerateCategory(); + var guid = body.Id.GetValueOrDefault(); + var mockResult = new ServiceResult(body); + + this.mockService + .Setup(x => x.UpdateAsync(guid, body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.UpdateCategory(guid, body); + + var result = response as ObjectResult; + + Assert.AreEqual(200, result?.StatusCode); + Assert.IsInstanceOf>(result?.Value); + + var listResponse = result?.Value as SaveResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); + } + + [Test] + public async Task UpdateCategory_Invalid_ReturnsBadRequest() + { + var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; + var body = this.modelGenerator.GenerateCategory(); + var guid = body.Id.GetValueOrDefault(); + + var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); + + this.mockService + .Setup(x => x.UpdateAsync(guid,body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.UpdateCategory(guid,body); + + var result = response as ObjectResult; + + Assert.AreEqual(400, result?.StatusCode); + Assert.IsInstanceOf(result?.Value); + + var listResponse = result?.Value as ValidationErrorResponse; + Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + + this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs new file mode 100644 index 0000000..584dfe0 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs @@ -0,0 +1,67 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results.Errors; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class TransactionsControllerTests + { + [Test] + public async Task CreateTransaction_Valid_ReturnsOk() + { + var body = this.modelGenerator.GenerateTransaction(); + var mockResult = new ServiceResult(body); + + this.mockService + .Setup(x => x.CreateAsync(body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.CreateTransaction(body); + + var result = response as ObjectResult; + + Assert.AreEqual(200, result?.StatusCode); + Assert.IsInstanceOf>(result?.Value); + + var listResponse = result?.Value as SaveResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + } + + [Test] + public async Task CreateTransaction_Invalid_ReturnsBadRequest() + { + var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; + var body = this.modelGenerator.GenerateTransaction(); + + var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); + + this.mockService + .Setup(x => x.CreateAsync(body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.CreateTransaction(body); + + var result = response as ObjectResult; + + Assert.AreEqual(400, result?.StatusCode); + Assert.IsInstanceOf(result?.Value); + + var listResponse = result?.Value as ValidationErrorResponse; + Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + + this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs new file mode 100644 index 0000000..6a298c7 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs @@ -0,0 +1,28 @@ +using Moq; +using System; +using NUnit.Framework; +using FinancialHub.WebApi.Controllers; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.NUnitTests.Generators; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class TransactionsControllerTests + { + private Random random; + private ModelGenerator modelGenerator; + + private TransactionsController controller; + private Mock mockService; + + [SetUp] + public void Setup() + { + this.random = new Random(); + this.modelGenerator = new ModelGenerator(random); + + this.mockService = new Mock(); + this.controller = new TransactionsController(this.mockService.Object); + } + } +} \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs new file mode 100644 index 0000000..fc06ccf --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Mvc; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class TransactionsControllerTests + { + [Test] + public async Task DeleteMyTransactions_ServiceSuccess_ReturnsNoContent() + { + var mock = this.modelGenerator.GenerateAccount(); + var response = await this.controller.DeleteTransaction(mock.Id.GetValueOrDefault()); + + var result = response as ObjectResult; + + Assert.IsNull(result?.Value); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs new file mode 100644 index 0000000..22fd043 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs @@ -0,0 +1,42 @@ +using FinancialHub.Domain.Filters; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class TransactionsControllerTests + { + [Test] + public async Task GetMyTransactions_ServiceSuccess_ReturnsOk() + { + var mockResult = new ServiceResult>( + Enumerable.Repeat(modelGenerator.GenerateTransaction(), random.Next(0, 10)).ToArray() + ); + + var filter = new TransactionFilter(); + + this.mockService + .Setup(x => x.GetAllByUserAsync(It.IsAny(),filter)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.GetMyTransactions(filter); + var result = (ObjectResult)response; + + Assert.AreEqual(200, result.StatusCode); + Assert.IsInstanceOf>(result.Value); + + var listResponse = result.Value as ListResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.GetAllByUserAsync(It.IsAny(),filter), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs new file mode 100644 index 0000000..98269d7 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs @@ -0,0 +1,69 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Results.Errors; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class TransactionsControllerTests + { + [Test] + public async Task UpdateTransaction_Valid_ReturnsOk() + { + var body = this.modelGenerator.GenerateTransaction(); + var guid = body.Id.GetValueOrDefault(); + var mockResult = new ServiceResult(body); + + this.mockService + .Setup(x => x.UpdateAsync(guid, body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.UpdateTransaction(guid, body); + + var result = response as ObjectResult; + + Assert.AreEqual(200, result?.StatusCode); + Assert.IsInstanceOf>(result?.Value); + + var listResponse = result?.Value as SaveResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); + } + + [Test] + public async Task UpdateTransaction_Invalid_ReturnsBadRequest() + { + var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; + var body = this.modelGenerator.GenerateTransaction(); + var guid = body.Id.GetValueOrDefault(); + + var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); + + this.mockService + .Setup(x => x.UpdateAsync(guid,body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.UpdateTransaction(guid,body); + + var result = response as ObjectResult; + + Assert.AreEqual(400, result?.StatusCode); + Assert.IsInstanceOf(result?.Value); + + var listResponse = result?.Value as ValidationErrorResponse; + Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + + this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj new file mode 100644 index 0000000..9955e55 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj @@ -0,0 +1,24 @@ + + + + net6.0 + enable + + false + + + + + + + + + + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs index c8b56e5..f9e16f0 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs @@ -1,9 +1,10 @@ -using FinancialHub.Domain.Interfaces.Services; -using System.Collections.Generic; -using FinancialHub.Domain.Models; -using System; +using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; namespace FinancialHub.WebApi.Controllers { @@ -15,7 +16,7 @@ public class AccountsController : Controller { private readonly IAccountsService service; - public AccountsController(IAccountsService service) + public AccountsController(IAccountsService service) { this.service = service; } @@ -24,18 +25,12 @@ public AccountsController(IAccountsService service) /// Get all accounts of the system (will be changed to only one user) /// [HttpGet] - [ProducesResponseType(typeof(ICollection), 200)] + [ProducesResponseType(typeof(ListResponse), 200)] public async Task GetMyAccounts() { - try - { - var response = await service.GetAllByUserAsync("mock"); - return Ok(response); - } - catch (Exception e) - { - return BadRequest(e); - } + var result = await service.GetAllByUserAsync("mock"); + + return Ok(new ListResponse(result.Data)); } /// @@ -43,18 +38,21 @@ public async Task GetMyAccounts() /// /// Account to be created [HttpPost] - [ProducesResponseType(typeof(ICollection),200)] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] public async Task CreateAccount([FromBody] AccountModel account) { - try - { - var response = await service.CreateAsync(account); - return Ok(response); - } - catch (Exception e) + var result = await service.CreateAsync(account); + + if (result.HasError) { - return BadRequest(e); + return StatusCode( + result.Error.Code, + new ValidationErrorResponse(result.Error.Message) + ); } + + return Ok( new SaveResponse(result.Data)); } /// @@ -63,18 +61,22 @@ public async Task CreateAccount([FromBody] AccountModel account) /// id of the account /// account changes [HttpPut("{id}")] - [ProducesResponseType(typeof(ICollection), 200)] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(NotFoundErrorResponse), 404)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] public async Task UpdateAccount([FromRoute] Guid id, [FromBody] AccountModel account) { - try - { - var response = await service.UpdateAsync(id,account); - return Ok(response); - } - catch (Exception e) + var response = await service.UpdateAsync(id, account); + + if (response.HasError) { - return BadRequest(e); + return StatusCode( + response.Error.Code, + new ValidationErrorResponse(response.Error.Message) + ); } + + return Ok(new SaveResponse(response.Data)); } /// @@ -84,15 +86,8 @@ public async Task UpdateAccount([FromRoute] Guid id, [FromBody] A [HttpDelete("{id}")] public async Task DeleteAccount([FromRoute] Guid id) { - try - { - await service.DeleteAsync(id); - return NoContent(); - } - catch (Exception e) - { - return BadRequest(e); - } + await service.DeleteAsync(id); + return NoContent(); } } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs new file mode 100644 index 0000000..ba1e19c --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs @@ -0,0 +1,27 @@ +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; + +namespace FinancialHub.WebApi.Controllers.Base +{ + [ApiController] + [System.Obsolete("Maybe use a middleware")] + public abstract class BaseController : ControllerBase + { + protected IActionResult CreateResponse(ServiceResult result) + { + return this.StatusCode(result.Error.Code,result.Data); + } + + protected IActionResult SuccessListResponse(ServiceResult> result) + { + return this.Ok(new ListResponse(result.Data)); + } + + protected IActionResult SuccessSaveResponse(ServiceResult result) + { + return this.Ok(new SaveResponse(result.Data)); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs index 7bf194d..2b168c1 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs @@ -1,16 +1,16 @@ using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Responses.Errors; using FinancialHub.Domain.Models; using Microsoft.AspNetCore.Mvc; -using System; -using System.Collections.Generic; using System.Threading.Tasks; +using System; namespace FinancialHub.WebApi.Controllers { [ApiController] [Route("[controller]")] [Produces("application/json")] - [ProducesErrorResponseType(typeof(Exception))] public class CategoriesController : Controller { private readonly ICategoriesService service; @@ -20,79 +20,72 @@ public CategoriesController(ICategoriesService service) this.service = service; } - [HttpGet] - [ProducesResponseType(typeof(ICollection), 200)] /// /// Get all categorys of the system (will be changed to only one user) /// + [HttpGet] + [ProducesResponseType(typeof(ListResponse), 200)] public async Task GetMyCategories() { - try - { - var response = await service.GetAllByUserAsync("mock"); - return Ok(response); - } - catch (Exception e) - { - return BadRequest(e); - } + var result = await service.GetAllByUserAsync("mock"); + + return Ok(new ListResponse(result.Data)); } - [HttpPost] - [ProducesResponseType(typeof(ICollection), 200)] /// /// Creates an category on database (will be changed to only one user) /// /// Account to be created + [HttpPost] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] public async Task CreateCategory([FromBody] CategoryModel category) { - try - { - var response = await service.CreateAsync(category); - return Ok(response); - } - catch (Exception e) + var result = await service.CreateAsync(category); + + if (result.HasError) { - return BadRequest(e); + return StatusCode( + result.Error.Code, + new ValidationErrorResponse(result.Error.Message) + ); } + + return Ok(new SaveResponse(result.Data)); } - [HttpPut("{id}")] - [ProducesResponseType(typeof(ICollection), 200)] /// /// Updates an existing category on database /// /// id of the category /// category changes + [HttpPut("{id}")] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] public async Task UpdateCategory([FromRoute] Guid id, [FromBody] CategoryModel category) { - try - { - var response = await service.UpdateAsync(id, category); - return Ok(response); - } - catch (Exception e) + var result = await service.UpdateAsync(id, category); + + if (result.HasError) { - return BadRequest(e); + return StatusCode( + result.Error.Code, + new ValidationErrorResponse(result.Error.Message) + ); } + + return Ok(new SaveResponse(result.Data)); } - [HttpDelete("{id}")] /// /// Deletes an existing category on database /// /// id of the category + [HttpDelete("{id}")] public async Task DeleteCategory([FromRoute] Guid id) { - try - { - await service.DeleteAsync(id); - return NoContent(); - } - catch (Exception e) - { - return BadRequest(e); - } + await service.DeleteAsync(id); + return NoContent(); } } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs index ef21932..68218d8 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs @@ -2,16 +2,16 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using FinancialHub.Domain.Models; -using System.Collections.Generic; -using FinancialHub.Domain.Interfaces.Services; using FinancialHub.Domain.Filters; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Interfaces.Services; namespace FinancialHub.WebApi.Controllers { [ApiController] [Route("[controller]")] [Produces("application/json")] - [ProducesErrorResponseType(typeof(Exception))]//TODO: custom exceptions public class TransactionsController : Controller { private readonly ITransactionsService service; @@ -22,46 +22,41 @@ public TransactionsController(ITransactionsService service) } [HttpGet] - [ProducesResponseType(typeof(ICollection), 200)] + [ProducesResponseType(typeof(ListResponse), 200)] /// /// Get all transaction of the system (will be changed to only one user and added filters) /// - public async Task GetMyTransactions( - [FromQuery] TransactionFilter filter - ) + public async Task GetMyTransactions([FromQuery] TransactionFilter filter) { - try - { - var response = await service.GetAllByUserAsync("mock", filter); - return Ok(response); - } - catch (Exception e) - { - return BadRequest(e); - } + var response = await service.GetAllByUserAsync("mock", filter); + return Ok(new ListResponse(response.Data)); } [HttpPost] - [ProducesResponseType(typeof(ICollection), 200)] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] /// /// Creates an transaction on database (will be changed to only one user) /// /// Transaction to be created public async Task CreateTransaction([FromBody] TransactionModel transaction) { - try - { - var response = await service.CreateAsync(transaction); - return Ok(response); - } - catch (Exception e) + var result = await service.CreateAsync(transaction); + + if (result.HasError) { - return BadRequest(e); + return StatusCode( + result.Error.Code, + new ValidationErrorResponse(result.Error.Message) + ); } + + return Ok(new SaveResponse(result.Data)); } [HttpPut("{id}")] - [ProducesResponseType(typeof(ICollection), 200)] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] /// /// Updates an existing transaction on database /// @@ -69,15 +64,18 @@ public async Task CreateTransaction([FromBody] TransactionModel t /// transaction changes public async Task UpdateTransaction([FromRoute] Guid id, [FromBody] TransactionModel transaction) { - try - { - var response = await service.UpdateAsync(id, transaction); - return Ok(response); - } - catch (Exception e) + var result = await service.UpdateAsync(id, transaction); + + if (result.HasError) { - return BadRequest(e); + return StatusCode( + result.Error.Code, + new ValidationErrorResponse(result.Error.Message) + ); } + + return Ok(new SaveResponse(result.Data)); + } [HttpDelete("{id}")] @@ -88,15 +86,8 @@ public async Task UpdateTransaction([FromRoute] Guid id, [FromBod /// id of the transaction public async Task DeleteTransaction([FromRoute] Guid id) { - try - { - await service.DeleteAsync(id); - return NoContent(); - } - catch (Exception e) - { - return BadRequest(e); - } + await service.DeleteAsync(id); + return NoContent(); } } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj index 31ce0de..8a64540 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -4,6 +4,10 @@ net6.0 + + + + @@ -26,7 +30,7 @@ - + diff --git a/api/src/FinancialHub/FinancialHub.sln b/api/src/FinancialHub/FinancialHub.sln index 99844d1..f08f39b 100644 --- a/api/src/FinancialHub/FinancialHub.sln +++ b/api/src/FinancialHub/FinancialHub.sln @@ -5,19 +5,25 @@ VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain", "FinancialHub.Domain\FinancialHub.Domain.csproj", "{776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data", "FinancialHub.Infra\FinancialHub.Infra.Data.csproj", "{126F1390-1B86-4ABB-9E49-E77B7857E2F0}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{1F4F43B0-14F5-4C91-B98C-AEB8A5421258}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{2444FB9D-15D1-4193-BF04-83C4397369DA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.NUnitTests", "MyFinancialHub.Infra.NUnitTests\FinancialHub.Infra.NUnitTests.csproj", "{D88B870B-D7EF-41CF-B24F-8D85C37559E1}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{91A212DC-1D96-43DD-B1A0-153ACB6980D5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.Services", "FinancialHub.Services\FinancialHub.Services.csproj", "{7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services", "FinancialHub.Services\FinancialHub.Services.csproj", "{7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services.NUnitTests", "FinancialHub.Services.NUnitTests\FinancialHub.Services.NUnitTests.csproj", "{DD50583D-8D5F-42B8-9225-3BCCCDC8B122}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain.NUnitTests", "FinancialHub.Domain.NUnitTests\FinancialHub.Domain.NUnitTests.csproj", "{4AD8BB4F-58F2-4488-BB95-D96CFD78F662}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data", "FinancialHub.Infra.Data\FinancialHub.Infra.Data.csproj", "{19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data.NUnitTests", "FinancialHub.Infra.Data.NUnitTests\FinancialHub.Infra.Data.NUnitTests.csproj", "{5A26CFA8-B077-4C91-BED9-C47339F960A2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.WebApi.NUnitTests", "FinancialHub.WebApi.NUnitTests\FinancialHub.WebApi.NUnitTests.csproj", "{40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -29,31 +35,45 @@ Global {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Release|Any CPU.Build.0 = Release|Any CPU - {126F1390-1B86-4ABB-9E49-E77B7857E2F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {126F1390-1B86-4ABB-9E49-E77B7857E2F0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {126F1390-1B86-4ABB-9E49-E77B7857E2F0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {126F1390-1B86-4ABB-9E49-E77B7857E2F0}.Release|Any CPU.Build.0 = Release|Any CPU {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Release|Any CPU.Build.0 = Release|Any CPU - {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D88B870B-D7EF-41CF-B24F-8D85C37559E1}.Release|Any CPU.Build.0 = Release|Any CPU {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Debug|Any CPU.Build.0 = Debug|Any CPU {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Release|Any CPU.ActiveCfg = Release|Any CPU {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Release|Any CPU.Build.0 = Release|Any CPU + {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Release|Any CPU.Build.0 = Release|Any CPU + {4AD8BB4F-58F2-4488-BB95-D96CFD78F662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4AD8BB4F-58F2-4488-BB95-D96CFD78F662}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AD8BB4F-58F2-4488-BB95-D96CFD78F662}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4AD8BB4F-58F2-4488-BB95-D96CFD78F662}.Release|Any CPU.Build.0 = Release|Any CPU + {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Release|Any CPU.Build.0 = Release|Any CPU + {5A26CFA8-B077-4C91-BED9-C47339F960A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5A26CFA8-B077-4C91-BED9-C47339F960A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A26CFA8-B077-4C91-BED9-C47339F960A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5A26CFA8-B077-4C91-BED9-C47339F960A2}.Release|Any CPU.Build.0 = Release|Any CPU + {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} - {126F1390-1B86-4ABB-9E49-E77B7857E2F0} = {2444FB9D-15D1-4193-BF04-83C4397369DA} - {D88B870B-D7EF-41CF-B24F-8D85C37559E1} = {2444FB9D-15D1-4193-BF04-83C4397369DA} {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {DD50583D-8D5F-42B8-9225-3BCCCDC8B122} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {4AD8BB4F-58F2-4488-BB95-D96CFD78F662} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} + {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3} = {2444FB9D-15D1-4193-BF04-83C4397369DA} + {5A26CFA8-B077-4C91-BED9-C47339F960A2} = {2444FB9D-15D1-4193-BF04-83C4397369DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} From cc173840365bf897be9df93bcdc69672dcf081ce Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Wed, 6 Apr 2022 17:34:59 -0300 Subject: [PATCH 07/30] Release v0.2.3 * Add : EntityBuilders * Add : ModelBuilders * Add : Integration tests * Change : Builder Pattern added to UnitTests * Remove : EntityGenerator * Remove : Useless Test Projects --- .../Generators/EntityGenerator.cs | 71 ----- .../Generators/ModelGenerator.cs | 65 ----- .../Builders/Entities/AccountEntityBuilder.cs | 39 +++ .../Builders/Entities/BaseEntityBuilder.cs | 35 +++ .../Entities/CategoryEntityBuilder.cs | 32 +++ .../Entities/TransactionEntityBuilder.cs | 81 ++++++ .../Builders/Models/AccountModelBuilder.cs | 39 +++ .../Builders/Models/BaseModelBuilder.cs | 21 ++ .../Builders/Models/CategoryModelBuilder.cs | 32 +++ .../Models/TransactionModelBuilder.cs | 78 ++++++ .../FinancialHub.Domain.Tests.csproj} | 0 .../Interfaces/Services/IAccountsService.cs | 2 - .../FinancialHub.Infra.Data.NUnitTests.csproj | 2 +- .../Accounts/AccountsRepositoryTests.cs | 8 +- .../Base/BaseRepositoryTests.create.cs | 2 - .../Repositories/Base/BaseRepositoryTests.cs | 48 ++-- .../Base/BaseRepositoryTests.delete.cs | 2 - .../Base/BaseRepositoryTests.update.cs | 2 +- .../Categories/CategoriesRepositoryTests.cs | 10 +- .../TransactionsRepositoryTests.cs | 51 +++- .../Contexts/FinancialHubContext.cs | 3 +- .../Contexts/FinancialHubContext.cs | 42 --- .../FinancialHub.Infra.Data.csproj | 15 - .../Repositories/AccountsRepository.cs | 15 - .../Repositories/BaseRepository.cs | 71 ----- .../Repositories/CategoriesRepository.cs | 13 - .../Repositories/TransactionsRepository.cs | 35 --- .../Services/AccountsService.cs | 58 ---- .../Services/CategoriesService.cs | 58 ---- .../Services/TransactionsService.cs | 64 ----- .../Base/BaseControllerTests.cs | 33 +++ .../Controllers/AccountsControllerTests.cs | 156 +++++++++++ .../Controllers/CategoriesControllerTests.cs | 156 +++++++++++ .../TransactionsControllerTests.cs | 263 ++++++++++++++++++ .../Extensions/HttpClientExtensions.cs | 25 ++ .../HttpResponseMessageExtensions.cs | 30 ++ .../IServiceCollectionExtensions.cs | 27 ++ .../FinancialHub.IntegrationTests.csproj | 26 ++ .../Setup/DbConnectionStringManager.cs | 43 +++ .../Setup/FinancialHubFixture.cs | 76 +++++ .../FinancialHub.Services.NUnitTests.csproj | 2 +- .../Accounts/AccountsServiceTests.create.cs | 6 +- .../Services/Accounts/AccountsServiceTests.cs | 17 +- .../Accounts/AccountsServiceTests.delete.cs | 2 +- .../Accounts/AccountsServiceTests.get.cs | 9 +- .../Accounts/AccountsServiceTests.update.cs | 10 +- .../CategoriesServiceTests.create.cs | 6 +- .../Categories/CategoriesServiceTests.cs | 18 +- .../Categories/CategoriesServiceTests.get.cs | 7 +- .../CategoriesServiceTests.update.cs | 10 +- .../TransactionsServiceTests.create.cs | 6 +- .../Transactions/TransactionsServiceTests.cs | 18 +- .../TransactionsServiceTests.delete.cs | 2 +- .../TransactionsServiceTests.get.cs | 8 +- .../TransactionsServiceTests.update.cs | 10 +- .../Services/TransactionsService.cs | 2 +- .../AccountsControllerTests.create.cs | 10 +- .../Accounts/AccountsControllerTests.cs | 13 +- .../AccountsControllerTests.delete.cs | 3 +- .../Accounts/AccountsControllerTests.get.cs | 19 +- .../AccountsControllerTests.update.cs | 22 +- .../CategoriesControllerTests.create.cs | 18 +- .../Categories/CategoriesControllerTests.cs | 6 +- .../CategoriesControllerTests.delete.cs | 7 +- .../CategoriesControllerTests.get.cs | 17 +- .../CategoriesControllerTests.update.cs | 6 +- .../TransactionsControllerTests.create.cs | 6 +- .../TransactionsControllerTests.cs | 6 +- .../TransactionsControllerTests.delete.cs | 3 +- .../TransactionsControllerTests.get.cs | 6 +- .../TransactionsControllerTests.update.cs | 6 +- .../FinancialHub.WebApi.NUnitTests.csproj | 2 +- .../appsettings.Development.json | 6 +- .../FinancialHub.WebApi/appsettings.json | 2 +- api/src/FinancialHub/FinancialHub.sln | 22 +- .../FinancialHub.Infra.NUnitTests.csproj | 27 -- .../Generators/EntityGenerator.cs | 71 ----- .../Accounts/AccountsRepositoryTests.cs | 24 -- .../Base/BaseRepositoryTests.create.cs | 65 ----- .../Repositories/Base/BaseRepositoryTests.cs | 94 ------- .../Base/BaseRepositoryTests.delete.cs | 37 --- .../Base/BaseRepositoryTests.get.cs | 139 --------- .../Base/BaseRepositoryTests.update.cs | 42 --- .../Categories/CategoriesRepositoryTests.cs | 23 -- .../TransactionsRepositoryTests.create.cs | 186 ------------- .../TransactionsRepositoryTests.cs | 38 --- .../TransactionsRepositoryTests.delete.cs | 27 -- .../TransactionsRepositoryTests.update.cs | 116 -------- 88 files changed, 1447 insertions(+), 1584 deletions(-) delete mode 100644 api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/EntityGenerator.cs delete mode 100644 api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/ModelGenerator.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs rename api/src/FinancialHub/{FinancialHub.Domain.NUnitTests/FinancialHub.Domain.NUnitTests.csproj => FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj} (100%) delete mode 100644 api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs delete mode 100644 api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.Data.csproj delete mode 100644 api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs delete mode 100644 api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs delete mode 100644 api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs delete mode 100644 api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs delete mode 100644 api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs delete mode 100644 api/src/FinancialHub/FinancialHub.Infra/Services/CategoriesService.cs delete mode 100644 api/src/FinancialHub/FinancialHub.Infra/Services/TransactionsService.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs delete mode 100644 api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/EntityGenerator.cs b/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/EntityGenerator.cs deleted file mode 100644 index 13b359f..0000000 --- a/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/EntityGenerator.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Bogus; -using System; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Enums; - -namespace FinancialHub.Domain.NUnitTests.Generators -{ - public class EntityGenerator - { - private readonly Random random; - - public EntityGenerator(Random random) - { - this.random = random; - } - - public AccountEntity GenerateAccount(Guid? id = null) - { - var fake = new Faker(); - - fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) - .RuleFor(x => x.Name, fake => fake.Finance.AccountName()) - .RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code) - .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1,5))) - .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) - .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) - .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); - - return fake.Generate(); - } - - public CategoryEntity GenerateCategory(Guid? id = null) - { - var fake = new Faker(); - - fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) - .RuleFor(x => x.Name, fake => fake.Finance.Random.Word()) - .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) - .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) - .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) - .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); - - return fake.Generate(); - } - - public TransactionEntity GenerateTransaction(Guid? id = null, Guid? accountId = null, Guid? categoryId = null) - { - var account = this.GenerateAccount(accountId); - var category = this.GenerateCategory(categoryId); - - var fake = new Faker(); - - fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) - .RuleFor(x => x.Amount , fake => fake.Random.Decimal(0,10000)) - .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) - .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) - .RuleFor(x => x.Type, fake => fake.PickRandom()) - .RuleFor(x => x.Status , fake => fake.PickRandom()) - .RuleFor(x => x.AccountId, fake => account.Id) - .RuleFor(x => x.Account, fake => account) - .RuleFor(x => x.CategoryId, fake => category.Id) - .RuleFor(x => x.Category, fake => category) - .RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset()) - .RuleFor(x => x.FinishDate, fake => fake.Date.RecentOffset()) - .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) - .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); - - return fake.Generate(); - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/ModelGenerator.cs b/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/ModelGenerator.cs deleted file mode 100644 index e5dbc92..0000000 --- a/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/Generators/ModelGenerator.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Bogus; -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Models; -using System; - -namespace FinancialHub.Domain.NUnitTests.Generators -{ - public class ModelGenerator - { - private readonly Random random; - - public ModelGenerator(Random random) - { - this.random = random; - } - - public AccountModel GenerateAccount(Guid? id = null) - { - var fake = new Faker(); - - fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) - .RuleFor(x => x.Name, fake => fake.Finance.AccountName()) - .RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code) - .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) - .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); - - return fake.Generate(); - } - - public CategoryModel GenerateCategory(Guid? id = null) - { - var fake = new Faker(); - - fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) - .RuleFor(x => x.Name, fake => fake.Finance.Random.Word()) - .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) - .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); - - return fake.Generate(); - } - - public TransactionModel GenerateTransaction(Guid? id = null, Guid? accountId = null, Guid? categoryId = null) - { - var account = this.GenerateAccount(accountId); - var category = this.GenerateCategory(categoryId); - - var fake = new Faker(); - - fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) - .RuleFor(x => x.Amount, fake => fake.Random.Decimal(0, 10000)) - .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) - .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) - .RuleFor(x => x.Type, fake => fake.PickRandom()) - .RuleFor(x => x.Status, fake => fake.PickRandom()) - .RuleFor(x => x.AccountId, fake => account.Id) - .RuleFor(x => x.Account, fake => account) - .RuleFor(x => x.CategoryId, fake => category.Id) - .RuleFor(x => x.Category, fake => category) - .RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset()) - .RuleFor(x => x.FinishDate, fake => fake.Date.RecentOffset()); - - return fake.Generate(); - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs new file mode 100644 index 0000000..5e70ad4 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs @@ -0,0 +1,39 @@ +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Domain.Tests.Builders.Entities +{ + public class AccountEntityBuilder : BaseEntityBuilder + { + public AccountEntityBuilder() : base() + { + this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); + this.RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code); + this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); + this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); + } + + public AccountEntityBuilder WithName(string name) + { + this.RuleFor(c => c.Name, name); + return this; + } + + public AccountEntityBuilder WithCurrency(string currency) + { + this.RuleFor(c => c.Currency, currency); + return this; + } + + public AccountEntityBuilder WithDescription(string description) + { + this.RuleFor(c => c.Description, description); + return this; + } + + public AccountEntityBuilder WithActive(bool isActive) + { + this.RuleFor(c => c.IsActive, isActive); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs new file mode 100644 index 0000000..fa01e78 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs @@ -0,0 +1,35 @@ +using Bogus; +using System; +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Domain.Tests.Builders.Entities +{ + public abstract class BaseEntityBuilder : Faker + where T : BaseEntity + { + public BaseEntityBuilder() + { + this.RuleFor(x => x.Id, fake => fake.Random.Guid()); + this.RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now); + this.RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); + } + + public BaseEntityBuilder WithId(Guid id) + { + this.RuleFor(c => c.Id, id); + return this; + } + + public BaseEntityBuilder WithCreationTime(DateTimeOffset creationTime) + { + this.RuleFor(c => c.CreationTime, creationTime); + return this; + } + + public BaseEntityBuilder WithUpdateTime(DateTimeOffset updateTime) + { + this.RuleFor(c => c.UpdateTime, updateTime); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs new file mode 100644 index 0000000..c7c97e5 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs @@ -0,0 +1,32 @@ +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Domain.Tests.Builders.Entities +{ + public class CategoryEntityBuilder : BaseEntityBuilder + { + public CategoryEntityBuilder() : base() + { + this.RuleFor(x => x.Name, fake => fake.Finance.Random.Word()); + this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); + this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); + } + + public CategoryEntityBuilder WithName(string name) + { + this.RuleFor(c => c.Name, name); + return this; + } + + public CategoryEntityBuilder WithDescription(string description) + { + this.RuleFor(c => c.Description, description); + return this; + } + + public CategoryEntityBuilder WithActive(bool isActive) + { + this.RuleFor(c => c.IsActive, isActive); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs new file mode 100644 index 0000000..238572d --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs @@ -0,0 +1,81 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Enums; +using System; + +namespace FinancialHub.Domain.Tests.Builders.Entities +{ + public class TransactionEntityBuilder : BaseEntityBuilder + { + public TransactionEntityBuilder() : base() + { + var account = new AccountEntityBuilder().Generate(); + var category = new CategoryEntityBuilder().Generate(); + + this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000),2)); + this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); + this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); + this.RuleFor(x => x.Type, fake => fake.PickRandom()); + this.RuleFor(x => x.Status, fake => fake.PickRandom()); + + this.RuleFor(x => x.AccountId, fake => account.Id); + this.RuleFor(x => x.Account, fake => account); + this.RuleFor(x => x.CategoryId, fake => category.Id); + this.RuleFor(x => x.Category, fake => category); + + this.RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset()); + this.RuleFor(x => x.FinishDate, fake => fake.Date.RecentOffset()); + } + + public TransactionEntityBuilder WithCategoryId(Guid? categoryId) + { + this.RuleFor(x => x.CategoryId, fake => categoryId); + this.RuleFor(x => x.Category, fake => default); + return this; + } + + public TransactionEntityBuilder WithCategory(CategoryEntity category) + { + this.WithCategoryId(category.Id); + this.RuleFor(x => x.Category, fake => category); + return this; + } + + public TransactionEntityBuilder WithAccount(AccountEntity account) + { + this.WithAccountId(account.Id); + this.RuleFor(x => x.Account, fake => account); + return this; + } + + public TransactionEntityBuilder WithAccountId(Guid? accountId) + { + this.RuleFor(x => x.AccountId, fake => accountId); + this.RuleFor(x => x.Account, fake => default); + return this; + } + + public TransactionEntityBuilder WithStatus(TransactionStatus transactionStatus) + { + this.RuleFor(x => x.Status, fake => transactionStatus); + return this; + } + + public TransactionEntityBuilder WithAmount(decimal amount) + { + this.RuleFor(x => x.Amount, fake => amount); + return this; + } + + public TransactionEntityBuilder WithType(TransactionType type) + { + this.RuleFor(x => x.Type, fake => type); + return this; + } + + public TransactionEntityBuilder WithActiveStatus(bool isActive) + { + this.RuleFor(x => x.IsActive, fake => isActive); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs new file mode 100644 index 0000000..3b47b3b --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs @@ -0,0 +1,39 @@ +using FinancialHub.Domain.Models; + +namespace FinancialHub.Domain.Tests.Builders.Models +{ + public class AccountModelBuilder : BaseModelBuilder + { + public AccountModelBuilder() : base() + { + this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); + this.RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code); + this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); + this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); + } + + public AccountModelBuilder WithName(string name) + { + this.RuleFor(c => c.Name, name); + return this; + } + + public AccountModelBuilder WithCurrency(string currency) + { + this.RuleFor(c => c.Currency, currency); + return this; + } + + public AccountModelBuilder WithDescription(string description) + { + this.RuleFor(c => c.Description, description); + return this; + } + + public AccountModelBuilder WithActive(bool isActive) + { + this.RuleFor(c => c.IsActive, isActive); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs new file mode 100644 index 0000000..e2d74a0 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs @@ -0,0 +1,21 @@ +using Bogus; +using FinancialHub.Domain.Model; +using System; + +namespace FinancialHub.Domain.Tests.Builders.Models +{ + public class BaseModelBuilder : Faker + where T : BaseModel + { + public BaseModelBuilder() + { + this.RuleFor(x => x.Id,y => y.System.Random.Guid()); + } + + public BaseModelBuilder WithId(Guid guid) + { + this.RuleFor(x => x.Id, guid); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs new file mode 100644 index 0000000..2f29ef1 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs @@ -0,0 +1,32 @@ +using FinancialHub.Domain.Models; + +namespace FinancialHub.Domain.Tests.Builders.Models +{ + public class CategoryModelBuilder : BaseModelBuilder + { + public CategoryModelBuilder() : base() + { + this.RuleFor(x => x.Name, fake => fake.Finance.Random.Word()); + this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); + this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool());; + } + + public CategoryModelBuilder WithName(string name) + { + this.RuleFor(c => c.Name, name); + return this; + } + + public CategoryModelBuilder WithDescription(string description) + { + this.RuleFor(c => c.Description, description); + return this; + } + + public CategoryModelBuilder WithActive(bool isActive) + { + this.RuleFor(c => c.IsActive, isActive); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs new file mode 100644 index 0000000..e2412c5 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs @@ -0,0 +1,78 @@ +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Models; +using System; + +namespace FinancialHub.Domain.Tests.Builders.Models +{ + public class TransactionModelBuilder : BaseModelBuilder + { + public TransactionModelBuilder() : base() + { + var account = new AccountModelBuilder().Generate(); + var category = new CategoryModelBuilder().Generate(); + + this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000),2)); + this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); + this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); + this.RuleFor(x => x.Type, fake => fake.PickRandom()); + this.RuleFor(x => x.Status, fake => fake.PickRandom()); + this.RuleFor(x => x.AccountId, fake => account.Id); + this.RuleFor(x => x.Account, fake => account); + this.RuleFor(x => x.CategoryId, fake => category.Id); + this.RuleFor(x => x.Category, fake => category); + + } + + public TransactionModelBuilder WithCategoryId(Guid? categoryId) + { + this.RuleFor(x => x.CategoryId, fake => categoryId); + this.RuleFor(x => x.Category, fake => default); + return this; + } + + public TransactionModelBuilder WithCategory(CategoryModel category) + { + this.WithCategoryId(category.Id); + this.RuleFor(x => x.Category, fake => category); + return this; + } + + public TransactionModelBuilder WithAccount(AccountModel account) + { + this.WithAccountId(account.Id); + this.RuleFor(x => x.Account, fake => account); + return this; + } + + public TransactionModelBuilder WithAccountId(Guid? accountId) + { + this.RuleFor(x => x.AccountId, fake => accountId); + this.RuleFor(x => x.Account, fake => default); + return this; + } + + public TransactionModelBuilder WithStatus(TransactionStatus transactionStatus) + { + this.RuleFor(x => x.Status, fake => transactionStatus); + return this; + } + + public TransactionModelBuilder WithAmount(decimal amount) + { + this.RuleFor(x => x.Amount, fake => amount); + return this; + } + + public TransactionModelBuilder WithType(TransactionType type) + { + this.RuleFor(x => x.Type, fake => type); + return this; + } + + public TransactionModelBuilder WithActiveStatus(bool isActive) + { + this.RuleFor(x => x.IsActive, fake => isActive); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.NUnitTests/FinancialHub.Domain.NUnitTests.csproj b/api/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.NUnitTests/FinancialHub.Domain.NUnitTests.csproj rename to api/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs index 5fd3765..bea7b2d 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs @@ -2,9 +2,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using FinancialHub.Domain.Models; using FinancialHub.Domain.Results; -using System.Collections.Generic; namespace FinancialHub.Domain.Interfaces.Services { diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj index 01d19f4..07ee470 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj @@ -20,7 +20,7 @@ - + diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs index cf5ab0b..a3e5833 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs @@ -3,6 +3,7 @@ using FinancialHub.Domain.Entities; using FinancialHub.Infra.Data.Repositories; using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Domain.Tests.Builders.Entities; namespace FinancialHub.Infra.Data.NUnitTests.Repositories { @@ -13,12 +14,7 @@ protected override void Setup() { base.Setup(); this.repository = new AccountsRepository(this.context); - } - - protected override AccountEntity GenerateObject(Guid? id = null) - { - - return this.generator.GenerateAccount(id); + this.builder = new AccountEntityBuilder(); } } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs index 9791475..95d99c7 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs @@ -19,7 +19,6 @@ protected virtual void AssertCreated(T createdItem) Assert.IsNotEmpty(context.Set().ToList()); } - #region Create [Test] [TestCase(TestName = "Create new Item", Category = "Create")] public virtual async Task CreateAsync_ValidItem_AddsOneRow(T item = null) @@ -60,6 +59,5 @@ public virtual async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithTheD this.AssertCreated(result); Assert.AreEqual(2,context.Set().Count()); } - #endregion } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs index e426835..5926af0 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs @@ -1,26 +1,27 @@ using System; -using NUnit.Framework; -using FinancialHub.Infra.Data.Contexts; -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using FinancialHub.Domain.Interfaces.Repositories; using System.Collections.Generic; using System.Threading.Tasks; +using NUnit.Framework; +using Microsoft.EntityFrameworkCore; using Microsoft.Data.Sqlite; -using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Tests.Builders.Entities; +using FinancialHub.Domain.Entities; +using FinancialHub.Infra.Data.Contexts; namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base { - public abstract partial class BaseRepositoryTests where T : BaseEntity + public abstract partial class BaseRepositoryTests + where T : BaseEntity { - protected Random random; - protected EntityGenerator generator; + protected BaseEntityBuilder builder; protected FinancialHubContext context; protected IBaseRepository repository; protected FinancialHubContext GetContext() { + //TODO: use docker/ local sql database var conn = new SqliteConnection("DataSource=:memory:"); conn.Open(); @@ -32,15 +33,12 @@ protected FinancialHubContext GetContext() ); } + #region lifeCycle [SetUp] protected virtual void Setup() - { + { this.context = this.GetContext(); - context.Database.EnsureCreated(); - - this.random = new Random(); - - this.generator = new EntityGenerator(random); + this.context.Database.EnsureCreated(); } [TearDown] @@ -48,6 +46,7 @@ protected virtual void TearDown() { this.context.Dispose(); } + #endregion #region Generics protected virtual async Task> InsertData(ICollection items) @@ -78,17 +77,20 @@ protected virtual async Task InsertData(Y item) protected virtual ICollection GenerateData(int min = 1, int max = 100) { - var count = random.Next(min, max); - var data = new T[count]; + var count = new Random().Next(min, max); + return this.builder.Generate(count); + } - for (int i = 0; i < count; i++) + protected virtual T GenerateObject(Guid? id = null) + { + if (id == null) { - data[i] = this.GenerateObject(Guid.NewGuid()); + return this.builder.Generate(); + } + else + { + return this.builder.WithId(id.Value).Generate(); } - - return data; } - - protected abstract T GenerateObject(Guid? id = null); } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs index f15f22d..50788b3 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs @@ -8,7 +8,6 @@ namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity { - #region Delete [Test] [TestCase(TestName = "Delete existing Item",Category = "Delete")] public virtual async Task DeleteAsync_ExistingItem_AffectsOneRow() @@ -32,6 +31,5 @@ public virtual async Task DeleteAsync_NonExistingItem_AffectsNothing() Assert.AreEqual(0, affectedRows); Assert.IsNotEmpty(context.Set().ToList()); } - #endregion } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs index 7cce1a0..73bea04 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs @@ -30,7 +30,7 @@ public virtual async Task UpdateAsync_ExistingItem_UpdatesItem() [Test] [TestCase(TestName = "Update non existing Item", Category = "Update")] - public virtual async Task UpdateAsync_NonExistingItem_ThrowsDbUpdateConcurrencyException() + public virtual void UpdateAsync_NonExistingItem_ThrowsDbUpdateConcurrencyException() { var id = Guid.NewGuid(); var item = this.GenerateObject(id); diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs index 378e290..fd19b4f 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs @@ -1,5 +1,5 @@ -using System; -using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Tests.Builders.Entities; using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; using FinancialHub.Infra.Data.Repositories; using NUnit.Framework; @@ -13,11 +13,7 @@ protected override void Setup() { base.Setup(); this.repository = new CategoriesRepository(this.context); - } - - protected override CategoryEntity GenerateObject(Guid? id = null) - { - return this.generator.GenerateCategory(id); + this.builder = new CategoryEntityBuilder(); } } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs index b09bde5..9b3c797 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs @@ -1,4 +1,5 @@ using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Tests.Builders.Entities; using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; using FinancialHub.Infra.Data.Repositories; using NUnit.Framework; @@ -8,31 +9,67 @@ namespace FinancialHub.Infra.Data.NUnitTests.Repositories { public partial class TransactionsRepositoryTests : BaseRepositoryTests { + private AccountEntityBuilder accountEntityBuilder; + private CategoryEntityBuilder categoryEntityBuilder; + [SetUp] protected override void Setup() { base.Setup(); this.repository = new TransactionsRepository(this.context); - } - protected override TransactionEntity GenerateObject(Guid? id = null) - { - return this.generator.GenerateTransaction(id); + this.accountEntityBuilder = new AccountEntityBuilder(); + this.categoryEntityBuilder = new CategoryEntityBuilder(); + + this.builder = new TransactionEntityBuilder(); } protected TransactionEntity GenerateTransaction(Guid? id = null,Guid? accountId = null, Guid? categoryId = null) { - return this.generator.GenerateTransaction(id,accountId,categoryId); + var category = this.GenerateCategory(categoryId); + var account = this.GenerateAccount(accountId); + + var build = (TransactionEntityBuilder)this.builder; + + if (id == null) + { + return build + .WithAccount(account) + .WithCategory(category) + .Generate(); + } + else + { + return build + .WithAccount(account) + .WithCategory(category) + .WithId(id.Value) + .Generate(); + } } protected CategoryEntity GenerateCategory(Guid? id = null) { - return this.generator.GenerateCategory(id); + if (id == null) + { + return this.categoryEntityBuilder.Generate(); + } + else + { + return this.categoryEntityBuilder.WithId(id.Value).Generate(); + } } protected AccountEntity GenerateAccount(Guid? id = null) { - return this.generator.GenerateAccount(id); + if (id == null) + { + return this.accountEntityBuilder.Generate(); + } + else + { + return this.accountEntityBuilder.WithId(id.Value).Generate(); + } } } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs index eaa1803..2dc2b79 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs @@ -15,8 +15,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(table => { table.HasKey(t => t.Id); - table.HasIndex(t => t.Id) - .IsUnique(true); + table.HasIndex(t => t.Id).IsUnique(true); table.HasOne(x => x.Account) .WithMany(x => x.Transactions) diff --git a/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs b/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs deleted file mode 100644 index eaa1803..0000000 --- a/api/src/FinancialHub/FinancialHub.Infra/Contexts/FinancialHubContext.cs +++ /dev/null @@ -1,42 +0,0 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using System.Diagnostics.CodeAnalysis; - -namespace FinancialHub.Infra.Data.Contexts -{ - public class FinancialHubContext : DbContext - { - public FinancialHubContext([NotNull] DbContextOptions options) : base(options) - { - } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(table => - { - table.HasKey(t => t.Id); - table.HasIndex(t => t.Id) - .IsUnique(true); - - table.HasOne(x => x.Account) - .WithMany(x => x.Transactions) - .HasForeignKey(x => x.AccountId) - .HasPrincipalKey(x => x.Id) - .IsRequired(true); - table.Navigation(t => t.Account).AutoInclude(); - - table.HasOne(x => x.Category) - .WithMany(x => x.Transactions) - .HasForeignKey(x => x.CategoryId) - .HasPrincipalKey(x => x.Id) - .IsRequired(true); - table.Navigation(t => t.Category).AutoInclude(); - }); - base.OnModelCreating(modelBuilder); - } - - public DbSet Accounts { get; set; } - public DbSet Transactions { get; set; } - public DbSet Categories { get; set; } - } -} diff --git a/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.Data.csproj b/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.Data.csproj deleted file mode 100644 index b84f938..0000000 --- a/api/src/FinancialHub/FinancialHub.Infra/FinancialHub.Infra.Data.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - net6.0 - - - - - - - - - - - diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs deleted file mode 100644 index 64fdba3..0000000 --- a/api/src/FinancialHub/FinancialHub.Infra/Repositories/AccountsRepository.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Data.Contexts; -using System.ComponentModel; - -namespace FinancialHub.Infra.Data.Repositories -{ - [Category("Repositories")] - public class AccountsRepository : BaseRepository, IAccountsRepository - { - public AccountsRepository(FinancialHubContext context) : base(context) - { - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs deleted file mode 100644 index d409f6d..0000000 --- a/api/src/FinancialHub/FinancialHub.Infra/Repositories/BaseRepository.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.Generic; -using FinancialHub.Infra.Data.Contexts; -using Microsoft.EntityFrameworkCore; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Repositories; - -namespace FinancialHub.Infra.Data.Repositories -{ - public class BaseRepository : - IBaseRepository - where T : BaseEntity - { - protected readonly FinancialHubContext context; - public BaseRepository(FinancialHubContext context) - { - this.context = context; - } - - public virtual async Task CreateAsync(T obj) - { - obj.Id = null; - obj.CreationTime = DateTimeOffset.Now; - obj.UpdateTime = DateTimeOffset.Now; - - var res = await context.Set().AddAsync(obj); - await context.SaveChangesAsync(); - return res.Entity; - } - - public virtual async Task DeleteAsync(Guid id) - { - var entity = context.Set().FirstOrDefault(x => x.Id == id); - - if(entity != null) - { - context.Set().Remove(entity); - return await context.SaveChangesAsync(); - } - else - { - return 0; - } - } - - public virtual async Task UpdateAsync(T obj) - { - obj.UpdateTime = DateTimeOffset.Now; - var res = context.Set().Update(obj); - await context.SaveChangesAsync(); - return res.Entity; - } - - public virtual async Task> GetAllAsync() - { - return await context.Set().ToListAsync(); - } - - public virtual async Task> GetAsync(Func predicate) - { - return context.Set().Where(predicate).ToList(); - } - - public virtual async Task GetByIdAsync(Guid id) - { - return await context.Set().FirstOrDefaultAsync(x => x.Id == id); - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs deleted file mode 100644 index 5d422c5..0000000 --- a/api/src/FinancialHub/FinancialHub.Infra/Repositories/CategoriesRepository.cs +++ /dev/null @@ -1,13 +0,0 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Data.Contexts; - -namespace FinancialHub.Infra.Data.Repositories -{ - public class CategoriesRepository : BaseRepository, ICategoriesRepository - { - public CategoriesRepository(FinancialHubContext context) : base(context) - { - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs b/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs deleted file mode 100644 index a19ae0f..0000000 --- a/api/src/FinancialHub/FinancialHub.Infra/Repositories/TransactionsRepository.cs +++ /dev/null @@ -1,35 +0,0 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Data.Contexts; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.Repositories -{ - public class TransactionsRepository : BaseRepository, ITransactionsRepository - { - public TransactionsRepository(FinancialHubContext context) : base(context) - { - } - - public override async Task CreateAsync(TransactionEntity obj) - { - #warning This is not a good practice, remove this later - if(obj == null) - { - throw new ArgumentNullException(nameof(obj)); - } - - obj.Category = null; - obj.Account = null; - return await base.CreateAsync(obj); - } - - public override async Task UpdateAsync(TransactionEntity obj) - { - obj.Category = null; - obj.Account = null; - return await base.UpdateAsync(obj); - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs b/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs deleted file mode 100644 index 5d6c445..0000000 --- a/api/src/FinancialHub/FinancialHub.Infra/Services/AccountsService.cs +++ /dev/null @@ -1,58 +0,0 @@ -using AutoMapper; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Models; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Services -{ - public class AccountsService : IAccountsService - { - private readonly IMapper mapper; - private readonly IAccountsRepository repository; - - public AccountsService(IMapper mapper,IAccountsRepository repository) - { - this.mapper = mapper; - this.repository = repository; - } - - public async Task CreateAsync(AccountModel account) - { - var entity = mapper.Map(account); - - entity = await this.repository.CreateAsync(entity); - - return mapper.Map(entity); - } - - public async Task DeleteAsync(Guid id) - { - return await this.repository.DeleteAsync(id); - } - - public async Task> GetAllByUserAsync(string userId) - { - var entities = await this.repository.GetAllAsync(); - return mapper.Map>(entities); - } - - public async Task UpdateAsync(Guid id, AccountModel account) - { - var entity = await this.repository.GetByIdAsync(id); - - if(entity == null) - { - throw new NullReferenceException($"Not found account with id {id}"); - } - entity.Id = id; - - entity = await this.repository.UpdateAsync(entity); - - return mapper.Map(entity); - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Services/CategoriesService.cs b/api/src/FinancialHub/FinancialHub.Infra/Services/CategoriesService.cs deleted file mode 100644 index d65fff8..0000000 --- a/api/src/FinancialHub/FinancialHub.Infra/Services/CategoriesService.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using AutoMapper; -using System.Threading.Tasks; -using FinancialHub.Domain.Models; -using System.Collections.Generic; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Interfaces.Repositories; - -namespace FinancialHub.Infra.Services -{ - public class CategoriesService : ICategoriesService - { - private readonly IMapper mapper; - private readonly ICategoriesRepository repository; - - public CategoriesService(IMapper mapper, ICategoriesRepository repository) - { - this.mapper = mapper; - this.repository = repository; - } - - public async Task CreateAsync(CategoryModel category) - { - var entity = mapper.Map(category); - - entity = await this.repository.CreateAsync(entity); - - return mapper.Map(entity); - } - - public async Task DeleteAsync(Guid id) - { - return await this.repository.DeleteAsync(id); - } - - public async Task> GetAllByUserAsync(string userId) - { - var entities = await this.repository.GetAllAsync(); - return mapper.Map>(entities); - } - - public async Task UpdateAsync(Guid id, CategoryModel category) - { - var entity = await this.repository.GetByIdAsync(id); - - if (entity == null) - { - throw new NullReferenceException($"Not found category with id {id}"); - } - entity.Id = id; - - entity = await this.repository.UpdateAsync(entity); - - return mapper.Map(entity); - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.Infra/Services/TransactionsService.cs b/api/src/FinancialHub/FinancialHub.Infra/Services/TransactionsService.cs deleted file mode 100644 index 48224bd..0000000 --- a/api/src/FinancialHub/FinancialHub.Infra/Services/TransactionsService.cs +++ /dev/null @@ -1,64 +0,0 @@ -using AutoMapper; -using FinancialHub.Domain.Entities; -using System; -using System.Threading.Tasks; -using System.Collections.Generic; -using FinancialHub.Domain.Filters; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Queries; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Interfaces.Repositories; - -namespace FinancialHub.Infra.Services -{ - public class TransactionsService : ITransactionsService - { - private readonly IMapper mapper; - private readonly ITransactionsRepository repository; - - public TransactionsService(IMapper mapper, ITransactionsRepository repository)//TODO: custom mapper - { - this.mapper = mapper; - this.repository = repository; - } - - public async Task CreateAsync(TransactionModel category) - { - var entity = mapper.Map(category); - - entity = await this.repository.CreateAsync(entity); - - return mapper.Map(entity); - } - - public async Task DeleteAsync(Guid id) - { - return await this.repository.DeleteAsync(id); - } - - public async Task> GetAllByUserAsync(string userId, TransactionFilter filter) - { - var query = mapper.Map(filter); - //query.UserId = userId; - - var entities = await this.repository.GetAsync(query.Query()); - - return mapper.Map>(entities); - } - - public async Task UpdateAsync(Guid id, TransactionModel category) - { - var entity = await this.repository.GetByIdAsync(id); - - if (entity == null) - { - throw new NullReferenceException($"Not found category with id {id}"); - } - entity.Id = id; - - entity = await this.repository.UpdateAsync(entity); - - return mapper.Map(entity); - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs new file mode 100644 index 0000000..ac5ef5e --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs @@ -0,0 +1,33 @@ +using System.Net.Http; +using NUnit.Framework; +using FinancialHub.IntegrationTests.Setup; + +namespace FinancialHub.IntegrationTests.Base +{ + [TestFixtureSource(typeof(FinancialHubApiFixture))] + public abstract class BaseControllerTests + { + protected readonly FinancialHubApiFixture fixture; + protected HttpClient client => fixture.Client; + + protected readonly string baseEndpoint; + + public BaseControllerTests(FinancialHubApiFixture fixture,string endpoint) + { + this.fixture = fixture; + this.baseEndpoint = endpoint; + } + + [SetUp] + public virtual void SetUp() + { + this.fixture.CreateDatabase(); + } + + [TearDown] + public virtual void TearDown() + { + this.fixture.ClearData(); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs new file mode 100644 index 0000000..e56c5a9 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs @@ -0,0 +1,156 @@ +using System; +using System.Net; +using System.Linq; +using NUnit.Framework; +using System.Threading.Tasks; +using FinancialHub.Domain.Models; +using FinancialHub.IntegrationTests.Base; +using FinancialHub.IntegrationTests.Setup; +using FinancialHub.IntegrationTests.Extensions; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.Domain.Tests.Builders.Entities; + +namespace FinancialHub.IntegrationTests +{ + public class AccountsControllerTests : BaseControllerTests + { + private AccountEntityBuilder dataBuilder; + private AccountModelBuilder builder; + + public AccountsControllerTests(FinancialHubApiFixture fixture) : base(fixture, "/accounts") + { + + } + + public override void SetUp() + { + this.dataBuilder = new AccountEntityBuilder(); + this.builder = new AccountModelBuilder(); + base.SetUp(); + } + + protected static void AssertEqual(AccountModel expected, AccountModel result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.Description, result.Description); + Assert.AreEqual(expected.Currency, result.Currency); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + + protected async Task AssertGetExists(AccountModel expected) + { + var getResponse = await this.client.GetAsync(baseEndpoint); + + var getResult = await getResponse.ReadContentAsync>(); + Assert.AreEqual(1, getResult?.Data.Count); + AssertEqual(expected, getResult!.Data.First()); + } + + [Test] + public async Task GetAll_ReturnAccounts() + { + var data = dataBuilder.Generate(10); + this.fixture.AddData(data.ToArray()); + + var response = await this.client.GetAsync(baseEndpoint); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.AreEqual(data.Count, result?.Data.Count); + } + + [Test] + public async Task Post_ValidAccount_ReturnCreatedAccount() + { + var data = this.builder.Generate(); + + var response = await this.client.PostAsync(baseEndpoint, data); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + AssertEqual(data, result!.Data); + } + + [Test] + public async Task Post_ValidAccount_CreateAccount() + { + var body = this.builder.Generate(); + + await this.client.PostAsync(baseEndpoint, body); + + await this.AssertGetExists(body); + } + + [Test] + public async Task Put_ExistingAccount_ReturnUpdatedAccount() + { + var id = Guid.NewGuid(); + this.fixture.AddData(dataBuilder.WithId(id).Generate()); + + var body = this.builder.WithId(id).Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + Assert.AreEqual(body.Id, result?.Data.Id); + AssertEqual(body,result!.Data); + } + + [Test] + public async Task Put_ExistingAccount_UpdatesAccount() + { + var id = Guid.NewGuid(); + this.fixture.AddData(dataBuilder.WithId(id).Generate()); + + var body = this.builder.WithId(id).Generate(); + await this.client.PutAsync($"{baseEndpoint}/{id}", body); + + await this.AssertGetExists(body); + } + + [Test] + public async Task Put_NonExistingAccount_ReturnNotFoundError() + { + var id = Guid.NewGuid(); + var body = this.builder.WithId(id).Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); + Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); + + var result = await response.ReadContentAsync(); + Assert.AreEqual($"Not found account with id {id}", result!.Message); + } + + [Test] + public async Task Delete_ReturnNoContent() + { + var id = Guid.NewGuid(); + + var data = dataBuilder.WithId(id).Generate(); + this.fixture.AddData(data); + + var response = await this.client.DeleteAsync($"{baseEndpoint}/{id}"); + Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); + } + + [Test] + public async Task Delete_RemovesAccountFromDatabase() + { + var id = Guid.NewGuid(); + + var data = dataBuilder.WithId(id).Generate(); + this.fixture.AddData(data); + + await this.client.DeleteAsync($"{baseEndpoint}/{id}"); + + var getResponse = await this.client.GetAsync(baseEndpoint); + var getResult = await getResponse.ReadContentAsync>(); + Assert.IsEmpty(getResult!.Data); + } + } +} \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs new file mode 100644 index 0000000..bdbe2d8 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs @@ -0,0 +1,156 @@ +using System; +using System.Net; +using System.Linq; +using NUnit.Framework; +using System.Threading.Tasks; +using FinancialHub.Domain.Models; +using FinancialHub.IntegrationTests.Base; +using FinancialHub.IntegrationTests.Setup; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.Domain.Tests.Builders.Entities; +using FinancialHub.IntegrationTests.Extensions; + +namespace FinancialHub.IntegrationTests +{ + public class CategoriesControllerTests : BaseControllerTests + { + private CategoryEntityBuilder dataBuilder; + private CategoryModelBuilder builder; + + + public CategoriesControllerTests(FinancialHubApiFixture fixture) : base(fixture, "/categories") + { + + } + + public override void SetUp() + { + this.dataBuilder = new CategoryEntityBuilder(); + this.builder = new CategoryModelBuilder(); + base.SetUp(); + } + + protected static void AssertEqual(CategoryModel expected, CategoryModel result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.Description, result.Description); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + + protected async Task AssertGetExists(CategoryModel expected) + { + var getResponse = await this.client.GetAsync(baseEndpoint); + + var getResult = await getResponse.ReadContentAsync>(); + Assert.AreEqual(1, getResult?.Data.Count); + AssertEqual(expected, getResult!.Data.First()); + } + + [Test] + public async Task GetAll_ReturnCategories() + { + var data = dataBuilder.Generate(10); + this.fixture.AddData(data.ToArray()); + + var response = await this.client.GetAsync(baseEndpoint); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.AreEqual(data.Count, result?.Data.Count); + } + + [Test] + public async Task Post_ValidCategory_ReturnCreatedCategory() + { + var data = this.builder.Generate(); + + var response = await this.client.PostAsync(baseEndpoint, data); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + AssertEqual(data, result!.Data); + } + + [Test] + public async Task Post_ValidCategory_CreateCategory() + { + var body = this.builder.Generate(); + + await this.client.PostAsync(baseEndpoint, body); + + await this.AssertGetExists(body); + } + + [Test] + public async Task Put_ExistingCategory_ReturnUpdatedCategory() + { + var id = Guid.NewGuid(); + this.fixture.AddData(dataBuilder.WithId(id).Generate()); + + var body = this.builder.WithId(id).Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + Assert.AreEqual(body.Id, result?.Data.Id); + AssertEqual(body,result!.Data); + } + + [Test] + public async Task Put_ExistingCategory_UpdatesCategory() + { + var id = Guid.NewGuid(); + this.fixture.AddData(dataBuilder.WithId(id).Generate()); + + var body = this.builder.WithId(id).Generate(); + await this.client.PutAsync($"{baseEndpoint}/{id}", body); + + await this.AssertGetExists(body); + } + + [Test] + public async Task Put_NonExistingCategory_ReturnNotFoundError() + { + var id = Guid.NewGuid(); + var body = this.builder.WithId(id).Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); + Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); + + var result = await response.ReadContentAsync(); + Assert.AreEqual($"Not found category with id {id}", result!.Message); + } + + [Test] + public async Task Delete_ReturnNoContent() + { + var id = Guid.NewGuid(); + + var data = dataBuilder.WithId(id).Generate(); + this.fixture.AddData(data); + + var response = await this.client.DeleteAsync($"{baseEndpoint}/{id}"); + Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); + } + + [Test] + public async Task Delete_RemovesCategoryFromDatabase() + { + var id = Guid.NewGuid(); + + var data = dataBuilder.WithId(id).Generate(); + this.fixture.AddData(data); + + await this.client.DeleteAsync($"{baseEndpoint}/{id}"); + + var getResponse = await this.client.GetAsync(baseEndpoint); + var getResult = await getResponse.ReadContentAsync>(); + Assert.IsEmpty(getResult!.Data); + } + } +} \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs new file mode 100644 index 0000000..7fb946b --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs @@ -0,0 +1,263 @@ +using System; +using System.Net; +using System.Linq; +using NUnit.Framework; +using System.Threading.Tasks; +using FinancialHub.IntegrationTests.Base; +using FinancialHub.IntegrationTests.Setup; +using FinancialHub.IntegrationTests.Extensions; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.Domain.Tests.Builders.Entities; + +namespace FinancialHub.IntegrationTests +{ + public class TransactionsControllerTests : BaseControllerTests + { + private TransactionEntityBuilder entityBuilder; + private TransactionModelBuilder modelBuilder; + + public TransactionsControllerTests(FinancialHubApiFixture fixture) : base(fixture, "/Transactions") + { + + } + + public override void SetUp() + { + this.entityBuilder = new TransactionEntityBuilder(); + this.modelBuilder = new TransactionModelBuilder(); + base.SetUp(); + } + + protected static void AssertEqual(TransactionModel expected, TransactionModel result) + { + Assert.AreEqual(expected.AccountId, result.AccountId); + Assert.AreEqual(expected.CategoryId, result.CategoryId); + Assert.AreEqual(expected.TargetDate, result.TargetDate); + Assert.AreEqual(expected.FinishDate, result.FinishDate); + Assert.AreEqual(expected.Amount, result.Amount); + Assert.AreEqual(expected.Type, result.Type); + Assert.AreEqual(expected.Description, result.Description); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + + protected async Task AssertGetExists(TransactionModel expected) + { + var getResponse = await this.client.GetAsync(baseEndpoint); + + var getResult = await getResponse.ReadContentAsync>(); + Assert.AreEqual(1, getResult?.Data.Count); + AssertEqual(expected, getResult!.Data.First()); + } + + protected TransactionModel CreateValidTransaction(bool isActive = true) + { + var model = entityBuilder.Generate(); + + this.fixture.AddData(model.Category); + this.fixture.AddData(model.Account); + + var data = entityBuilder + .WithAccountId(model.Account.Id) + .WithCategoryId(model.Category.Id) + .WithActiveStatus(isActive) + .Generate(); + + return new TransactionModel() + { + Id = data.Id, + CategoryId = data.CategoryId, + AccountId = data.AccountId, + Description = data.Description, + FinishDate = data.FinishDate, + TargetDate = data.TargetDate, + Amount = data.Amount, + Status = data.Status, + Type = data.Type, + IsActive = data.IsActive, + }; + } + + protected TransactionModel InsertTransaction(bool isActive = true) + { + var model = entityBuilder.Generate(); + + this.fixture.AddData(model.Category); + this.fixture.AddData(model.Account); + + var data = entityBuilder + .WithAccountId(model.Account.Id) + .WithCategoryId(model.Category.Id) + .WithActiveStatus(isActive) + .Generate(); + + this.fixture.AddData(data); + + return new TransactionModel() + { + Id = data.Id, + CategoryId = data.CategoryId, + AccountId = data.AccountId, + Description = data.Description, + FinishDate = data.FinishDate, + TargetDate = data.TargetDate, + Amount = data.Amount, + Status = data.Status, + Type = data.Type, + IsActive = data.IsActive, + }; + } + + protected TransactionModel[] InsertTransactions(bool isActive = true) + { + var model = entityBuilder.Generate(); + + this.fixture.AddData(model.Category); + this.fixture.AddData(model.Account); + + var data = entityBuilder + .WithAccountId(model.Account.Id) + .WithCategoryId(model.Category.Id) + .WithActiveStatus(isActive) + .Generate(10); + + this.fixture.AddData(data.ToArray()); + + return data.Select( + x => new TransactionModel() + { + Id = x.Id, + CategoryId = x.CategoryId, + AccountId = x.AccountId, + Description = x.Description, + FinishDate = x.FinishDate, + TargetDate = x.TargetDate, + Amount = x.Amount, + Status = x.Status, + Type = x.Type, + IsActive = x.IsActive, + } + ).ToArray(); + } + + [Test] + public async Task GetAll_ReturnActiveTransactions() + { + var data = this.InsertTransactions(); + + var response = await this.client.GetAsync(baseEndpoint); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.AreEqual(data.Length, result?.Data.Count); + } + + [Test] + public async Task GetAll_DoesNotReturnNotActiveTransactions() + { + this.InsertTransactions(false); + + var response = await this.client.GetAsync(baseEndpoint); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.Zero(result!.Data.Count); + } + + [Test] + public async Task Post_ValidTransaction_ReturnCreatedTransaction() + { + var data = this.CreateValidTransaction(); + + var response = await this.client.PostAsync(baseEndpoint, data); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + AssertEqual(data, result!.Data); + } + + [Test] + public async Task Post_ValidTransaction_CreateTransaction() + { + var body = this.CreateValidTransaction(); + + await this.client.PostAsync(baseEndpoint, body); + + await this.AssertGetExists(body); + } + + [Test] + public async Task Put_ExistingTransaction_ReturnUpdatedTransaction() + { + var data = this.InsertTransaction(true); + + var body = this.modelBuilder + .WithAccountId(data.AccountId) + .WithCategoryId(data.CategoryId) + .WithActiveStatus(data.IsActive) + .WithId(data.Id.GetValueOrDefault()) + .Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{data.Id}", body); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + Assert.AreEqual(body.Id, result?.Data.Id); + AssertEqual(body,result!.Data); + } + + [Test] + public async Task Put_ExistingTransaction_UpdatesTransaction() + { + var data = this.InsertTransaction(true); + + var body = this.modelBuilder + .WithAccountId(data.AccountId) + .WithCategoryId(data.CategoryId) + .WithActiveStatus(data.IsActive) + .WithId(data.Id.GetValueOrDefault()) + .Generate(); + await this.client.PutAsync($"{baseEndpoint}/{data.Id}", body); + + await this.AssertGetExists(body); + } + + [Test] + public async Task Put_NonExistingTransaction_ReturnNotFoundError() + { + var body = this.CreateValidTransaction(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{body.Id}", body); + Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); + + var result = await response.ReadContentAsync(); + Assert.AreEqual($"Not found Transaction with id {body.Id}", result!.Message); + } + + [Test] + public async Task Delete_ReturnNoContent() + { + var body = this.InsertTransaction(); + + var response = await this.client.DeleteAsync($"{baseEndpoint}/{body.Id}"); + + Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); + } + + [Test] + public async Task Delete_RemovesTransactionFromDatabase() + { + var body = this.InsertTransaction(); + + await this.client.DeleteAsync($"{baseEndpoint}/{body.Id}"); + + var getResponse = await this.client.GetAsync(baseEndpoint); + var getResult = await getResponse.ReadContentAsync>(); + Assert.IsEmpty(getResult!.Data); + } + } +} \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs new file mode 100644 index 0000000..e9b2594 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs @@ -0,0 +1,25 @@ +using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +namespace FinancialHub.IntegrationTests.Extensions +{ + public static class HttpClientExtensions + { + public static HttpContent CreateContent(T content) + { + return new StringContent(JsonSerializer.Serialize(content), Encoding.UTF8, "application/json"); + } + + public static async Task PostAsync(this HttpClient client, string requestUri, T? content) + { + return await client.PostAsync(requestUri, CreateContent(content)); + } + + public static async Task PutAsync(this HttpClient client, string requestUri, T? content) + { + return await client.PutAsync(requestUri, CreateContent(content)); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs new file mode 100644 index 0000000..a76dd82 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs @@ -0,0 +1,30 @@ +using System; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; + +namespace FinancialHub.IntegrationTests.Extensions +{ + public static class HttpResponseMessageExtensions + { + public static async Task ReadContentAsync(this HttpResponseMessage response) + { + try + { + var stream = await response.Content.ReadAsStreamAsync(); + + return await JsonSerializer.DeserializeAsync(stream, + new JsonSerializerOptions() + { + PropertyNameCaseInsensitive = true + } + ); + } + catch (Exception e) + { + var json = await response.Content.ReadAsStringAsync(); + throw new Exception($"Not able to Read the content:\n{json}",e); + } + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..443f84e --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,27 @@ +using FinancialHub.IntegrationTests.Setup; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using System.Linq; + +namespace FinancialHub.IntegrationTests.Extensions +{ + public static class IServiceCollectionExtensions + { + public static IServiceCollection AddTestDbContext(this IServiceCollection services) + where Context : DbContext + { + var dbContextOptions = services.SingleOrDefault( + d => d.ServiceType == typeof(DbContextOptions) + ); + services.Remove(dbContextOptions!); + + services.AddDbContext(options => + { + options.UseSqlServer(DbConnectionStringManager.ConnectionString); + options.EnableSensitiveDataLogging(true); + options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); + }); + return services; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj b/api/src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj new file mode 100644 index 0000000..5f71212 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + enable + + false + + + + + + + + + + + + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs new file mode 100644 index 0000000..6744ef7 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs @@ -0,0 +1,43 @@ +using System; +using System.IO; + +namespace FinancialHub.IntegrationTests.Setup +{ + internal static class DbConnectionStringManager + { + private const string DockerConnectionString = "Server=localhost;Database=financial_hub;Trusted_Connection=True;"; + private const string LocalDbConnectionString = "Server=(LocalDB)\\MSSQLLocalDB;Database=financial_hub;Trusted_Connection=True;"; + + public static string ConnectionString + { + get + { + if (LocalDbExists()) + { + return LocalDbConnectionString; + } + + return DockerConnectionString; + } + } + private static readonly string sqlServerLocalDbPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), + "Microsoft SQL Server" + ); + + private static bool LocalDbExists() + { + var files = Directory.GetFiles( + sqlServerLocalDbPath, + "SqlLocalDB.exe", + new EnumerationOptions() + { + IgnoreInaccessible = true, + RecurseSubdirectories = true + } + ); + + return files.Length > 0; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs new file mode 100644 index 0000000..137ea12 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs @@ -0,0 +1,76 @@ +using System; +using System.Net.Http; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.DependencyInjection; +using FinancialHub.WebApi; +using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Domain.Entities; +using System.Collections; +using FinancialHub.IntegrationTests.Extensions; + +namespace FinancialHub.IntegrationTests.Setup +{ + public class FinancialHubApiFixture : IEnumerable, IDisposable + { + public HttpClient Client { get; protected set; } + public WebApplicationFactory Api { get; protected set; } + + public FinancialHubApiFixture() + { + this.Api = new WebApplicationFactory() + .WithWebHostBuilder( + builder => + { + builder.ConfigureServices(services => + { + services.AddTestDbContext(); + }); + } + ); + + this.Client = this.Api.CreateClient(); + } + + public void AddData(params T[] data) + where T : BaseEntity + { + using (var scope = this.Api.Server.Services.CreateScope()) + { + var context = scope.ServiceProvider.GetRequiredService(); + context.Set().AddRange(data); + context.SaveChanges(); + } + } + + public void CreateDatabase() + { + using(var scope = this.Api.Services.CreateScope()) + { + //TODO: run migrations + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); + } + } + + public void ClearData() + { + using (var scope = this.Api.Server.Services.CreateScope()) + { + var context = scope.ServiceProvider.GetRequiredService(); + context.Database.EnsureDeleted(); + } + } + + public void Dispose() + { + this.Api.Dispose(); + this.Client.Dispose(); + GC.SuppressFinalize(this); + } + + public IEnumerator GetEnumerator() + { + yield return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj index 25abc01..720a625 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj @@ -17,7 +17,7 @@ - + diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs index eb68365..78413d5 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs @@ -14,7 +14,7 @@ public partial class AccountsServiceTests [TestCase(Description = "Create valid account", Category = "Create")] public async Task CreateAsync_ValidAccountModel_ReturnsAccountModel() { - var model = this.modelGenerator.GenerateAccount(); + var model = this.accountModelBuilder.Generate(); this.repository .Setup(x => x.CreateAsync(It.IsAny())) @@ -43,9 +43,9 @@ public async Task CreateAsync_ValidAccountModel_ReturnsAccountModel() [Test] [TestCase(Description = "Create repository exception", Category = "Create")] - public async Task CreateAsync_RepositoryException_ThrowsException() + public void CreateAsync_RepositoryException_ThrowsException() { - var model = this.modelGenerator.GenerateAccount(); + var model = this.accountModelBuilder.Generate(); var exc = new Exception("mock"); this.repository diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs index 5c3367b..f6c79b9 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs @@ -1,21 +1,24 @@ using AutoMapper; +using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Mappers; using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Domain.Tests.Builders.Entities; +using FinancialHub.Domain.Tests.Builders.Models; using FinancialHub.Services.Mappers; using FinancialHub.Services.Services; using Moq; using NUnit.Framework; using System; +using System.Collections.Generic; namespace FinancialHub.Services.NUnitTests.Services { public partial class AccountsServiceTests { protected Random random; - protected EntityGenerator entityGenerator; - protected ModelGenerator modelGenerator; + protected AccountEntityBuilder accountEntityBuilder; + protected AccountModelBuilder accountModelBuilder; private IAccountsService service; @@ -44,8 +47,12 @@ public void Setup() this.random = new Random(); - this.entityGenerator = new EntityGenerator(random); - this.modelGenerator = new ModelGenerator(random); + this.accountEntityBuilder = new AccountEntityBuilder(); + this.accountModelBuilder = new AccountModelBuilder(); + } + + public ICollection GenerateAccounts(){ + return this.accountEntityBuilder.Generate(random.Next(5,10)); } } } diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs index 1bd5df7..d876894 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs @@ -28,7 +28,7 @@ public async Task DeleteAsync_RepositorySuccess_ReturnsAccountModel() [Test] [TestCase(Description = "Update repository exception", Category = "Delete")] - public async Task DeleteAsync_RepositoryException_ThrowsException() + public void DeleteAsync_RepositoryException_ThrowsException() { var guid = Guid.NewGuid(); var exc = new Exception("mock"); diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs index 9e867f0..ed0b4f1 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs @@ -17,8 +17,8 @@ public partial class AccountsServiceTests [TestCase(Description = "Get by user sucess return",Category = "Get")] public async Task GetByUsersAsync_ValidUser_ReturnsAccounts() { - var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateAccount(),random.Next(10,100)); - + var entitiesMock = this.GenerateAccounts(); + this.repository .Setup(x => x.GetAllAsync()) .ReturnsAsync(entitiesMock.ToArray()) @@ -42,9 +42,10 @@ public async Task GetByUsersAsync_ValidUser_ReturnsAccounts() [Test] [TestCase(Description = "Get by user repository exception", Category = "Get")] - public async Task GetByUsersAsync_RepositoryException_ThrowsException() + public void GetByUsersAsync_RepositoryException_ThrowsException() { - var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateAccount(), random.Next(10, 100)); + var entitiesMock = this.GenerateAccounts(); + var exc = new Exception("mock"); this.repository .Setup(x => x.GetAllAsync()) diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs index d41784f..234e237 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs @@ -14,7 +14,7 @@ public partial class AccountsServiceTests [TestCase(Description = "Update valid account", Category = "Update")] public async Task UpdateAsync_ValidAccountModel_ReturnsAccountModel() { - var model = this.modelGenerator.GenerateAccount(); + var model = this.accountModelBuilder.Generate(); this.repository .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) @@ -52,11 +52,11 @@ public async Task UpdateAsync_ValidAccountModel_ReturnsAccountModel() [TestCase(Description = "Update non existing account", Category = "Update")] public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() { - var model = this.modelGenerator.GenerateAccount(); + var model = this.accountModelBuilder.Generate(); this.repository .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync((AccountEntity)null) + .ReturnsAsync(default(AccountEntity)) .Verifiable(); this.repository @@ -75,9 +75,9 @@ public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() [Test] [TestCase(Description = "Update repository exception", Category = "Update")] - public async Task UpdateAsync_RepositoryException_ThrowsException() + public void UpdateAsync_RepositoryException_ThrowsException() { - var model = this.modelGenerator.GenerateAccount(); + var model = this.accountModelBuilder.Generate(); var exc = new Exception("mock"); this.repository diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs index 0eefe98..6da7689 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs @@ -14,7 +14,7 @@ public partial class CategoriesServiceTests [TestCase(Description = "Create valid Category", Category = "Create")] public async Task CreateAsync_ValidCategoryModel_ReturnsCategoryModel() { - var model = this.modelGenerator.GenerateCategory(); + var model = this.categoryModelBuilder.Generate(); this.repository .Setup(x => x.CreateAsync(It.IsAny())) @@ -43,9 +43,9 @@ public async Task CreateAsync_ValidCategoryModel_ReturnsCategoryModel() [Test] [TestCase(Description = "Create repository exception", Category = "Create")] - public async Task CreateAsync_RepositoryException_ThrowsException() + public void CreateAsync_RepositoryException_ThrowsException() { - var model = this.modelGenerator.GenerateCategory(); + var model = this.categoryModelBuilder.Generate(); var exc = new Exception("mock"); this.repository diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs index d560d1c..b90e4f3 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs @@ -1,21 +1,24 @@ using AutoMapper; +using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Mappers; using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Domain.Tests.Builders.Entities; +using FinancialHub.Domain.Tests.Builders.Models; using FinancialHub.Services.Mappers; using FinancialHub.Services.Services; using Moq; using NUnit.Framework; using System; +using System.Collections.Generic; namespace FinancialHub.Services.NUnitTests.Services { public partial class CategoriesServiceTests { protected Random random; - protected EntityGenerator entityGenerator; - protected ModelGenerator modelGenerator; + protected CategoryEntityBuilder categoryBuilder; + protected CategoryModelBuilder categoryModelBuilder; private ICategoriesService service; @@ -44,8 +47,13 @@ public void Setup() this.random = new Random(); - this.entityGenerator = new EntityGenerator(random); - this.modelGenerator = new ModelGenerator(random); + this.categoryBuilder = new CategoryEntityBuilder(); + this.categoryModelBuilder = new CategoryModelBuilder(); + } + + private ICollection CreateCategories() + { + return this.categoryBuilder.Generate(random.Next(10, 100)); } } } diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs index 8a9ac8d..ef7a1ff 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs @@ -17,7 +17,7 @@ public partial class CategoriesServiceTests [TestCase(Description = "Get by user sucess return",Category = "Get")] public async Task GetByUsersAsync_ValidUser_ReturnsCategories() { - var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateCategory(),random.Next(10,100)); + var entitiesMock = this.CreateCategories(); this.repository .Setup(x => x.GetAllAsync()) @@ -42,9 +42,10 @@ public async Task GetByUsersAsync_ValidUser_ReturnsCategories() [Test] [TestCase(Description = "Get by user repository exception", Category = "Get")] - public async Task GetByUsersAsync_RepositoryException_ThrowsException() + public void GetByUsersAsync_RepositoryException_ThrowsException() { - var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateCategory(), random.Next(10, 100)); + var entitiesMock = this.CreateCategories(); + var exc = new Exception("mock"); this.repository .Setup(x => x.GetAllAsync()) diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs index 605c90c..466ce76 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs @@ -14,7 +14,7 @@ public partial class CategoriesServiceTests [TestCase(Description = "Update valid Category", Category = "Update")] public async Task UpdateAsync_ValidCategoryModel_ReturnsCategoryModel() { - var model = this.modelGenerator.GenerateCategory(); + var model = this.categoryModelBuilder.Generate(); this.repository .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) @@ -52,11 +52,11 @@ public async Task UpdateAsync_ValidCategoryModel_ReturnsCategoryModel() [TestCase(Description = "Update non existing Category", Category = "Update")] public async Task UpdateAsync_NonExistingCategoryId_ReturnsResultError() { - var model = this.modelGenerator.GenerateCategory(); + var model = this.categoryModelBuilder.Generate(); this.repository .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync((CategoryEntity)null) + .ReturnsAsync(default(CategoryEntity)) .Verifiable(); this.repository @@ -75,9 +75,9 @@ public async Task UpdateAsync_NonExistingCategoryId_ReturnsResultError() [Test] [TestCase(Description = "Update repository exception", Category = "Update")] - public async Task UpdateAsync_RepositoryException_ThrowsException() + public void UpdateAsync_RepositoryException_ThrowsException() { - var model = this.modelGenerator.GenerateCategory(); + var model = this.categoryModelBuilder.Generate(); var exc = new Exception("mock"); this.repository diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs index b190145..b2e7238 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs @@ -14,7 +14,7 @@ public partial class TransactionsServiceTests [TestCase(Description = "Create valid Transaction", Category = "Create")] public async Task CreateAsync_ValidTransactionModel_ReturnsTransactionModel() { - var model = this.modelGenerator.GenerateTransaction(); + var model = this.transactionModelBuilder.Generate(); this.repository .Setup(x => x.CreateAsync(It.IsAny())) @@ -43,9 +43,9 @@ public async Task CreateAsync_ValidTransactionModel_ReturnsTransactionModel() [Test] [TestCase(Description = "Create repository exception", Category = "Create")] - public async Task CreateAsync_RepositoryException_ThrowsException() + public void CreateAsync_RepositoryException_ThrowsException() { - var model = this.modelGenerator.GenerateTransaction(); + var model = this.transactionModelBuilder.Generate(); var exc = new Exception("mock"); this.repository diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs index e3e6be6..7f382e1 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs @@ -1,21 +1,24 @@ using AutoMapper; +using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Mappers; using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Domain.Tests.Builders.Entities; +using FinancialHub.Domain.Tests.Builders.Models; using FinancialHub.Services.Mappers; using FinancialHub.Services.Services; using Moq; using NUnit.Framework; using System; +using System.Collections.Generic; namespace FinancialHub.Services.NUnitTests.Services { public partial class TransactionsServiceTests { protected Random random; - protected EntityGenerator entityGenerator; - protected ModelGenerator modelGenerator; + protected TransactionEntityBuilder transactionBuilder; + protected TransactionModelBuilder transactionModelBuilder; private ITransactionsService service; @@ -44,8 +47,13 @@ public void Setup() this.random = new Random(); - this.entityGenerator = new EntityGenerator(random); - this.modelGenerator = new ModelGenerator(random); + this.transactionBuilder = new TransactionEntityBuilder(); + this.transactionModelBuilder = new TransactionModelBuilder(); + } + + public ICollection GenerateTransactions() + { + return this.transactionBuilder.Generate(random.Next(5, 10)); } } } diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs index bb3f960..445a53d 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs @@ -28,7 +28,7 @@ public async Task DeleteAsync_RepositorySuccess_ReturnsTransactionModel() [Test] [TestCase(Description = "Update repository exception", Category = "Delete")] - public async Task DeleteAsync_RepositoryException_ThrowsException() + public void DeleteAsync_RepositoryException_ThrowsException() { var guid = Guid.NewGuid(); var exc = new Exception("mock"); diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs index 10c1305..c9efb90 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs @@ -22,8 +22,8 @@ public partial class TransactionsServiceTests public async Task GetByUsersAsync_ValidUser_ReturnsTransactions() { var filter = new TransactionFilter(); - var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateTransaction(),random.Next(10,100)); - + var entitiesMock = this.GenerateTransactions(); + this.repository .Setup(x => x.GetAsync(It.IsAny>())) .ReturnsAsync(entitiesMock.ToArray()) @@ -53,11 +53,11 @@ public async Task GetByUsersAsync_ValidUser_ReturnsTransactions() [Test] [TestCase(Description = "Get by user repository exception", Category = "Get")] - public async Task GetByUsersAsync_RepositoryException_ThrowsException() + public void GetByUsersAsync_RepositoryException_ThrowsException() { var filter = new TransactionFilter(); - var entitiesMock = Enumerable.Repeat(this.entityGenerator.GenerateTransaction(), random.Next(10, 100)); + var entitiesMock = this.GenerateTransactions(); var exc = new Exception("mock"); this.mapperWrapper diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs index 07e3119..4455ee7 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs @@ -14,7 +14,7 @@ public partial class TransactionsServiceTests [TestCase(Description = "Update valid Transaction", Category = "Update")] public async Task UpdateAsync_ValidTransactionModel_ReturnsTransactionModel() { - var model = this.modelGenerator.GenerateTransaction(); + var model = this.transactionModelBuilder.Generate(); this.repository .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) @@ -52,11 +52,11 @@ public async Task UpdateAsync_ValidTransactionModel_ReturnsTransactionModel() [TestCase(Description = "Update non existing Transaction", Category = "Update")] public async Task UpdateAsync_NonExistingTransactionId_ReturnsResultError() { - var model = this.modelGenerator.GenerateTransaction(); + var model = this.transactionModelBuilder.Generate(); this.repository .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync((TransactionEntity)null) + .ReturnsAsync(default(TransactionEntity)) .Verifiable(); this.repository @@ -75,9 +75,9 @@ public async Task UpdateAsync_NonExistingTransactionId_ReturnsResultError() [Test] [TestCase(Description = "Update repository exception", Category = "Update")] - public async Task UpdateAsync_RepositoryException_ThrowsException() + public void UpdateAsync_RepositoryException_ThrowsException() { - var model = this.modelGenerator.GenerateTransaction(); + var model = this.transactionModelBuilder.Generate(); var exc = new Exception("mock"); this.repository diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs index d714f67..ca4c480 100644 --- a/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs +++ b/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs @@ -53,7 +53,7 @@ public async Task> UpdateAsync(Guid id, Transact if (entity == null) { - return new NotFoundError($"Not found transaction with id {id}"); + return new NotFoundError($"Not found Transaction with id {id}"); } entity = this.mapper.Map(transaction); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs index 2d2cfc5..71888bf 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs @@ -14,9 +14,10 @@ namespace FinancialHub.WebApi.NUnitTests.Controllers public partial class AccountsControllerTests { [Test] - public async Task CreateAccount_Valid_ReturnsOk() + [TestCase(Description = "Create account returns ok", Category = "Create")] + public async Task CreateAccount_ServiceSuccess_ReturnsOk() { - var body = this.modelGenerator.GenerateAccount(); + var body = this.accountModelBuilder.Generate(); var mockResult = new ServiceResult(body); this.mockService @@ -38,10 +39,11 @@ public async Task CreateAccount_Valid_ReturnsOk() } [Test] - public async Task CreateAccount_Invalid_ReturnsBadRequest() + [TestCase(Description = "Create account returns Bad Request", Category = "Create")] + public async Task CreateAccount_ServiceError_ReturnsBadRequest() { var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.modelGenerator.GenerateAccount(); + var body = this.accountModelBuilder.Generate(); var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs index 48170e8..70dcfca 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs @@ -1,15 +1,12 @@ using Moq; -using System; using NUnit.Framework; using FinancialHub.WebApi.Controllers; using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Domain.Tests.Builders.Models; +using System; namespace FinancialHub.WebApi.NUnitTests.Controllers { - //TODO: create default controller test - //TODO: create integration test for controllers - //TODO: start to use : //https://docs.educationsmediagroup.com/unit-testing-csharp/nunit/parameterized-tests //or @@ -17,7 +14,8 @@ namespace FinancialHub.WebApi.NUnitTests.Controllers public partial class AccountsControllerTests { private Random random; - private ModelGenerator modelGenerator; + + private AccountModelBuilder accountModelBuilder; private AccountsController controller; private Mock mockService; @@ -26,7 +24,8 @@ public partial class AccountsControllerTests public void Setup() { this.random = new Random(); - this.modelGenerator = new ModelGenerator(random); + + this.accountModelBuilder = new AccountModelBuilder(); this.mockService = new Mock(); this.controller = new AccountsController(this.mockService.Object); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs index bbd76ee..f47cb07 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs @@ -7,9 +7,10 @@ namespace FinancialHub.WebApi.NUnitTests.Controllers public partial class AccountsControllerTests { [Test] + [TestCase(Description = "Delete Account returns NoContent", Category = "Delete")] public async Task DeleteMyAccounts_ServiceSuccess_ReturnsNoContent() { - var mock = this.modelGenerator.GenerateAccount(); + var mock = this.accountModelBuilder.Generate(); var response = await this.controller.DeleteAccount(mock.Id.GetValueOrDefault()); var result = response as ObjectResult; diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs index 5251def..329b56a 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs @@ -1,25 +1,22 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Moq; -using NUnit.Framework; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; +using NUnit.Framework; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results; namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { - [Test] - public async Task GetMyAccounts_ServiceSuccess_ReturnsOk( - //ServiceResult> mockResult - ) + [TestCase(Description = "Get Accounts returns ok", Category = "Get")] + public async Task GetMyAccounts_ServiceSuccess_ReturnsOk() { var mockResult = new ServiceResult>( - Enumerable.Repeat(modelGenerator.GenerateAccount(), random.Next(0, 10)).ToArray() + accountModelBuilder.Generate(random.Next(0, 10)) ); this.mockService diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs index 93e0950..dfd95c7 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs @@ -1,22 +1,23 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; +using System; +using System.Threading.Tasks; +using NUnit.Framework; +using Moq; +using Microsoft.AspNetCore.Mvc; +using FinancialHub.Domain.Models; using FinancialHub.Domain.Results; using FinancialHub.Domain.Results.Errors; -using Microsoft.AspNetCore.Mvc; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { [Test] + [TestCase(Description = "Update account existing Returns Ok", Category = "Update")] public async Task UpdateAccount_Valid_ReturnsOk() { - var body = this.modelGenerator.GenerateAccount(); + var body = this.accountModelBuilder.Generate(); var guid = body.Id.GetValueOrDefault(); var mockResult = new ServiceResult(body); @@ -39,10 +40,11 @@ public async Task UpdateAccount_Valid_ReturnsOk() } [Test] + [TestCase(Description = "Update Account invalid account returns BadRequest", Category = "Update")] public async Task UpdateAccount_Invalid_ReturnsBadRequest() { var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.modelGenerator.GenerateAccount(); + var body = this.accountModelBuilder.Generate(); var guid = body.Id.GetValueOrDefault(); var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs index 3e2e987..a1ea546 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs @@ -1,22 +1,23 @@ -using FinancialHub.Domain.Models; +using Moq; +using System; +using System.Threading.Tasks; +using NUnit.Framework; +using Microsoft.AspNetCore.Mvc; +using FinancialHub.Domain.Models; using FinancialHub.Domain.Results; using FinancialHub.Domain.Responses.Errors; using FinancialHub.Domain.Responses.Success; using FinancialHub.Domain.Results.Errors; -using Microsoft.AspNetCore.Mvc; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { [Test] + [TestCase(Description = "Create valid category returns Ok", Category = "Create")] public async Task CreateCategory_Valid_ReturnsOk() { - var body = this.modelGenerator.GenerateCategory(); + var body = this.categoryModelBuilder.Generate(); var mockResult = new ServiceResult(body); this.mockService @@ -38,10 +39,11 @@ public async Task CreateCategory_Valid_ReturnsOk() } [Test] + [TestCase(Description = "Create invalid Category returns BadRequest", Category = "Create")] public async Task CreateCategory_Invalid_ReturnsBadRequest() { var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.modelGenerator.GenerateCategory(); + var body = this.categoryModelBuilder.Generate(); var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs index 194769c..1c6b068 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs @@ -3,14 +3,14 @@ using NUnit.Framework; using FinancialHub.WebApi.Controllers; using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Domain.Tests.Builders.Models; namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { private Random random; - private ModelGenerator modelGenerator; + private CategoryModelBuilder categoryModelBuilder; private CategoriesController controller; private Mock mockService; @@ -19,7 +19,7 @@ public partial class CategoriesControllerTests public void Setup() { this.random = new Random(); - this.modelGenerator = new ModelGenerator(random); + this.categoryModelBuilder = new CategoryModelBuilder(); this.mockService = new Mock(); this.controller = new CategoriesController(this.mockService.Object); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs index 5ec35a7..355f8cf 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs @@ -1,15 +1,16 @@ -using Microsoft.AspNetCore.Mvc; -using NUnit.Framework; +using NUnit.Framework; using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { [Test] + [TestCase(Description = "Delete Returns NoContent", Category = "Delete")] public async Task DeleteMyCategories_ServiceSuccess_ReturnsNoContent() { - var mock = this.modelGenerator.GenerateAccount(); + var mock = this.categoryModelBuilder.Generate(); var response = await this.controller.DeleteCategory(mock.Id.GetValueOrDefault()); var result = response as ObjectResult; diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs index c1c30a2..1c94956 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs @@ -1,23 +1,22 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results; -using Microsoft.AspNetCore.Mvc; -using Moq; -using NUnit.Framework; +using NUnit.Framework; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Moq; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results; namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { - [Test] + [TestCase(Description = "Get returns Ok", Category = "Create")] public async Task GetMyCategories_ServiceSuccess_ReturnsOk() { var mockResult = new ServiceResult>( - Enumerable.Repeat(modelGenerator.GenerateCategory(), random.Next(0, 10)).ToArray() + categoryModelBuilder.Generate(random.Next(0, 10)) ); this.mockService diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs index e4a93a2..1f26cec 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs @@ -14,9 +14,10 @@ namespace FinancialHub.WebApi.NUnitTests.Controllers public partial class CategoriesControllerTests { [Test] + [TestCase(Description = "Update valid Category returns Ok", Category = "Update")] public async Task UpdateCategory_Valid_ReturnsOk() { - var body = this.modelGenerator.GenerateCategory(); + var body = this.categoryModelBuilder.Generate(); var guid = body.Id.GetValueOrDefault(); var mockResult = new ServiceResult(body); @@ -39,10 +40,11 @@ public async Task UpdateCategory_Valid_ReturnsOk() } [Test] + [TestCase(Description = "Update invalid Category returns BadRequest", Category = "Update")] public async Task UpdateCategory_Invalid_ReturnsBadRequest() { var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.modelGenerator.GenerateCategory(); + var body = this.categoryModelBuilder.Generate(); var guid = body.Id.GetValueOrDefault(); var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs index 584dfe0..40e1d55 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs @@ -14,9 +14,10 @@ namespace FinancialHub.WebApi.NUnitTests.Controllers public partial class TransactionsControllerTests { [Test] + [TestCase(Description = "Create valid transaction Return Ok", Category = "Create")] public async Task CreateTransaction_Valid_ReturnsOk() { - var body = this.modelGenerator.GenerateTransaction(); + var body = this.transactionModelBuilder.Generate(); var mockResult = new ServiceResult(body); this.mockService @@ -38,10 +39,11 @@ public async Task CreateTransaction_Valid_ReturnsOk() } [Test] + [TestCase(Description = "Create invalid Transaction Return BadRequest", Category = "Create")] public async Task CreateTransaction_Invalid_ReturnsBadRequest() { var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.modelGenerator.GenerateTransaction(); + var body = this.transactionModelBuilder.Generate(); var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs index 6a298c7..c87c134 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs @@ -3,14 +3,14 @@ using NUnit.Framework; using FinancialHub.WebApi.Controllers; using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.NUnitTests.Generators; +using FinancialHub.Domain.Tests.Builders.Models; namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class TransactionsControllerTests { private Random random; - private ModelGenerator modelGenerator; + private TransactionModelBuilder transactionModelBuilder; private TransactionsController controller; private Mock mockService; @@ -19,7 +19,7 @@ public partial class TransactionsControllerTests public void Setup() { this.random = new Random(); - this.modelGenerator = new ModelGenerator(random); + this.transactionModelBuilder = new TransactionModelBuilder(); this.mockService = new Mock(); this.controller = new TransactionsController(this.mockService.Object); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs index fc06ccf..f64deb2 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs @@ -7,9 +7,10 @@ namespace FinancialHub.WebApi.NUnitTests.Controllers public partial class TransactionsControllerTests { [Test] + [TestCase(Description = "Delete Transaction Returns NoContent", Category = "Delete")] public async Task DeleteMyTransactions_ServiceSuccess_ReturnsNoContent() { - var mock = this.modelGenerator.GenerateAccount(); + var mock = this.transactionModelBuilder.Generate(); var response = await this.controller.DeleteTransaction(mock.Id.GetValueOrDefault()); var result = response as ObjectResult; diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs index 22fd043..d639ac6 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs @@ -6,7 +6,6 @@ using Moq; using NUnit.Framework; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; namespace FinancialHub.WebApi.NUnitTests.Controllers @@ -14,11 +13,10 @@ namespace FinancialHub.WebApi.NUnitTests.Controllers public partial class TransactionsControllerTests { [Test] + [TestCase(Description = "Get Transactions return Ok", Category = "Create")] public async Task GetMyTransactions_ServiceSuccess_ReturnsOk() { - var mockResult = new ServiceResult>( - Enumerable.Repeat(modelGenerator.GenerateTransaction(), random.Next(0, 10)).ToArray() - ); + var mockResult = new ServiceResult>(transactionModelBuilder.Generate(random.Next(0, 10))); var filter = new TransactionFilter(); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs index 98269d7..34e7373 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs @@ -14,9 +14,10 @@ namespace FinancialHub.WebApi.NUnitTests.Controllers public partial class TransactionsControllerTests { [Test] + [TestCase(Description = "Update valid Transaction returns Ok", Category = "Update")] public async Task UpdateTransaction_Valid_ReturnsOk() { - var body = this.modelGenerator.GenerateTransaction(); + var body = this.transactionModelBuilder.Generate(); var guid = body.Id.GetValueOrDefault(); var mockResult = new ServiceResult(body); @@ -39,10 +40,11 @@ public async Task UpdateTransaction_Valid_ReturnsOk() } [Test] + [TestCase(Description = "Update Transaction invalid returns BadRequest", Category = "Update")] public async Task UpdateTransaction_Invalid_ReturnsBadRequest() { var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.modelGenerator.GenerateTransaction(); + var body = this.transactionModelBuilder.Generate(); var guid = body.Id.GetValueOrDefault(); var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj index 9955e55..98e77fb 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj @@ -16,7 +16,7 @@ - + diff --git a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json index 8983e0f..7106a01 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json +++ b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json @@ -5,5 +5,9 @@ "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } - } + }, + "ConnectionStrings": { + "default": "Server=localhost;Database=financial_hub;Trusted_Connection=True;" + }, + "AllowedHosts": "*" } diff --git a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json index 7106a01..282da1a 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json +++ b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json @@ -7,7 +7,7 @@ } }, "ConnectionStrings": { - "default": "Server=localhost;Database=financial_hub;Trusted_Connection=True;" + "default": "" }, "AllowedHosts": "*" } diff --git a/api/src/FinancialHub/FinancialHub.sln b/api/src/FinancialHub/FinancialHub.sln index f08f39b..32a657f 100644 --- a/api/src/FinancialHub/FinancialHub.sln +++ b/api/src/FinancialHub/FinancialHub.sln @@ -17,13 +17,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services", "Fi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services.NUnitTests", "FinancialHub.Services.NUnitTests\FinancialHub.Services.NUnitTests.csproj", "{DD50583D-8D5F-42B8-9225-3BCCCDC8B122}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain.NUnitTests", "FinancialHub.Domain.NUnitTests\FinancialHub.Domain.NUnitTests.csproj", "{4AD8BB4F-58F2-4488-BB95-D96CFD78F662}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data", "FinancialHub.Infra.Data\FinancialHub.Infra.Data.csproj", "{19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data.NUnitTests", "FinancialHub.Infra.Data.NUnitTests\FinancialHub.Infra.Data.NUnitTests.csproj", "{5A26CFA8-B077-4C91-BED9-C47339F960A2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.WebApi.NUnitTests", "FinancialHub.WebApi.NUnitTests\FinancialHub.WebApi.NUnitTests.csproj", "{40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi.NUnitTests", "FinancialHub.WebApi.NUnitTests\FinancialHub.WebApi.NUnitTests.csproj", "{40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain.Tests", "FinancialHub.Domain.Tests\FinancialHub.Domain.Tests.csproj", "{050E99E5-5F26-4157-A80A-0493D5E9DE55}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.IntegrationTests", "FinancialHub.IntegrationTests\FinancialHub.IntegrationTests.csproj", "{B6694C5F-1BCF-460D-B9EA-39A49849737A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -47,10 +49,6 @@ Global {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Release|Any CPU.Build.0 = Release|Any CPU - {4AD8BB4F-58F2-4488-BB95-D96CFD78F662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4AD8BB4F-58F2-4488-BB95-D96CFD78F662}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4AD8BB4F-58F2-4488-BB95-D96CFD78F662}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4AD8BB4F-58F2-4488-BB95-D96CFD78F662}.Release|Any CPU.Build.0 = Release|Any CPU {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -63,6 +61,14 @@ Global {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Debug|Any CPU.Build.0 = Debug|Any CPU {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Release|Any CPU.ActiveCfg = Release|Any CPU {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Release|Any CPU.Build.0 = Release|Any CPU + {050E99E5-5F26-4157-A80A-0493D5E9DE55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {050E99E5-5F26-4157-A80A-0493D5E9DE55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {050E99E5-5F26-4157-A80A-0493D5E9DE55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {050E99E5-5F26-4157-A80A-0493D5E9DE55}.Release|Any CPU.Build.0 = Release|Any CPU + {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -71,9 +77,9 @@ Global {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} {DD50583D-8D5F-42B8-9225-3BCCCDC8B122} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} - {4AD8BB4F-58F2-4488-BB95-D96CFD78F662} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3} = {2444FB9D-15D1-4193-BF04-83C4397369DA} {5A26CFA8-B077-4C91-BED9-C47339F960A2} = {2444FB9D-15D1-4193-BF04-83C4397369DA} + {050E99E5-5F26-4157-A80A-0493D5E9DE55} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj deleted file mode 100644 index 04d6db4..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/FinancialHub.Infra.NUnitTests.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - net6.0 - - false - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs deleted file mode 100644 index f96696c..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Generators/EntityGenerator.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Bogus; -using System; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Enums; - -namespace FinancialHub.Infra.Data.NUnitTests.Generators -{ - public class EntityGenerator - { - private readonly Random random; - - public EntityGenerator(Random random) - { - this.random = random; - } - - public AccountEntity GenerateAccount(Guid? id = null) - { - var fake = new Faker(); - - fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) - .RuleFor(x => x.Name, fake => fake.Finance.AccountName()) - .RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code) - .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1,5))) - .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) - .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) - .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); - - return fake.Generate(); - } - - public CategoryEntity GenerateCategory(Guid? id = null) - { - var fake = new Faker(); - - fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) - .RuleFor(x => x.Name, fake => fake.Finance.Random.Word()) - .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) - .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) - .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) - .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); - - return fake.Generate(); - } - - public TransactionEntity GenerateTransaction(Guid? id = null, Guid? accountId = null, Guid? categoryId = null) - { - var account = this.GenerateAccount(accountId); - var category = this.GenerateCategory(categoryId); - - var fake = new Faker(); - - fake.RuleFor(x => x.Id, fake => id ?? fake.Database.Random.Guid()) - .RuleFor(x => x.Amount , fake => fake.Random.Decimal(0,10000)) - .RuleFor(x => x.Description, fake => fake.Lorem.Sentences(random.Next(1, 5))) - .RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()) - .RuleFor(x => x.Type, fake => fake.PickRandom()) - .RuleFor(x => x.Status , fake => fake.PickRandom()) - .RuleFor(x => x.AccountId, fake => account.Id) - .RuleFor(x => x.Account, fake => account) - .RuleFor(x => x.CategoryId, fake => category.Id) - .RuleFor(x => x.Category, fake => category) - .RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset()) - .RuleFor(x => x.FinishDate, fake => fake.Date.RecentOffset()) - .RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now) - .RuleFor(x => x.UpdateTime, fake => DateTimeOffset.Now); - - return fake.Generate(); - } - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs deleted file mode 100644 index 3c42bdb..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using NUnit.Framework; -using FinancialHub.Domain.Entities; -using FinancialHub.Infra.Data.Repositories; -using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Accounts -{ - public class AccountsRepositoryTests : BaseRepositoryTests - { - [SetUp] - protected override void Setup() - { - base.Setup(); - this.repository = new AccountsRepository(this.context); - } - - protected override AccountEntity GenerateObject(Guid? id = null) - { - - return this.generator.GenerateAccount(id); - } - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs deleted file mode 100644 index 9791475..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Linq; -using NUnit.Framework; -using System.Threading.Tasks; -using FinancialHub.Domain.Entities; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests where T : BaseEntity - { - protected virtual void AssertCreated(T createdItem) - { - Assert.IsNotNull(createdItem); - Assert.IsNotNull(createdItem.Id); - Assert.IsNotNull(createdItem.CreationTime); - Assert.IsNotNull(createdItem.UpdateTime); - Assert.IsInstanceOf(createdItem); - - Assert.IsNotEmpty(context.Set().ToList()); - } - - #region Create - [Test] - [TestCase(TestName = "Create new Item", Category = "Create")] - public virtual async Task CreateAsync_ValidItem_AddsOneRow(T item = null) - { - item ??= this.GenerateObject(); - - var createdItem = await this.repository.CreateAsync(item); - - this.AssertCreated(createdItem); - } - - [Test] - [TestCase(TestName = "Create new Item with id", Category = "Create")] - public virtual async Task CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(T item = null) - { - var id = item == null ? Guid.NewGuid() : item.Id.GetValueOrDefault(); - item ??= this.GenerateObject(id); - - var createdItem = await this.repository.CreateAsync(item); - - this.AssertCreated(createdItem); - Assert.AreNotEqual(id,createdItem.Id); - } - - [Test] - [TestCase(TestName = "Create item with existing id", Category = "Create")] - public virtual async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithTheDifferentId(T item = null) - { - var id = item == null ? Guid.NewGuid() : item.Id.GetValueOrDefault(); - - item ??= this.GenerateObject(id); - await this.InsertData(item); - - item ??= this.GenerateObject(id); - - var result = await this.repository.CreateAsync(item); - - this.AssertCreated(result); - Assert.AreEqual(2,context.Set().Count()); - } - #endregion - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs deleted file mode 100644 index 5a87f1b..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using NUnit.Framework; -using FinancialHub.Infra.Data.Contexts; -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using FinancialHub.Domain.Interfaces.Repositories; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.Data.Sqlite; -using FinancialHub.Infra.Data.NUnitTests.Generators; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests where T : BaseEntity - { - protected Random random; - protected EntityGenerator generator; - protected FinancialHubContext context; - - protected IBaseRepository repository; - - protected FinancialHubContext GetContext() - { - var conn = new SqliteConnection("DataSource=:memory:"); - conn.Open(); - - var cfg = new DbContextOptionsBuilder().UseSqlite(conn); - cfg.EnableSensitiveDataLogging(true); - - return new FinancialHubContext( - cfg.Options - ); - } - - [SetUp] - protected virtual void Setup() - { - this.context = this.GetContext(); - context.Database.EnsureCreated(); - - this.random = new Random(); - - this.generator = new EntityGenerator(random); - } - - [TearDown] - protected virtual void TearDown() - { - this.context.Dispose(); - } - - #region Generics - protected virtual async Task> InsertData(ICollection items) - where Y : BaseEntity - { - var list = new List(); - foreach (var item in items) - { - var entity = await this.context.Set().AddAsync(item); - await this.context.SaveChangesAsync(); - list.Add(entity.Entity); - } - await this.context.SaveChangesAsync(); - return list; - } - - protected virtual async Task InsertData(Y item) - where Y : BaseEntity - { - var res = await this.context.Set().AddAsync(item); - item.Id = res.Entity.Id; - await this.context.SaveChangesAsync(); - - return res.Entity; - } - - #endregion - - protected virtual ICollection GenerateData(int min = 1, int max = 100) - { - var count = random.Next(min, max); - var data = new T[count]; - - for (int i = 0; i < count; i++) - { - data[i] = this.GenerateObject(Guid.NewGuid()); - } - - return data; - } - - protected abstract T GenerateObject(Guid? id = null); - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs deleted file mode 100644 index f15f22d..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs +++ /dev/null @@ -1,37 +0,0 @@ -using FinancialHub.Domain.Entities; -using NUnit.Framework; -using System; -using System.Linq; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests where T : BaseEntity - { - #region Delete - [Test] - [TestCase(TestName = "Delete existing Item",Category = "Delete")] - public virtual async Task DeleteAsync_ExistingItem_AffectsOneRow() - { - var items = this.GenerateData(); - await this.InsertData(items); - - var affectedRows = await this.repository.DeleteAsync(items.First().Id.Value); - Assert.AreEqual(1,affectedRows); - Assert.AreEqual(items.Count - 1,context.Set().ToList().Count); - } - - [Test] - [TestCase(TestName = "Delete non existing Item",Category = "Delete")] - public virtual async Task DeleteAsync_NonExistingItem_AffectsNothing() - { - var items = this.GenerateData(); - await this.InsertData(items); - - var affectedRows = await this.repository.DeleteAsync(new Guid()); - Assert.AreEqual(0, affectedRows); - Assert.IsNotEmpty(context.Set().ToList()); - } - #endregion - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs deleted file mode 100644 index c580c4e..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Linq; -using NUnit.Framework; -using System.Threading.Tasks; -using System.Collections.Generic; -using FinancialHub.Domain.Entities; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests where T : BaseEntity - { - #region Get All - [Test] - [TestCase(TestName = "Get All Items without data",Category = "Get")] - public virtual async Task GetAllAsync_NoData_ReturnsEmpty() - { - var list = await this.repository.GetAllAsync(); - - Assert.IsEmpty(list); - Assert.IsInstanceOf>(list); - } - - [Test] - [TestCase(TestName = "Get All Items with data", Category = "Get")] - public virtual async Task GetAllAsync_Data_ReturnsItems() - { - var items = this.GenerateData(); - items = await this.InsertData(items); - - var list = await this.repository.GetAllAsync(); - - Assert.IsNotEmpty(list); - Assert.AreEqual(items,list); - Assert.IsInstanceOf>(list); - } - #endregion - - #region Get - [Test] - [TestCase(TestName = "Get Items with no filter", Category = "Get")] - public virtual async Task GetAsync_NoFilter_ReturnsAllItems() - { - var items = this.GenerateData(); - items = await this.InsertData(items); - - var list = await this.repository.GetAsync((x) => true); - - Assert.IsNotEmpty(list); - Assert.AreEqual(items, list); - Assert.IsInstanceOf>(list); - } - - [Test] - [TestCase(TestName = "Get Items not setting filter", Category = "Get")] - public virtual async Task GetAsync_NullFilter_ThrowsArgumentNullException() - { - var items = this.GenerateData(); - items = await this.InsertData(items); - - Assert.ThrowsAsync(typeof(ArgumentNullException), async () => await this.repository.GetAsync(null)); - } - - [Test] - [TestCase(TestName = "Get Items filtering", Category = "Get")] - public virtual async Task GetAsync_Filter_ReturnsFilteredItems() - { - var items = this.GenerateData(10,100); - items = await this.InsertData(items); - - var id = items.First().Id; - Func filter = (x) => x.Id == id; - var expectedResult = items.Where(filter); - - var list = await this.repository.GetAsync(filter); - - Assert.IsNotEmpty(list); - Assert.AreEqual(expectedResult, list); - Assert.IsInstanceOf>(list); - } - - [Test] - [TestCase(TestName = "Get Items with wrong filter", Category = "Get")] - public virtual async Task GetAsync_WrongFilter_ReturnsEmpty() - { - var items = this.GenerateData(10, 100); - items = await this.InsertData(items); - - Func filter = (x) => x.Id == new Guid(); - - var list = await this.repository.GetAsync(filter); - - Assert.IsEmpty(list); - Assert.IsInstanceOf>(list); - } - #endregion - - #region Get By Id - [Test] - [TestCase(TestName = "Get By Id with empty id", Category = "Get")] - public virtual async Task GetByIdAsync_EmptyId_ReturnsNull() - { - var items = this.GenerateData(); - items = await this.InsertData(items); - - var item = await this.repository.GetByIdAsync(Guid.Empty); - - Assert.IsNull(item); - } - - [Test] - [TestCase(TestName = "Get By Id with existing id", Category = "Get")] - public virtual async Task GetByIdAsync_ExistingId_ReturnsItem() - { - var items = this.GenerateData(1); - items = await this.InsertData(items); - - var id = items.First().Id; - - var item = await this.repository.GetByIdAsync(id.Value); - - Assert.IsNotNull(item); - Assert.AreEqual(id,item.Id); - Assert.IsInstanceOf(item); - } - - [Test] - [TestCase(TestName = "Get By Id with non-existing id", Category = "Get")] - public virtual async Task GetByIdAsync_NonExistingId_ReturnsNull() - { - var items = this.GenerateData(); - items = await this.InsertData(items); - - var item = await this.repository.GetByIdAsync(new Guid()); - - Assert.IsNull(item); - } - #endregion - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs deleted file mode 100644 index 7cce1a0..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs +++ /dev/null @@ -1,42 +0,0 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests where T : BaseEntity - { - #region Update - [Test] - [TestCase(TestName = "Update existing Item", Category = "Update")] - public virtual async Task UpdateAsync_ExistingItem_UpdatesItem() - { - var item = this.GenerateObject(); - await this.InsertData(new T[1] { item }); - - var oldCreationTime = item.UpdateTime.GetValueOrDefault(); - - var updatedItem = await this.repository.UpdateAsync(item); - - Assert.IsNotNull(updatedItem); - Assert.IsNotNull(updatedItem.Id); - Assert.IsNotNull(updatedItem.CreationTime); - Assert.IsNotNull(updatedItem.UpdateTime); - Assert.AreNotEqual(oldCreationTime,updatedItem.UpdateTime); - Assert.IsInstanceOf(updatedItem); - } - - [Test] - [TestCase(TestName = "Update non existing Item", Category = "Update")] - public virtual async Task UpdateAsync_NonExistingItem_ThrowsDbUpdateConcurrencyException() - { - var id = Guid.NewGuid(); - var item = this.GenerateObject(id); - - Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(item)); - } - #endregion - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs deleted file mode 100644 index a33c90b..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using FinancialHub.Domain.Entities; -using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; -using FinancialHub.Infra.Data.Repositories; -using NUnit.Framework; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Categories -{ - public class CategoriesRepositoryTests : BaseRepositoryTests - { - [SetUp] - protected override void Setup() - { - base.Setup(); - this.repository = new CategoriesRepository(this.context); - } - - protected override CategoryEntity GenerateObject(Guid? id = null) - { - return this.generator.GenerateCategory(id); - } - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs deleted file mode 100644 index fbd89da..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs +++ /dev/null @@ -1,186 +0,0 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using NUnit.Framework; -using System; -using System.Linq; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Transactions -{ - public partial class TransactionsRepositoryTests - { - protected override void AssertCreated(TransactionEntity createdItem) - { - base.AssertCreated(createdItem); - - Assert.IsNotNull(createdItem.Account); - Assert.IsNotNull(createdItem.Category); - Assert.AreEqual(createdItem.AccountId, createdItem.Account.Id); - Assert.AreEqual(createdItem.CategoryId, createdItem.Category.Id); - } - - [Test] - [TestCase(TestName = "Create new Transaction with valid Category and Account", Category = "Create")] - public override async Task CreateAsync_ValidItem_AddsOneRow(TransactionEntity item = null) - { - var entity = this.GenerateObject(); - - entity.Category = await this.InsertData(entity.Category); - entity.Account = await this.InsertData(entity.Account); - - await base.CreateAsync_ValidItem_AddsOneRow(entity); - } - - [Test] - [TestCase(TestName = "Create new Item with id", Category = "Create")] - public async override Task CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(TransactionEntity item = null) - { - var entity = this.GenerateObject(); - - var generatedAccount = this.GenerateAccount(entity.AccountId); - var generatedCategory = this.GenerateCategory(entity.CategoryId); - - await this.InsertData(generatedAccount); - await this.InsertData(generatedCategory); - - await base.CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(entity); - } - - [Test] - [TestCase(TestName = "Create item with existing id", Category = "Create")] - public override async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithTheDifferentId(TransactionEntity item = null) - { - var id = Guid.NewGuid(); - item = this.GenerateObject(id); - - //INSERTS ACCOUNT AND CATEGORY - var generatedAccount = this.GenerateAccount(item.AccountId); - var generatedCategory = this.GenerateCategory(item.CategoryId); - - await this.InsertData(generatedAccount); - await this.InsertData(generatedCategory); - - item.Category = null; - item.Account = null; - item = await this.InsertData(item); - - var newItem = this.GenerateObject(id); - newItem.CategoryId = generatedCategory.Id.GetValueOrDefault(); - newItem.AccountId = generatedAccount.Id.GetValueOrDefault(); - - var result = await this.repository.CreateAsync(newItem); - - Assert.AreNotEqual(item.Id,newItem.Id); - this.AssertCreated(result); - Assert.AreEqual(2, context.Set().Count()); - } - - [Test] - [TestCase(TestName = "Create new Transaction without Updates/Creates Account or Category", Category = "Create")] - public async Task CreateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() - { - #warning this test is too complex - - /***** ARRANGE *****/ - var entity = this.GenerateObject(); - - //INSERTS ACCOUNT AND CATEGORY - var oldAccount = this.GenerateAccount(entity.AccountId); - var oldCategory = this.GenerateCategory(entity.CategoryId); - - await this.InsertData(oldAccount); - await this.InsertData(oldCategory); - - //CHANGES TRANSACTION'S CATEGORY AND ACCOUNT - entity.Account.Name = Guid.NewGuid().ToString(); - entity.Category.Name = Guid.NewGuid().ToString(); - - /***** ACT *****/ - - var result = await this.repository.CreateAsync(entity); - - /***** ASSERT *****/ - - this.AssertCreated(result); - - //SHOULD NOT CREATE ACCOUNTS OR CATEGORIES - Assert.AreEqual(1,this.context.Accounts.Count()); - Assert.AreEqual(1,this.context.Categories.Count()); - - var account = this.context.Accounts.FirstOrDefault(x => x.Id == entity.AccountId); - var category = this.context.Categories.FirstOrDefault(x => x.Id == entity.CategoryId); - - //SHOULD NOT UPDATE DATABASE - Assert.AreEqual(oldAccount, account); - Assert.AreEqual(oldCategory, category); - - //SHOULD NOT RETURN THE WRONG ITEM - Assert.AreEqual(oldAccount, result.Account); - Assert.AreEqual(oldCategory, result.Category); - } - - [Test] - [TestCase(TestName = "Create new Transaction with invalid Account", Category = "Create")] - public async Task CreateAsync_InvalidAccountId_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - - await this.InsertData(this.GenerateAccount()); - - entity.Category = await this.InsertData(entity.Category); - entity.CategoryId = entity.Category.Id.GetValueOrDefault(); - - Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); - - Assert.IsEmpty(this.context.Transactions); - Assert.AreEqual(1, this.context.Accounts.Count()); - Assert.AreEqual(1, this.context.Categories.Count()); - } - - [Test] - [TestCase(TestName = "Create new Transaction with invalid Category", Category = "Create")] - public async Task CreateAsync_InvalidCategoryId_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - - await this.InsertData(entity.Account); - await this.InsertData(this.GenerateCategory()); - - Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); - - Assert.IsEmpty(this.context.Transactions); - Assert.AreEqual(1, this.context.Accounts.Count()); - Assert.AreEqual(1, this.context.Categories.Count()); - } - - [Test] - [TestCase(TestName = "Create new Transaction with no Account", Category = "Create")] - public async Task CreateAsync_NoAccount_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - - await this.InsertData(entity.Category); - - entity.Account = null; - - Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); - - Assert.IsEmpty(this.context.Transactions.ToList()); - } - - [Test] - [TestCase(TestName = "Create new Transaction with no Category", Category = "Create")] - public async Task CreateAsync_NoCategory_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - - await this.InsertData(entity.Account); - - entity.Category = null; - - Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); - - Assert.IsEmpty(this.context.Transactions.ToList()); - } - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs deleted file mode 100644 index 9b1a604..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; -using FinancialHub.Infra.Data.Repositories; -using NUnit.Framework; -using System; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Transactions -{ - public partial class TransactionsRepositoryTests : BaseRepositoryTests - { - [SetUp] - protected override void Setup() - { - base.Setup(); - this.repository = new TransactionsRepository(this.context); - } - - protected override TransactionEntity GenerateObject(Guid? id = null) - { - return this.generator.GenerateTransaction(id); - } - - protected TransactionEntity GenerateTransaction(Guid? id = null,Guid? accountId = null, Guid? categoryId = null) - { - return this.generator.GenerateTransaction(id,accountId,categoryId); - } - - protected CategoryEntity GenerateCategory(Guid? id = null) - { - return this.generator.GenerateCategory(id); - } - - protected AccountEntity GenerateAccount(Guid? id = null) - { - return this.generator.GenerateAccount(id); - } - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs deleted file mode 100644 index 56ab497..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs +++ /dev/null @@ -1,27 +0,0 @@ -using NUnit.Framework; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Transactions -{ - public partial class TransactionsRepositoryTests - { - [Test] - [TestCase(TestName = "Delete a Transaction without delete Category or Account", Category = "Delete")] - public async Task DeleteAsync_ValidItemWithNestChild_DoesNotDeleteNestChild() - { - var entity = this.GenerateObject(); - - await this.InsertData(entity.Account); - await this.InsertData(entity.Category); - await this.InsertData(entity); - - var result = await this.repository.DeleteAsync(entity.Id.Value); - - Assert.AreEqual(1,result); - - Assert.IsEmpty(this.context.Transactions.Local); - Assert.AreEqual(1, this.context.Accounts.Local.Count); - Assert.AreEqual(1, this.context.Categories.Local.Count); - } - } -} diff --git a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs deleted file mode 100644 index 0e2f8e4..0000000 --- a/api/src/FinancialHub/MyFinancialHub.Infra.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs +++ /dev/null @@ -1,116 +0,0 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using NUnit.Framework; -using System; -using System.Linq; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Transactions -{ - public partial class TransactionsRepositoryTests - { - protected async Task InsertTransaction(TransactionEntity entity) - { - await this.InsertData(entity.Account); - await this.InsertData(entity.Category); - await this.InsertData(entity); - - context.Entry(entity).State = EntityState.Detached; - } - - [Test] - [TestCase(TestName = "Update Transaction but no Accounts or Category", Category = "Update")] - public async Task UpdateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() - { - var entity = this.GenerateObject(); - await this.InsertTransaction(entity); - - var changedEntity = this.GenerateTransaction(entity.Id, entity.AccountId, entity.CategoryId); - - var result = await this.repository.UpdateAsync(changedEntity); - - this.AssertCreated(result); - - //SHOULD NOT CREATE - Assert.AreEqual(1, this.context.Accounts.Local.Count); - Assert.AreEqual(1, this.context.Categories.Local.Count); - - var account = this.context.Accounts.FirstOrDefault(x => x.Id == changedEntity.AccountId); - var category = this.context.Categories.FirstOrDefault(x => x.Id == changedEntity.CategoryId); - - //SHOULD NOT UPDATE DATABASE - Assert.AreEqual(account, result.Account); - Assert.AreEqual(category, result.Category); - } - - [Test] - [TestCase(TestName = "Update Transaction changing Account", Category = "Update")] - public async Task UpdateAsync_ChangeAccountId_ChangesAccount() - { - var entity = this.GenerateObject(); - await this.InsertTransaction(entity); - - var newAccount = this.GenerateAccount(); - await this.InsertData(newAccount); - - entity.AccountId = (Guid)newAccount.Id; - - var result = await this.repository.CreateAsync(entity); - - this.AssertCreated(result); - - Assert.AreEqual(newAccount.Id, result.AccountId); - Assert.AreEqual(newAccount, result.Account); - } - - [Test] - [TestCase(TestName = "Update Transaction changing Category", Category = "Update")] - public async Task UpdateAsync_ChangeCategoryId_ChangesCategory() - { - var entity = this.GenerateObject(); - await this.InsertTransaction(entity); - - var newCategory = this.GenerateCategory(); - await this.InsertData(newCategory); - - entity.CategoryId = (Guid)newCategory.Id; - - var result = await this.repository.CreateAsync(entity); - - this.AssertCreated(result); - - Assert.AreEqual(newCategory.Id, result.CategoryId); - Assert.AreEqual(newCategory, result.Category); - } - - [Test] - [TestCase(TestName = "Update Transaction with invalid Account", Category = "Update")] - public async Task UpdateAsync_InvalidAccountId_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - var oldCategoryId = entity.Category.Id; - - await this.InsertTransaction(entity); - - var newCategory = this.GenerateCategory(); - entity.CategoryId = (Guid)newCategory.Id; - - Assert.ThrowsAsync( async () =>await this.repository.UpdateAsync(entity)); - } - - [Test] - [TestCase(TestName = "Update Transaction with invalid Category", Category = "Update")] - public async Task UpdateAsync_InvalidCategoryId_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - var newCategory = this.GenerateCategory(); - - await this.InsertTransaction(entity); - - entity.CategoryId = (Guid)newCategory.Id; - entity.Category = newCategory; - - Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(entity)); - } - } -} From 72837a6408642e3a3b375a7fc18e370eef41da24 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Fri, 22 Apr 2022 18:07:07 -0300 Subject: [PATCH 08/30] Release v0.2.4 * Add : database migrations * Add : Database Dockerfile & DockerCompose * Add : SonarCloud Code Analysis --- .github/workflows/api_basic_flow.yml | 50 +++++ .github/workflows/sonarcloud.yml | 74 +++++++ api/src/FinancialHub/Dockerfile | 8 + .../Entities/AccountEntity.cs | 6 +- .../Entities/CategoryEntity.cs | 4 +- .../Entities/TransactionEntity.cs | 4 +- .../FinancialHub.Infra.Migrations.csproj | 23 +++ .../20220407152032_v0.2.4.Designer.cs | 189 ++++++++++++++++++ .../Migrations/20220407152032_v0.2.4.cs | 108 ++++++++++ .../FinancialHubContextModelSnapshot.cs | 187 +++++++++++++++++ .../Setup/DbConnectionStringManager.cs | 11 +- .../FinancialHub.WebApi.csproj | 1 + .../FinancialHub.WebApi/Startup.cs | 9 +- .../appsettings.Development.json | 2 +- api/src/FinancialHub/FinancialHub.sln | 17 +- api/src/FinancialHub/docker-compose.yml | 12 ++ 16 files changed, 687 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/api_basic_flow.yml create mode 100644 .github/workflows/sonarcloud.yml create mode 100644 api/src/FinancialHub/Dockerfile create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs create mode 100644 api/src/FinancialHub/docker-compose.yml diff --git a/.github/workflows/api_basic_flow.yml b/.github/workflows/api_basic_flow.yml new file mode 100644 index 0000000..59c65f0 --- /dev/null +++ b/.github/workflows/api_basic_flow.yml @@ -0,0 +1,50 @@ +name: "API Build & Tests" + +on: + push: + branches: + - 'main' + paths: + - 'api/src/FinancialHub/*' + - 'api/src/FinancialHub/**' + pull_request: + branches: + - 'main' + - 'release/**' + paths: + - 'api/src/FinancialHub/*' + - 'api/src/FinancialHub/**' + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + services: + sql-database: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + SA_PASSWORD: "P@ssw0rd!" + ACCEPT_EULA: "Y" + ports: + - 1450:1433 + + steps: + - uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Restore dependencies + run: dotnet restore + working-directory: './api/src/FinancialHub/' + + - name: Build + run: dotnet build --no-restore + working-directory: './api/src/FinancialHub/' + + - name: Test + run: dotnet test --no-build --verbosity normal + working-directory: './api/src/FinancialHub/' diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..77062ec --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,74 @@ +name: SonarCloud analysis + +on: + push: + branches: + - 'main' + paths: + - 'api/src/FinancialHub/*' + - 'api/src/FinancialHub/**' + pull_request: + branches: + - 'main' + - 'release/**' + paths: + - 'api/src/FinancialHub/*' + - 'api/src/FinancialHub/**' + +permissions: + pull-requests: read + +jobs: + code_analysis: + name: Code Analysis + runs-on: windows-latest + defaults: + run: + working-directory: ./api/src/FinancialHub/ + steps: + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache SonarCloud scanner + id: cache-sonar-scanner + uses: actions/cache@v1 + with: + path: .\.sonar\scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + + - name: Install SonarCloud scanner + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' + shell: powershell + run: | + New-Item -Path .\.sonar\scanner -ItemType Directory + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + shell: powershell + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"Chingling152_my-financial-hub" /o:"chingling-152" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + dotnet build + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" diff --git a/api/src/FinancialHub/Dockerfile b/api/src/FinancialHub/Dockerfile new file mode 100644 index 0000000..fe64382 --- /dev/null +++ b/api/src/FinancialHub/Dockerfile @@ -0,0 +1,8 @@ +# database +FROM mcr.microsoft.com/mssql/server:2019-latest + +ENV SA_PASSWORD=P@ssw0rd! +ENV ACCEPT_EULA=Y + +EXPOSE 1450:1433 +VOLUME ../database:/var/opt/mssql/data diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs index a3040ec..e93ef4c 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs @@ -6,11 +6,11 @@ namespace FinancialHub.Domain.Entities [Table("accounts")] public class AccountEntity : BaseEntity { - [Column("name")] + [Column("name",TypeName = "varchar(200)")] public string Name { get; set; } - [Column("description")] + [Column("description", TypeName = "varchar(500)")] public string Description { get; set; } - [Column("currency")] + [Column("currency", TypeName = "varchar(50)")] public string Currency { get; set; } [Column("active")] public bool IsActive { get; set; } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs index 94218ca..9a62ac0 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs @@ -6,9 +6,9 @@ namespace FinancialHub.Domain.Entities [Table("categories")] public class CategoryEntity : BaseEntity { - [Column("name")] + [Column("name", TypeName = "varchar(200)")] public string Name { get; set; } - [Column("description")] + [Column("description", TypeName = "varchar(500)")] public string Description { get; set; } [Column("active")] public bool IsActive { get; set; } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs index f612ad8..0ac7f5f 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs @@ -7,10 +7,10 @@ namespace FinancialHub.Domain.Entities [Table("transactions")] public class TransactionEntity : BaseEntity { - [Column("description")] + [Column("description", TypeName = "varchar(500)")] public string Description { get; set; } - [Column("amount")] + [Column("amount",TypeName = "money")] public decimal Amount { get; set; } [Column("target_date")] diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj b/api/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj new file mode 100644 index 0000000..a1bcbd7 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs new file mode 100644 index 0000000..cf7c9cd --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs @@ -0,0 +1,189 @@ +// +using System; +using FinancialHub.Infra.Data.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FinancialHub.Infra.Migrations.Migrations +{ + [DbContext(typeof(FinancialHubContext))] + [Migration("20220407152032_v0.2.4")] + partial class v024 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Currency") + .HasColumnType("varchar(50)") + .HasColumnName("currency"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("accounts"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("categories"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("AccountId") + .HasColumnType("uniqueidentifier") + .HasColumnName("account_id"); + + b.Property("Amount") + .HasColumnType("money") + .HasColumnName("amount"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier") + .HasColumnName("category_id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("FinishDate") + .HasColumnType("datetimeoffset") + .HasColumnName("finish_date"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Status") + .HasColumnType("int") + .HasColumnName("status"); + + b.Property("TargetDate") + .HasColumnType("datetimeoffset") + .HasColumnName("target_date"); + + b.Property("Type") + .HasColumnType("int") + .HasColumnName("type"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") + .WithMany("Transactions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") + .WithMany("Transactions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs new file mode 100644 index 0000000..cd41f6a --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs @@ -0,0 +1,108 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FinancialHub.Infra.Migrations.Migrations +{ + public partial class v024 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "accounts", + columns: table => new + { + id = table.Column(type: "uniqueidentifier", nullable: false), + name = table.Column(type: "varchar(200)", nullable: true), + description = table.Column(type: "varchar(500)", nullable: true), + currency = table.Column(type: "varchar(50)", nullable: true), + active = table.Column(type: "bit", nullable: false), + creation_time = table.Column(type: "datetimeoffset", nullable: true), + update_time = table.Column(type: "datetimeoffset", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_accounts", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "categories", + columns: table => new + { + id = table.Column(type: "uniqueidentifier", nullable: false), + name = table.Column(type: "varchar(200)", nullable: true), + description = table.Column(type: "varchar(500)", nullable: true), + active = table.Column(type: "bit", nullable: false), + creation_time = table.Column(type: "datetimeoffset", nullable: true), + update_time = table.Column(type: "datetimeoffset", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_categories", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "transactions", + columns: table => new + { + id = table.Column(type: "uniqueidentifier", nullable: false), + description = table.Column(type: "varchar(500)", nullable: true), + amount = table.Column(type: "money", nullable: false), + target_date = table.Column(type: "datetimeoffset", nullable: false), + finish_date = table.Column(type: "datetimeoffset", nullable: false), + account_id = table.Column(type: "uniqueidentifier", nullable: false), + category_id = table.Column(type: "uniqueidentifier", nullable: false), + active = table.Column(type: "bit", nullable: false), + status = table.Column(type: "int", nullable: false), + type = table.Column(type: "int", nullable: false), + creation_time = table.Column(type: "datetimeoffset", nullable: true), + update_time = table.Column(type: "datetimeoffset", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_transactions", x => x.id); + table.ForeignKey( + name: "FK_transactions_accounts_account_id", + column: x => x.account_id, + principalTable: "accounts", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_transactions_categories_category_id", + column: x => x.category_id, + principalTable: "categories", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_transactions_account_id", + table: "transactions", + column: "account_id"); + + migrationBuilder.CreateIndex( + name: "IX_transactions_category_id", + table: "transactions", + column: "category_id"); + + migrationBuilder.CreateIndex( + name: "IX_transactions_id", + table: "transactions", + column: "id", + unique: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "transactions"); + + migrationBuilder.DropTable( + name: "accounts"); + + migrationBuilder.DropTable( + name: "categories"); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs new file mode 100644 index 0000000..19a736c --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs @@ -0,0 +1,187 @@ +// +using System; +using FinancialHub.Infra.Data.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FinancialHub.Infra.Migrations.Migrations +{ + [DbContext(typeof(FinancialHubContext))] + partial class FinancialHubContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Currency") + .HasColumnType("varchar(50)") + .HasColumnName("currency"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("accounts"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("categories"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("AccountId") + .HasColumnType("uniqueidentifier") + .HasColumnName("account_id"); + + b.Property("Amount") + .HasColumnType("money") + .HasColumnName("amount"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier") + .HasColumnName("category_id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("FinishDate") + .HasColumnType("datetimeoffset") + .HasColumnName("finish_date"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Status") + .HasColumnType("int") + .HasColumnName("status"); + + b.Property("TargetDate") + .HasColumnType("datetimeoffset") + .HasColumnName("target_date"); + + b.Property("Type") + .HasColumnType("int") + .HasColumnName("type"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") + .WithMany("Transactions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") + .WithMany("Transactions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs index 6744ef7..c742f69 100644 --- a/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs @@ -1,18 +1,19 @@ using System; using System.IO; +using System.Runtime.InteropServices; namespace FinancialHub.IntegrationTests.Setup { internal static class DbConnectionStringManager { - private const string DockerConnectionString = "Server=localhost;Database=financial_hub;Trusted_Connection=True;"; + private const string DockerConnectionString = "Server=localhost,1450;Database=financial_hub;user=sa;pwd=P@ssw0rd!;"; private const string LocalDbConnectionString = "Server=(LocalDB)\\MSSQLLocalDB;Database=financial_hub;Trusted_Connection=True;"; public static string ConnectionString { get - { - if (LocalDbExists()) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && LocalDbExists()) { return LocalDbConnectionString; } @@ -21,8 +22,8 @@ public static string ConnectionString } } private static readonly string sqlServerLocalDbPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), - "Microsoft SQL Server" + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), + "Microsoft SQL Server" ); private static bool LocalDbExists() diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj index 8a64540..9298059 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -31,6 +31,7 @@ + diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs index bce2b89..bfa6b13 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs @@ -19,12 +19,16 @@ public Startup(IConfiguration configuration) public IConfiguration Configuration { get; } - // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext( provider =>{ - provider.UseSqlServer(Configuration.GetConnectionString("default")); + provider.UseSqlServer( + Configuration.GetConnectionString("default"), + x => x + .MigrationsAssembly("FinancialHub.Infra.Migrations") + .MigrationsHistoryTable("migrations") + ); } ); @@ -43,7 +47,6 @@ public void ConfigureServices(IServiceCollection services) services.AddMvc().AddNewtonsoftJson(); } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) diff --git a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json index 7106a01..9398fef 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json +++ b/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json @@ -7,7 +7,7 @@ } }, "ConnectionStrings": { - "default": "Server=localhost;Database=financial_hub;Trusted_Connection=True;" + "default": "Server=localhost,1450;Database=financial_hub;user=sa;pwd=P@ssw0rd!;" }, "AllowedHosts": "*" } diff --git a/api/src/FinancialHub/FinancialHub.sln b/api/src/FinancialHub/FinancialHub.sln index 32a657f..5dc98ae 100644 --- a/api/src/FinancialHub/FinancialHub.sln +++ b/api/src/FinancialHub/FinancialHub.sln @@ -27,6 +27,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain.Tests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.IntegrationTests", "FinancialHub.IntegrationTests\FinancialHub.IntegrationTests.csproj", "{B6694C5F-1BCF-460D-B9EA-39A49849737A}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Migrations", "FinancialHub.Infra.Migrations\FinancialHub.Infra.Migrations.csproj", "{7ED57B2C-520B-4A25-B3C1-268EEA48CADB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{8AFE509C-0DD0-4C85-8BEA-24FB599293D7}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Migrations", "Migrations", "{EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -69,6 +75,10 @@ Global {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Release|Any CPU.Build.0 = Release|Any CPU + {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -77,9 +87,12 @@ Global {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} {DD50583D-8D5F-42B8-9225-3BCCCDC8B122} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} - {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3} = {2444FB9D-15D1-4193-BF04-83C4397369DA} - {5A26CFA8-B077-4C91-BED9-C47339F960A2} = {2444FB9D-15D1-4193-BF04-83C4397369DA} + {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} + {5A26CFA8-B077-4C91-BED9-C47339F960A2} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} {050E99E5-5F26-4157-A80A-0493D5E9DE55} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} + {7ED57B2C-520B-4A25-B3C1-268EEA48CADB} = {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} + {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} = {2444FB9D-15D1-4193-BF04-83C4397369DA} + {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} = {2444FB9D-15D1-4193-BF04-83C4397369DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} diff --git a/api/src/FinancialHub/docker-compose.yml b/api/src/FinancialHub/docker-compose.yml new file mode 100644 index 0000000..edcaa54 --- /dev/null +++ b/api/src/FinancialHub/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.4' +services: + sql-database: + image: mcr.microsoft.com/mssql/server:2019-latest + tty: true + environment: + - SA_PASSWORD=P@ssw0rd! + - ACCEPT_EULA=Y + ports: + - "1450:1433" + volumes: + - ../database:/var/opt/mssql/data \ No newline at end of file From 34396aabedddf219d3a7482c701d5f58b5011f75 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Fri, 3 Jun 2022 11:07:36 -0300 Subject: [PATCH 09/30] Release v0.3.0 * Add : CHANGELOG.md * Add : Postman file * Add : Account, Category, Transaction & Balance validators * Add : Services GetById returns not found error * Add : Account Balance * Add : BalancesRepository & BalancesService * Add : IAccountBalanceService to AccountsController * Add : Balance Database Migration * Add : Balance Create/Update Endpoint * Add : Create an active & commited Transaction updates balance amount * Add : Transaction Deletion Removes Balance amount * Update : Currency moved from Account to Balance * Update : Transactions now holds balanceId * Update : README.md * Remove : Old AutoMapper from api project * Remove : Code Smells in AccountsServiceTests, Builders & TransactionFilter * Fix : Code coverage pipeline always 0% * Fix : TransactionQuery Filter By Start Month * Known Issue : Change Transaction Amount is creating a new one * Known Issue : Delete Account is not removing child balances --- .github/workflows/sonarcloud.yml | 27 +- CHANGELOG.md | 7 + README.md | 36 +- .../financial-hub-api-dev.postman_environment | 15 + .../api/financial-hub-api.postman_collection | 1261 +++++++++++++++++ api/docs/database/database.drawio | 2 +- api/docs/database/financial-hub_DDL.sql | 22 +- .../Builders/Entities/AccountEntityBuilder.cs | 7 - .../Builders/Entities/BalanceEntityBuilder.cs | 52 + .../Entities/TransactionEntityBuilder.cs | 33 +- .../Builders/Models/AccountModelBuilder.cs | 7 - .../Builders/Models/BalanceModelBuilder.cs | 52 + .../Models/TransactionModelBuilder.cs | 28 +- .../Queries/TransactionQueryTests.cs | 212 +++ .../Entities/AccountEntity.cs | 4 +- .../Entities/BalanceEntity.cs | 26 + .../Entities/TransactionEntity.cs | 6 +- .../Filters/TransactionFilter.cs | 32 - .../FinancialHub.Domain.csproj | 15 + .../Repositories/IBalancesRepository.cs | 12 + .../Services/IAccountBalanceService.cs | 15 + .../Interfaces/Services/IBalancesService.cs | 21 + .../Services/ITransactionsService.cs | 6 +- .../Models/AccountModel.cs | 1 - .../Models/BalanceModel.cs | 15 + .../Models/TransactionModel.cs | 8 +- .../Queries/TransactionQuery.cs | 102 +- .../FinancialHubConcepts.Designer.cs | 90 ++ .../Resources/FinancialHubConcepts.resx | 129 ++ .../Results/ServiceResult.cs | 16 + .../Accounts/AccountsRepositoryTests.cs | 3 +- .../BalancesRepositoryTests.amount.cs | 98 ++ .../BalancesRepositoryTests.create.cs | 24 + .../Balances/BalancesRepositoryTests.cs | 27 + .../Repositories/Base/BaseRepositoryTests.cs | 2 + .../Base/BaseRepositoryTests.delete.cs | 2 + .../TransactionsRepositoryTests.create.cs | 60 +- .../TransactionsRepositoryTests.cs | 24 +- .../TransactionsRepositoryTests.delete.cs | 4 +- .../TransactionsRepositoryTests.update.cs | 30 +- .../Contexts/FinancialHubContext.cs | 21 +- .../Repositories/BalancesRepository.cs | 57 + .../Repositories/BaseRepository.cs | 8 +- .../Repositories/TransactionsRepository.cs | 4 +- .../20220520163358_add-balance.Designer.cs | 236 +++ .../Migrations/20220520163358_add-balance.cs | 57 + ...117_add-balance-to-transaction.Designer.cs | 242 ++++ ...220520215117_add-balance-to-transaction.cs | 69 + ...20520215501_add-balance-active.Designer.cs | 246 ++++ .../20220520215501_add-balance-active.cs | 26 + .../FinancialHubContextModelSnapshot.cs | 81 +- .../Base/BaseControllerTests.cs | 167 +++ .../Controllers/AccountsControllerTests.cs | 57 +- .../Controllers/BalancesControllerTests.cs | 220 +++ .../TransactionsControllerTests.cs | 34 +- .../Setup/FinancialHubFixture.cs | 19 +- .../AccountBalanceServiceTests.create.cs | 129 ++ .../AccountBalanceServiceTests.cs | 37 + .../AccountBalanceServiceTests.delete.cs | 147 ++ .../Services/Accounts/AccountsServiceTests.cs | 13 +- .../Accounts/AccountsServiceTests.delete.cs | 2 - .../Accounts/AccountsServiceTests.get.cs | 1 - .../Balances/BalancesServiceTests.create.cs | 99 ++ .../Services/Balances/BalancesServiceTests.cs | 79 ++ .../Balances/BalancesServiceTests.delete.cs | 42 + .../Balances/BalancesServiceTests.get.cs | 79 ++ .../Balances/BalancesServiceTests.update.cs | 149 ++ .../TransactionsServiceTests.create.cs | 158 ++- .../Transactions/TransactionsServiceTests.cs | 20 +- .../TransactionsServiceTests.delete.cs | 128 +- .../TransactionsServiceTests.get.cs | 81 +- .../TransactionsServiceTests.update.cs | 334 ++++- .../Mappers/FinancialHubAutoMapperProfile.cs | 1 + .../Services/AccountBalanceService.cs | 76 + .../Services/AccountsService.cs | 3 +- .../Services/BalancesService.cs | 104 ++ .../Services/TransactionsService.cs | 105 +- .../AccountsControllerTests.create.cs | 8 +- .../Accounts/AccountsControllerTests.cs | 8 +- .../BalancesControllerTests.create.cs | 68 + .../Balances/BalancesControllerTests.cs | 30 + .../BalancesControllerTests.delete.cs | 20 + .../BalancesControllerTests.update.cs | 69 + .../Validators/AccountValidatorTests.cs | 85 ++ .../Validators/BalanceValidatorTests.cs | 86 ++ .../Validators/CategoryValidatorTests.cs | 85 ++ .../Validators/TransactionValidatorTests.cs | 86 ++ .../Controllers/AccountsController.cs | 19 +- .../Controllers/BalancesController.cs | 68 + .../Controllers/TransactionsController.cs | 4 +- .../IServiceCollectionExtensions.cs | 22 + .../FinancialHub.WebApi.csproj | 16 + .../FinancialHubAutoMapperProfile.cs | 22 - .../Resources/ErrorMessages.Designer.cs | 99 ++ .../Resources/ErrorMessages.resx | 132 ++ .../FinancialHub.WebApi/Startup.cs | 1 + .../Validators/AccountValidator.cs | 22 + .../Validators/BalanceValidator.cs | 22 + .../Validators/CategoryValidator.cs | 22 + .../Validators/TransactionValidator.cs | 28 + 100 files changed, 6402 insertions(+), 484 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 api/docs/api/environments/financial-hub-api-dev.postman_environment create mode 100644 api/docs/api/financial-hub-api.postman_collection create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs create mode 100644 api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs create mode 100644 api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs create mode 100644 api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs create mode 100644 api/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs delete mode 100644 api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs create mode 100644 api/src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 77062ec..f124f1a 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -22,9 +22,11 @@ jobs: code_analysis: name: Code Analysis runs-on: windows-latest + defaults: run: working-directory: ./api/src/FinancialHub/ + steps: - name: Set up JDK 11 uses: actions/setup-java@v1 @@ -62,13 +64,30 @@ jobs: - name: Restore dependencies run: dotnet restore - + - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} shell: powershell run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"Chingling152_my-financial-hub" /o:"chingling-152" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" - dotnet build - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" + .\.sonar\scanner\dotnet-sonarscanner begin ` + /k:"Chingling152_my-financial-hub" ` + /o:"chingling-152" ` + /d:sonar.login="${{ secrets.SONAR_TOKEN }}" ` + /d:sonar.host.url="https://sonarcloud.io" ` + /d:sonar.coverage.exclusions=/FinancialHub.Infra.Migrations/** ` + /d:sonar.cs.opencover.reportsPaths="/TestResults/**/coverage.opencover.xml" + + echo "build project" + dotnet build --configuration Release --no-restore + + echo "running code coverage" + dotnet test ` + --collect:"XPlat Code Coverage" ` + --results-directory TestResults/ ` + --configuration release ` + -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover ` + + .\.sonar\scanner\dotnet-sonarscanner end ` + /d:sonar.login="${{ secrets.SONAR_TOKEN }}" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..876287f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +## API +* ### [v0.2.4](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.4) +* ### [v0.2.3](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.3) +* ### [v0.2.2](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.2) +* ### [v0.2.1](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.1) +* ### [v0.2.0](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.0) +* ### [v0.1.0](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.1.0) diff --git a/README.md b/README.md index f8af120..e15b7b4 100644 --- a/README.md +++ b/README.md @@ -1 +1,35 @@ -# my-financial-hub \ No newline at end of file +# My Financial Hub + + +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Chingling152_my-financial-hub&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Chingling152_my-financial-hub) + +## What's planned for the future + +- ### Api + - **[Monthly Milestones](https://github.com/Chingling152/my-financial-hub/issues/9)** + - **[Earns/Expenses Portion](https://github.com/Chingling152/my-financial-hub/issues/10)** + - **Transaction exports (xlsx,pdf)** + - **Earns/Expenses average** + - **Earns/Expenses predictions** + +## Requeriments +- ### Api + * Docker (optional) + * .NET 6.0 + * SQL Server + +## How to Start +### Api +* Run the Dockerfile in root project to create the database (optional) +* Configure the **ConnectionStrings** in the file **appsettings.Development.json** with your SQL Server database +* Initial configuration (pick one) + * #### Visual Studio + Open : Project solution and build the project + Open : Tools -> NuGet Package Manager -> Package Manager Console + Type : Update-Database + * ### Dotnet Cli + Open : WebApi Project directory + Type : dotnet build + Type : dotnet tool install --global dotnet-ef + Type : dotnet ef database update +* After that, you'll be able to run the project diff --git a/api/docs/api/environments/financial-hub-api-dev.postman_environment b/api/docs/api/environments/financial-hub-api-dev.postman_environment new file mode 100644 index 0000000..a008aad --- /dev/null +++ b/api/docs/api/environments/financial-hub-api-dev.postman_environment @@ -0,0 +1,15 @@ +{ + "id": "b25ada13-3e88-4b39-94c1-e3eb1bc394aa", + "name": "Financial Hub Api", + "values": [ + { + "key": "baseUrl", + "value": "http://localhost:62772/", + "type": "default", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2022-04-29T18:21:42.984Z", + "_postman_exported_using": "Postman/9.14.14" +} \ No newline at end of file diff --git a/api/docs/api/financial-hub-api.postman_collection b/api/docs/api/financial-hub-api.postman_collection new file mode 100644 index 0000000..caa4b60 --- /dev/null +++ b/api/docs/api/financial-hub-api.postman_collection @@ -0,0 +1,1261 @@ +{ + "info": { + "_postman_id": "38685a83-5b92-4a6a-93f3-ee9ece5cbb4b", + "name": "Financial Hub WebApi", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Accounts", + "item": [ + { + "name": "{id}", + "item": [ + { + "name": "/Accounts/:id", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Accounts/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Accounts/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n }\n}" + }, + { + "name": "Bad Request", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Accounts/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" + }, + { + "name": "Not Found", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Accounts/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "Not Found", + "code": 404, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" + } + ] + }, + { + "name": "/Accounts/:id", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{baseUrl}}/Accounts/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{baseUrl}}/Accounts/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + } + ] + } + ] + }, + { + "name": "/Accounts", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/Accounts", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts" + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/Accounts", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": [\n {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n }\n ]\n}" + } + ] + }, + { + "name": "/Accounts", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Accounts", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts" + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Accounts", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n }\n}" + }, + { + "name": "Bad Request", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Accounts", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Accounts" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" + } + ] + } + ] + }, + { + "name": "Categories", + "item": [ + { + "name": "{id}", + "item": [ + { + "name": "/Categories/:id", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Categories/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Categories", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Categories/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Categories", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n }\n}" + }, + { + "name": "Bad Request", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Categories/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Categories", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" + } + ] + }, + { + "name": "/Categories/:id", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{baseUrl}}/Categories/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Categories", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:62772//Categories/:id", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "62772", + "path": [ + "", + "Categories", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + } + ] + } + ] + }, + { + "name": "/Categories", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/Categories", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Categories" + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:62772//Categories", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "62772", + "path": [ + "", + "Categories" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": [\n {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n }\n ]\n}" + } + ] + }, + { + "name": "/Categories", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Categories", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Categories" + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:62772//Categories", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "62772", + "path": [ + "", + "Categories" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n }\n}" + }, + { + "name": "Bad Request", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Categories", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Categories" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" + } + ] + } + ] + }, + { + "name": "Transactions", + "item": [ + { + "name": "{id}", + "item": [ + { + "name": "/Transactions/:id", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Transactions/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Transactions", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:62772//Transactions/:id", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "62772", + "path": [ + "", + "Transactions", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n }\n}" + }, + { + "name": "Bad Request", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Transactions/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Transactions", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" + } + ] + }, + { + "name": "/Transactions/:id", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{baseUrl}}/Transactions/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Transactions", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:62772//Transactions/:id", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "62772", + "path": [ + "", + "Transactions", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "", + "description": "(Required) " + } + ] + } + }, + "status": "No Content", + "code": 204, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + } + ] + } + ] + }, + { + "name": "/Transactions", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/Transactions?StartDate=&EndDate=&Types=&Types=&Status=&Status=&Accounts=&Accounts=&Categories=&Categories=", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Transactions" + ], + "query": [ + { + "key": "StartDate", + "value": "" + }, + { + "key": "EndDate", + "value": "" + }, + { + "key": "Types", + "value": "" + }, + { + "key": "Types", + "value": "" + }, + { + "key": "Status", + "value": "" + }, + { + "key": "Status", + "value": "" + }, + { + "key": "Accounts", + "value": "" + }, + { + "key": "Accounts", + "value": "" + }, + { + "key": "Categories", + "value": "" + }, + { + "key": "Categories", + "value": "" + } + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:62772//Transactions?StartDate=&EndDate=&Types=&Types=&Status=&Status=&Accounts=&Accounts=&Categories=&Categories=", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "62772", + "path": [ + "", + "Transactions" + ], + "query": [ + { + "key": "StartDate", + "value": "" + }, + { + "key": "EndDate", + "value": "" + }, + { + "key": "Types", + "value": "" + }, + { + "key": "Types", + "value": "" + }, + { + "key": "Status", + "value": "" + }, + { + "key": "Status", + "value": "" + }, + { + "key": "Accounts", + "value": "" + }, + { + "key": "Accounts", + "value": "" + }, + { + "key": "Categories", + "value": "" + }, + { + "key": "Categories", + "value": "" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": [\n {\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n },\n {\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n }\n ]\n}" + } + ] + }, + { + "name": "/Transactions", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Transactions", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Transactions" + ] + } + }, + "response": [ + { + "name": "Success", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:62772//Transactions", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "62772", + "path": [ + "", + "Transactions" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n }\n}" + }, + { + "name": "Bad Request", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/Transactions", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "Transactions" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" + } + ] + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ] +} \ No newline at end of file diff --git a/api/docs/database/database.drawio b/api/docs/database/database.drawio index 6dfcdca..462b4b6 100644 --- a/api/docs/database/database.drawio +++ b/api/docs/database/database.drawio @@ -1 +1 @@ -7V1dd6o4FP01PvYuAbH2sdr2tuvaO3faTjudl64UImYGiSvEKv31k0DwowQviviRsJYP5iSE5OydDckh0LB6o9l3AsbDe+xCv2E23VnDumqYptEyzQb/Nd0osZy3hcEjyBWFFoZH9AmFsSmsE+TCcKUgxdinaLxqdHAQQIeu2AAheLpabID91bOOgQczhkcH+FnrC3LpMLF27ObCfguRN0zPbDRFzjtw/vMIngTifAEOYJIzAmk1omg4BC6eLpms64bVIxjT5N9o1oM+d2vqseS4m5zceZMJDGiRA67AnT8FwH1rWWc/X6Km92q9nolaPoA/Ea64dBzWHRqKRtMo9RFr/5j/peCdm7ohBYQKKK0mMzBwKEABJMxgxGnfB+MQxcUTyxD5bh9EeELTitJUd4Bm0H1IkORlGah9VhlP8soHrPJH0RieDXzkBey/w3rPz9glMGRt6YOQihJZ/6SdhYTC2ZJJ+Os7xCNIScSKiNyWgC5aTU4XFDE6wjZcpseFMAJBS29e8wIf9kdAtAFcZgauXJhYxykC/gMbLiDwYsRWAeFedQkePwHiQSoMY4y4P68/IKeAcD3y/R72Mcc15rfVpXgsMn04SI99x5TiUQqfcMe80tgVdpf9mHN6zW92w2bN7bG0sUizHy9OaA8HISWMTbwOyECdQg6sBNS1tP490gJaqyC0VlXIWhlkf/3YDNtYGcEC241ha36B7euQw8ydAz+WsCFyXRgUx8MsjMcSANaG/heVLbyycW3AZ9wPAIVdruhhBtR5O7fHuZXBmRU/LM6plCZlu+EYOCjw+smR7S9EsPdFhFn+wLR3SoxC1e2BGfZJaPtX8pyAtrcPre3tksjufMRDF6X1lRR2uzAYqgv7eQbkAIzgsUv7XqBXWcrtW/gS/cCXs+iq/1dk2/fEfJfMqmop34mUX+xRyqXIlp2AHYeUryWtVlIu9UR2LubC0CFoTBEO1FD0kgxQWdHl85bs5b2W9J1IumEe+vbc7Cgh6ut5q5Wqy11xkYHZmRDmPydSQ9PLEkA7US877mtNz9N0+9Canh3rykh6pzAaqit6Gj1eQhk4FH2ovOpSHH2V5bx9h/t3vWfndtr5eRk4Z4M/WoFk1aXHzudhgmAdzW5kotlmp6BIG+0dqLQUsbKrKQqGs9cy+yjD2dIWKxPOXstbrS7BUk/oE84uSQTtrsZ1OLsibd9nOFvaYjXC2WtJWwu7yuHsktBrJ+X1OllFUr7PcLa0xWosk60lbS3lkmUy5eLZJSmgnaQb2Ylbrek70fS9xrPlTS479TpiVZ/ztpZ1IzsPUyn6URZ+lSX94p/bh1HwPHo+f/y4/xM0W5+fhiT88URAEHJOMAnMJcVpBUAywEtiImsCINvt55tHSspItRSzOgBSBNV8uh9FAETavJMOgGyDh6n8VVjabbUDIDskgnbX43rVrCJt32cARNq801012waMjp7Cruqq2Q4poJ2k16tmVWn6PiMh8uad7qLZVmi0NFV1yaLZiL/vSC9Bz4NfO0UvvferVvRjiIPIsdXrPt3U9Ebdyt6oD1CAwuGby86rl67ncUA/Xc+Sotb13ej6Pvf2ybHNRrpuDr22Xq2yN/VU9nTMrkS447eTvh3/Ivt+KKCdsBv1iziqEvai+wGrW4PJTsbUFvaEzPoJuyF5FUeyVTfSTtnzOKCdspv1jrGKlH3+mv3D3bKf7p6xre7WbD11XfKWtJACOsl/+lBJSc+DXztJN+oXoVYl6UWfXa3uZj07OVdZ0g31dxnI+519kPXUdxnsEn7tJN20MsBD14Pp46RMCofYwwHwrxfWbvyBJOgK6BZl+jjGnI/WfyGlkdh+ACYUM9OQjnyRy8Ah0d/pOOeJV574ZqfJq9ly5lUkUvGmhkv+gShmuH5IiBYbbxDvtzjEXSnyhO9BECUZS8WSfvPO5lJHmEI8IY4ote4rGDS9kuU6O2fVj0AfxGNw+axrOPWLX9CW2bq6D8L8+r2ipAPiqAo41Ko5tAmH1r165rccyltfKMyhnLsEllx8uyxhxuLbcNb1/w== \ No newline at end of file +7V1bd6I6GP01PnaWoNj2sdrrGp2Z0+v0vHSlEJE5SFghttJfPwkEb4lUD4g2ZC0fyJcQwrd3Nkk+go1Wbzy9wiAcDZAD/YbZdKaN1nnDNI22aTbYr+nEqeW4ww0u9hxeaG648z4gNza5deI5MFoqSBDyiRcuG20UBNAmSzaAMXpfLjZE/vJVQ+BCwXBnA1+0PnkOGaXWE6s5t19Dzx1lVzaaPOcV2P+5GE0Cfr0ABTDNGYOsGl40GgEHvS+YWheNVg8jRNKj8bQHfebWzGPpeZdrcmdNxjAgm5xwDm78dwCcl3br6MdT3HSfW89HvJY34E+4K85sm94OiXijSZz5iLY/ZIcEvDJTNyIAEw5lq0kNFBwCvABiajCStO+DMPKS4qll5PlOH8RoQrKKslR36E2hc5siycpSUPu0MpZklQ9p5Xe8MSwb+J4b0GOb3j27YhfDiLalDyLCS4j+yW4WYgKnCyburyuIxpDgmBbhuW0OHWd1iyff5xQxTrhttEiPDjcCTkt3VvMcH3rAIdoCLlOAay1M9MaJB/xb2l1A4CaILQPCvOpgFN4D7ELCDSHymD8v3iCjAHe95/s95COGa8LvVpegkGf6cJid+4oIQeMMPu6OWaWJK6wu/VHn9JrfrIZFm9ujaWOepj9WHJMeCiKCKZtYHZCC+g4ZsBJQc2n9OdJbQtvaFbItAdlf37fDNlFGMMd2a9iaK7CtdjlE3Tn0EwkbeY4Dg83xMDfGYwGA1pb+55XNvbJ1bcCn3A8AgV2m6JEA6qyd/x/ntoAzLb5fnDMpTct2oxDYXuD20zM7K0SwqiLCdH3HtEolxkbVVcAM60to+yp5voC2d/at7Z2CyJbe46HjZfUVFHZrYzBUF/ZjAeQAjOGhS3sl0Kss5dY1fIq/o7NpfN5/iC1rgM1XyaxKS3kpUn5aoZRLkS06ATsMKc8lba2kXOoJcS7mwMjGXkg8FKih6AUZoLKiS5XqRCv6bhTdMPc9Oj9VQtJzWVsrSZfzsimgDGzivak8QN8cfZXlvHOD+je9R/v6/eTHWWAfDX+2A8kAvUev5yLsQR34oDmzgTZX6Y3XUEoJfUgh06EPAdZcah9k6EPaYmVCH7m8rdUzWOqJ+oQ+ChKhdo9jHfrYkbZXGfqQtliN0EcuabWwqxz6KAh97aRcL5TtSMqrDH1IW6zGOlkuabWUS9bJlIt9FKRA7STdECduWtNL0fRKgx/yJhedeh2wqs94q2XdEOdhKoU/isKvsqSf/nt9Ow4ex4/Hd2+Df0Cz/fFhSOIf9xgEEeMElcC1pKhRBKST7fDJIiAbKrV5UoJUSzHTARAB1VxuH2QARNpiZQIgubyt1VNY6on6BEAKEqF2z2O9arYjba8yACJtsRqrZrmk1cJeh1WzghSonaTrVbNdaXqVkRB5i9VYNMunrVZ12aLZmH0bQ2FB14tmOfMXPUrfkaJXGgeRY6vwON3UA/XZSps4UB96gReNXhx6XYV1fQsO1E/XRVJoXS9H162967oY6brc99p6icre3BgR1ZU967MLQL8CHwQ2fDn8RfZqKFA7YTfEF5O1sJcj7Cf7FnZDnIwpJOwz5mphN8SZmZ3u1Y3VVvYtOFA7ZTf1jrEdKfvsk8z7G7KrsWcsn7da101xcBYRQCbr3z78+pK+Bfy1k3RDfzRvV5Le3rekG+LkXBlJNzbHQ3VJN8QXWVXaZVAU/tpJutkWgIeOC7PXSakUjpCLAuBfzK3d5M80oMOhm5fpowRz1lv/QEJivv0ATAiiphEZ+zyX4oXj31k/Z4lnlvhmZcnz6WLmecxTyaaGM/ZnItRwcZsSLTFeeuy++SnOUpF7NABBnGYsFBPJw2kSoQm2uS/yvhJCsgfXWt7x4RNzaC7rMPRB0gcXm1FE4Y8BubMe0cvxfTxy3J/+6cPZlWRDSTddfV3b9Wu0l2T1a1qbbjgo5WNaUriKPo8V3EuSS+uD3EsibbEye0lyeVursZbUE/XZS1KQCCqPuqSu0UujO9L2KveSSFusxsJoLmm1sKv8Ma2C0NdOyvULxzuS8iq3kEhbrMbrxrmk1VIu2RZoTzB1nx0rrOf6TeP1hNAxrh0JeqU7SORNFtfUvuYLafnM1aoujXIl/5mtzPtoRSmgsrBPwvAP/HF2G/3yB6dH1w+98dXvTK+qDXSVH7BaCSZ9GsHK+4vfxQhWDp8qCFhJERMfvIeKWElY5S2jfhptTJ+u5WNFkxghstgZMQhHA+RAVuIv \ No newline at end of file diff --git a/api/docs/database/financial-hub_DDL.sql b/api/docs/database/financial-hub_DDL.sql index b35b283..464c825 100644 --- a/api/docs/database/financial-hub_DDL.sql +++ b/api/docs/database/financial-hub_DDL.sql @@ -1,25 +1,37 @@ CREATE DATABASE financial_hub; USE financial_hub; -CREATE TABLE accounts( +CREATE TABLE categories( id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), name VARCHAR(200) NOT NULL, description VARCHAR(500) NULL, - currency VARCHAR(50), active BIT DEFAULT 1, + update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), ); -CREATE TABLE categories( +CREATE TABLE accounts( id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), name VARCHAR(200) NOT NULL, description VARCHAR(500) NULL, active BIT DEFAULT 1, + update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), ); +CREATE TABLE balances( + id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), + name VARCHAR(200) NOT NULL, + amount MONEY NOT NULL, + + account_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES accounts(id) NOT NULL, + + update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), + creation_time DATETIMEOFFSET DEFAULT GETUTCDATE() +); + CREATE TABLE transactions( id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), description VARCHAR(500) NULL, @@ -28,7 +40,7 @@ CREATE TABLE transactions( target_date DATETIMEOFFSET NOT NULL, finish_date DATETIMEOFFSET NOT NULL, - account_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES accounts(id) NOT NULL, + balance_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES balances(id) NOT NULL, category_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES categories(id) NOT NULL, status INT NOT NULL, @@ -37,4 +49,4 @@ CREATE TABLE transactions( update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), -); \ No newline at end of file +); diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs index 5e70ad4..a966c6b 100644 --- a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs @@ -7,7 +7,6 @@ public class AccountEntityBuilder : BaseEntityBuilder public AccountEntityBuilder() : base() { this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); - this.RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code); this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); } @@ -18,12 +17,6 @@ public AccountEntityBuilder WithName(string name) return this; } - public AccountEntityBuilder WithCurrency(string currency) - { - this.RuleFor(c => c.Currency, currency); - return this; - } - public AccountEntityBuilder WithDescription(string description) { this.RuleFor(c => c.Description, description); diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs new file mode 100644 index 0000000..8cea247 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs @@ -0,0 +1,52 @@ +using FinancialHub.Domain.Entities; +using System; + +namespace FinancialHub.Domain.Tests.Builders.Entities +{ + public class BalanceEntityBuilder : BaseEntityBuilder + { + public BalanceEntityBuilder() : base() + { + var account = new AccountEntityBuilder().Generate(); + + this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); + this.RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code); + this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000), 2)); + + this.RuleFor(x => x.Account, fake => account); + this.RuleFor(x => x.AccountId, fake => account.Id); + } + + public BalanceEntityBuilder WithName(string name) + { + this.RuleFor(c => c.Name, name); + return this; + } + + public BalanceEntityBuilder WithCurrency(string currency) + { + this.RuleFor(c => c.Currency, currency); + return this; + } + + public BalanceEntityBuilder WithAmount(decimal amount) + { + this.RuleFor(c => c.Amount, amount); + return this; + } + + public BalanceEntityBuilder WithAccount(AccountEntity account) + { + this.RuleFor(x => x.AccountId, fake => account.Id); + this.RuleFor(x => x.Account, fake => account); + return this; + } + + public BalanceEntityBuilder WithAccountId(Guid? accountId) + { + this.RuleFor(x => x.AccountId, fake => accountId); + this.Ignore( x => x.Account); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs index 238572d..de95478 100644 --- a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs @@ -8,7 +8,7 @@ public class TransactionEntityBuilder : BaseEntityBuilder { public TransactionEntityBuilder() : base() { - var account = new AccountEntityBuilder().Generate(); + var balance = new BalanceEntityBuilder().Generate(); var category = new CategoryEntityBuilder().Generate(); this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000),2)); @@ -17,8 +17,8 @@ public TransactionEntityBuilder() : base() this.RuleFor(x => x.Type, fake => fake.PickRandom()); this.RuleFor(x => x.Status, fake => fake.PickRandom()); - this.RuleFor(x => x.AccountId, fake => account.Id); - this.RuleFor(x => x.Account, fake => account); + this.RuleFor(x => x.BalanceId, fake => balance.Id); + this.RuleFor(x => x.Balance, fake => balance); this.RuleFor(x => x.CategoryId, fake => category.Id); this.RuleFor(x => x.Category, fake => category); @@ -29,28 +29,28 @@ public TransactionEntityBuilder() : base() public TransactionEntityBuilder WithCategoryId(Guid? categoryId) { this.RuleFor(x => x.CategoryId, fake => categoryId); - this.RuleFor(x => x.Category, fake => default); + this.Ignore(x => x.Category); return this; } public TransactionEntityBuilder WithCategory(CategoryEntity category) { - this.WithCategoryId(category.Id); + this.RuleFor(x => x.CategoryId, fake => category.Id); this.RuleFor(x => x.Category, fake => category); return this; } - public TransactionEntityBuilder WithAccount(AccountEntity account) + public TransactionEntityBuilder WithBalance(BalanceEntity balance) { - this.WithAccountId(account.Id); - this.RuleFor(x => x.Account, fake => account); + this.RuleFor(x => x.BalanceId, fake => balance.Id); + this.RuleFor(x => x.Balance, fake => balance); return this; } - public TransactionEntityBuilder WithAccountId(Guid? accountId) + public TransactionEntityBuilder WithBalanceId(Guid? balanceId) { - this.RuleFor(x => x.AccountId, fake => accountId); - this.RuleFor(x => x.Account, fake => default); + this.RuleFor(x => x.BalanceId, fake => balanceId); + this.Ignore( x => x.Balance); return this; } @@ -77,5 +77,16 @@ public TransactionEntityBuilder WithActiveStatus(bool isActive) this.RuleFor(x => x.IsActive, fake => isActive); return this; } + + public TransactionEntityBuilder WithTargetDate(DateTime date) + { + this.RuleFor(x => x.TargetDate, date); + return this; + } + public TransactionEntityBuilder WithTargetDateNextTo(DateTime date,int offset = 90) + { + this.RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset(offset, date)); + return this; + } } } diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs index 3b47b3b..98b2d19 100644 --- a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs @@ -7,7 +7,6 @@ public class AccountModelBuilder : BaseModelBuilder public AccountModelBuilder() : base() { this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); - this.RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code); this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); } @@ -18,12 +17,6 @@ public AccountModelBuilder WithName(string name) return this; } - public AccountModelBuilder WithCurrency(string currency) - { - this.RuleFor(c => c.Currency, currency); - return this; - } - public AccountModelBuilder WithDescription(string description) { this.RuleFor(c => c.Description, description); diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs new file mode 100644 index 0000000..ac0dc89 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs @@ -0,0 +1,52 @@ +using FinancialHub.Domain.Models; +using System; + +namespace FinancialHub.Domain.Tests.Builders.Models +{ + public class BalanceModelBuilder : BaseModelBuilder + { + public BalanceModelBuilder() : base() + { + var account = new AccountModelBuilder().Generate(); + + this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); + this.RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code); + this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000), 2)); + + this.RuleFor(x => x.Account, fake => account); + this.RuleFor(x => x.AccountId, fake => account.Id); + } + + public BalanceModelBuilder WithName(string name) + { + this.RuleFor(c => c.Name, name); + return this; + } + + public BalanceModelBuilder WithCurrency(string currency) + { + this.RuleFor(c => c.Currency, currency); + return this; + } + + public BalanceModelBuilder WithAmount(decimal amount) + { + this.RuleFor(c => c.Amount, amount); + return this; + } + + public BalanceModelBuilder WithAccount(AccountModel account) + { + this.WithAccountId(account.Id); + this.RuleFor(x => x.Account, fake => account); + return this; + } + + public BalanceModelBuilder WithAccountId(Guid? accountId) + { + this.RuleFor(x => x.AccountId, fake => accountId); + this.Ignore(x => x.Account); + return this; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs index e2412c5..3edba61 100644 --- a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs @@ -8,7 +8,7 @@ public class TransactionModelBuilder : BaseModelBuilder { public TransactionModelBuilder() : base() { - var account = new AccountModelBuilder().Generate(); + var balance = new BalanceModelBuilder().Generate(); var category = new CategoryModelBuilder().Generate(); this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000),2)); @@ -16,17 +16,25 @@ public TransactionModelBuilder() : base() this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); this.RuleFor(x => x.Type, fake => fake.PickRandom()); this.RuleFor(x => x.Status, fake => fake.PickRandom()); - this.RuleFor(x => x.AccountId, fake => account.Id); - this.RuleFor(x => x.Account, fake => account); + + this.RuleFor(x => x.BalanceId, fake => balance.Id); + this.RuleFor(x => x.Balance, fake => balance); + this.RuleFor(x => x.CategoryId, fake => category.Id); this.RuleFor(x => x.Category, fake => category); } + public TransactionModelBuilder WithDescription(string description) + { + this.RuleFor(c => c.Description, description); + return this; + } + public TransactionModelBuilder WithCategoryId(Guid? categoryId) { this.RuleFor(x => x.CategoryId, fake => categoryId); - this.RuleFor(x => x.Category, fake => default); + this.Ignore( x => x.Category); return this; } @@ -37,17 +45,17 @@ public TransactionModelBuilder WithCategory(CategoryModel category) return this; } - public TransactionModelBuilder WithAccount(AccountModel account) + public TransactionModelBuilder WithBalance(BalanceModel balance) { - this.WithAccountId(account.Id); - this.RuleFor(x => x.Account, fake => account); + this.WithBalanceId(balance.Id); + this.RuleFor(x => x.Balance, fake => balance); return this; } - public TransactionModelBuilder WithAccountId(Guid? accountId) + public TransactionModelBuilder WithBalanceId(Guid? balanceId) { - this.RuleFor(x => x.AccountId, fake => accountId); - this.RuleFor(x => x.Account, fake => default); + this.RuleFor(x => x.BalanceId, fake => balanceId); + this.Ignore(x => x.Balance); return this; } diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs b/api/src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs new file mode 100644 index 0000000..880c570 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs @@ -0,0 +1,212 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Queries; +using FinancialHub.Domain.Tests.Builders.Entities; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace FinancialHub.Domain.Tests.Queries +{ + public class TransactionQueryTests + { + private readonly Random random; + private TransactionEntityBuilder transactionBuilder; + + public TransactionQueryTests() + { + this.random = new Random(); + } + + [SetUp] + public void SetUp() + { + this.transactionBuilder = new TransactionEntityBuilder(); + } + + [Test] + public void Query_AlwaysFilterByActiveStatus() + { + var size = this.random.Next(10,100); + var entities = this.transactionBuilder.Generate(size); + + var query = new TransactionQuery().Query(); + + var expectedResult = entities.Where(x => x.IsActive); + var result = entities.Where(query); + + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void Query_OnlyStartDate_FiltersStartDateMonth() + { + var thisDate = DateTime.Now; + var size = this.random.Next(10, 100); + + var entity = this.transactionBuilder + .WithTargetDate(thisDate) + .WithActiveStatus(true) + .Generate(); + var entities = this.transactionBuilder + .WithTargetDateNextTo(thisDate,30) + .Generate(size); + entities.Add(entity); + + var transactionQuery = new TransactionQuery() + { + StartDate = thisDate + }; + + var result = entities.Where(transactionQuery.Query()); + + foreach (var res in result) + { + Assert.AreEqual(thisDate.Month, res.TargetDate.Month); + Assert.IsTrue(res.IsActive); + } + Assert.Greater(result.Count(), 0); + } + + [Test] + public void Query_OnlyEndDate_DoNotFilterByDate() + { + var endDate = DateTime.Now.AddMonths(-2); + + var size = this.random.Next(10, 100); + var entities = this.transactionBuilder + .WithTargetDateNextTo(endDate) + .Generate(size); + + var transactionQuery = new TransactionQuery() + { + EndDate = endDate + }; + + var result = entities.Where(transactionQuery.Query()); + + var expectedResult = entities.Where(x => x.IsActive); + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void Query_StartDateAndEndDate_FiltersBetweenDates() + { + var startDate = DateTime.Now.AddMonths(-2); + var endDate = startDate.AddMonths(2); + + var size = this.random.Next(10, 100); + var entities = this.transactionBuilder + .WithTargetDateNextTo(startDate) + .Generate(size); + + var transactionQuery = new TransactionQuery() + { + StartDate = startDate, + EndDate = endDate + }; + + var result = entities.Where(transactionQuery.Query()); + + var expectedResult = entities.Where(x => + x.IsActive && + x.TargetDate >= startDate && + x.TargetDate <= endDate + ); + + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void Query_Balances_FiltersByBalance() + { + var size = this.random.Next(10, 100); + var entities = this.transactionBuilder.Generate(size); + + var balances = entities.Where(x=> x.Amount > 1000).Select(x => x.BalanceId).ToArray(); + + var transactionQuery = new TransactionQuery() + { + Balances = balances + }; + + var result = entities.Where(transactionQuery.Query()); + + var expectedResult = entities.Where( + x => x.IsActive && balances.Contains(x.BalanceId) + ); + + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void Query_Categories_FiltersByCategory() + { + var size = this.random.Next(10, 100); + var entities = this.transactionBuilder.Generate(size); + + var categories = entities.Where(x => x.Amount > 1000).Select(x => x.CategoryId).ToArray(); + var transactionQuery = new TransactionQuery() + { + Categories = categories + }; + + var result = entities.Where(transactionQuery.Query()); + + var expectedResult = entities.Where( + x => x.IsActive && categories.Contains(x.CategoryId) + ); + + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void Query_Types_FiltersByType() + { + var size = this.random.Next(10, 100); + var entities = this.transactionBuilder.Generate(size); + + var types = new TransactionType[1] + { + TransactionType.Earn + }; + var transactionQuery = new TransactionQuery() + { + Types = types + }; + + var result = entities.Where(transactionQuery.Query()); + + var expectedResult = entities.Where( + x => x.IsActive && types.Contains(x.Type) + ); + + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void Query_Status_FiltersByStatus() + { + var size = this.random.Next(10, 100); + var entities = this.transactionBuilder.Generate(size); + + var status = new TransactionStatus[1] + { + TransactionStatus.Committed + }; + var transactionQuery = new TransactionQuery() + { + Status = status + }; + + var result = entities.Where(transactionQuery.Query()); + + var expectedResult = entities.Where( + x => x.IsActive && status.Contains(x.Status) + ); + + Assert.AreEqual(expectedResult, result); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs index e93ef4c..f8b5727 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs @@ -10,11 +10,9 @@ public class AccountEntity : BaseEntity public string Name { get; set; } [Column("description", TypeName = "varchar(500)")] public string Description { get; set; } - [Column("currency", TypeName = "varchar(50)")] - public string Currency { get; set; } [Column("active")] public bool IsActive { get; set; } - public ICollection Transactions { get; set; } + public ICollection Balances { get; set; } } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs new file mode 100644 index 0000000..c46abe4 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; + +namespace FinancialHub.Domain.Entities +{ + [Table("balances")] + public class BalanceEntity : BaseEntity + { + [Column("name",TypeName = "varchar(200)")] + public string Name { get; set; } + [Column("currency",TypeName = "varchar(50)")] + public string Currency { get; set; } + [Column("amount", TypeName = "money")] + public decimal Amount { get; set; } + [Column("active")] + public bool IsActive { get; set; } + + [Column("account_id")] + public Guid AccountId { get; set; } + public AccountEntity Account { get; set; } + + + public ICollection Transactions { get; set; } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs b/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs index 0ac7f5f..d7bf237 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs @@ -18,9 +18,9 @@ public class TransactionEntity : BaseEntity [Column("finish_date")] public DateTimeOffset FinishDate { get; set; } - [Column("account_id")] - public Guid AccountId { get; set; } - public AccountEntity Account { get; set; } + [Column("balance_id")] + public Guid BalanceId { get; set; } + public BalanceEntity Balance { get; set; } [Column("category_id")] [ForeignKey("category_id")] diff --git a/api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs b/api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs index 23483c6..a24600a 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs @@ -11,39 +11,7 @@ public class TransactionFilter public TransactionType[] Types { get; set; } public TransactionStatus[] Status { get; set; } - //TODO: get a better way to add/get array queries public Guid[] Accounts { get; set; } public Guid[] Categories { get; set; } - - //public string Accounts { get; set; } - //public string Categories { get; set; } - - //public Guid[] AccountsIds - //{ - // get - // { - // return this.GetIds(Accounts); - // } - //} - //public Guid[] CategoriesId - //{ - // get - // { - // return this.GetIds(Categories); - // } - //} - - //public Guid[] GetIds(string value) - //{ - // var arr = value?.Split(',') ?? Array.Empty(); - // var res = new Guid[arr.Length]; - - // for (var i = 0; i < arr.Length; i++) - // { - // res[i] = new Guid(arr[i]); - // } - - // return res; - //} } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj b/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj index 4f9a474..7f771d4 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj +++ b/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj @@ -8,4 +8,19 @@ + + + True + True + FinancialHubConcepts.resx + + + + + + PublicResXFileCodeGenerator + FinancialHubConcepts.Designer.cs + + + diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs new file mode 100644 index 0000000..d005b67 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs @@ -0,0 +1,12 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Enums; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Domain.Interfaces.Repositories +{ + public interface IBalancesRepository : IBaseRepository + { + Task ChangeAmountAsync(Guid balanceId,decimal value, TransactionType transactionType, bool removed = false); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs new file mode 100644 index 0000000..21cc0c6 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; + +namespace FinancialHub.Domain.Interfaces.Services +{ + public interface IAccountBalanceService + { + Task>> GetBalancesByAccountAsync(Guid accountId); + Task> CreateAsync(AccountModel account); + Task> DeleteAsync(Guid accountId); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs new file mode 100644 index 0000000..fee7ffb --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; + +namespace FinancialHub.Domain.Interfaces.Services +{ + public interface IBalancesService + { + Task> GetByIdAsync(Guid id); + + Task>> GetAllByAccountAsync(Guid accountId); + + Task> CreateAsync(BalanceModel balance); + + Task> UpdateAsync(Guid id, BalanceModel balance); + + Task> DeleteAsync(Guid id); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs index 9136a7d..b3c2c12 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs @@ -11,9 +11,11 @@ public interface ITransactionsService { Task>> GetAllByUserAsync(string userId, TransactionFilter filter); - Task> CreateAsync(TransactionModel account); + Task> GetByIdAsync(Guid id); - Task> UpdateAsync(Guid id, TransactionModel account); + Task> CreateAsync(TransactionModel transaction); + + Task> UpdateAsync(Guid id, TransactionModel transaction); Task> DeleteAsync(Guid id); } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs b/api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs index 6720017..2571b29 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs @@ -6,7 +6,6 @@ public class AccountModel : BaseModel { public string Name { get; set; } public string Description { get; set; } - public string Currency { get; set; } public bool IsActive { get; set; } } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs b/api/src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs new file mode 100644 index 0000000..44daa90 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs @@ -0,0 +1,15 @@ +using FinancialHub.Domain.Model; +using System; + +namespace FinancialHub.Domain.Models +{ + public class BalanceModel : BaseModel + { + public string Name { get; set; } + public string Currency { get; set; } + public decimal Amount { get; set; } + public Guid AccountId { get; set; } + public AccountModel Account { get; set; } + public bool IsActive { get; set; } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs b/api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs index 7c47c33..f2df90c 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs @@ -1,6 +1,7 @@ using FinancialHub.Domain.Enums; using FinancialHub.Domain.Model; using System; +using System.Text.Json.Serialization; namespace FinancialHub.Domain.Models { @@ -12,8 +13,8 @@ public class TransactionModel : BaseModel public DateTimeOffset TargetDate { get; set; } public DateTimeOffset FinishDate { get; set; } - public Guid AccountId { get; set; } - public AccountModel Account { get; set; } + public Guid BalanceId { get; set; } + public BalanceModel Balance { get; set; } public Guid CategoryId { get; set; } public CategoryModel Category { get; set; } @@ -22,5 +23,8 @@ public class TransactionModel : BaseModel public TransactionStatus Status { get; set; } public TransactionType Type { get ; set ;} + + [JsonIgnore] + public bool IsPaid => this.IsActive && this.Status == TransactionStatus.Committed; } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs b/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs index c2760bb..4205751 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs @@ -1,28 +1,22 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Enums; -using System; -using System.Collections.Generic; +using System; using System.Linq; -using System.Linq.Expressions; +using System.Collections.Generic; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Enums; namespace FinancialHub.Domain.Queries { public class TransactionQuery { - [Obsolete("Not Used yet")] - public string UserId { get; set; } public DateTime? StartDate { get; set; } public DateTime? EndDate { get; set; } - public Guid[] Accounts { get; set; } + public Guid[] Balances { get; set; } public Guid[] Categories { get; set; } public TransactionType[] Types { get; set; } public TransactionStatus[] Status { get; set; } - //public Guid[] AccountsIds { get; set; } - //public Guid[] CategoriesIds { get; set; } - public Func Query() { //TODO: compare performance @@ -31,108 +25,42 @@ public Func Query() private Func QueryFuncs() { - var queries = new List>(); - - queries.Add((ent) => ent.IsActive); + var queries = new List> + { + (ent) => ent.IsActive + }; if (StartDate != null) { if (EndDate == null) { StartDate = new DateTime(StartDate.Value.Year, StartDate.Value.Month,1); - EndDate = StartDate.Value.AddMonths(2).AddSeconds(-1); + EndDate = StartDate.Value.AddMonths(1).AddSeconds(-1); } queries.Add((ent) => ent.TargetDate >= StartDate && ent.TargetDate <= EndDate); } - if (Accounts.Length > 0) + if (Balances?.Length > 0) { - queries.Add((ent) => Accounts.Contains(ent.AccountId)); + queries.Add((ent) => Balances.Contains(ent.BalanceId)); } - if (Categories.Length > 0) + if (Categories?.Length > 0) { queries.Add((ent) => Categories.Contains(ent.CategoryId)); } - if (Types.Length > 0) + if (Types?.Length > 0) { queries.Add((ent) => Types.Contains(ent.Type)); } - if (Status.Length > 0) + if (Status?.Length > 0) { queries.Add((ent) => Status.Contains(ent.Status)); } return (ent) => queries.All(query => query(ent)); } - - [Obsolete("Not working : no accounts/types/status filters")] - private Func QueryFunc() - { - Func query; - - if (EndDate == null) - { - query = (ent) => ent.TargetDate == StartDate; - } - else - { - query = (ent) => ent.TargetDate >= StartDate && ent.TargetDate <= EndDate; - } - - //TODO: idk how to add it - if (Accounts.Length > 0) - { - - } - - if (Categories.Length > 0) - { - - } - - return query; - } - - [Obsolete("Not working : exception at Expression.And")] - private Func QueryExpression() - { - //TODO: do a better filter system (IQueryable Results on repository) - var expressions = new List>>(); - expressions.Add((ent) => ent.IsActive); - - if (EndDate == null) - { - expressions.Add((ent) => ent.TargetDate == StartDate); - } - else - { - expressions.Add((ent) => ent.TargetDate >= StartDate && ent.TargetDate <= EndDate); - } - - if (Accounts.Length > 0) - { - expressions.Add((ent) => Accounts.Contains(ent.AccountId)); - } - - if (Categories.Length > 0) - { - expressions.Add((ent) => Accounts.Contains(ent.CategoryId)); - } - - Expression expression = expressions.First(); - - foreach (var exp in expressions.Skip(1)) - { - expression = Expression.And(expression, exp); - } - - var parameter = Expression.Parameter(typeof(TransactionEntity), "ent"); - var query = Expression.Lambda>(expression, parameter); - - return query.Compile(); - } } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs b/api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs new file mode 100644 index 0000000..5fc913e --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// O código foi gerado por uma ferramenta. +// Versão de Tempo de Execução:4.0.30319.42000 +// +// As alterações ao arquivo poderão causar comportamento incorreto e serão perdidas se +// o código for gerado novamente. +// +//------------------------------------------------------------------------------ + +namespace FinancialHub.Domain.Resources { + using System; + + + /// + /// Uma classe de recurso de tipo de alta segurança, para pesquisar cadeias de caracteres localizadas etc. + /// + // Essa classe foi gerada automaticamente pela classe StronglyTypedResourceBuilder + // através de uma ferramenta como ResGen ou Visual Studio. + // Para adicionar ou remover um associado, edite o arquivo .ResX e execute ResGen novamente + // com a opção /str, ou recrie o projeto do VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class FinancialHubConcepts { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal FinancialHubConcepts() { + } + + /// + /// Retorna a instância de ResourceManager armazenada em cache usada por essa classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.Domain.Resources.FinancialHubConcepts", typeof(FinancialHubConcepts).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Substitui a propriedade CurrentUICulture do thread atual para todas as + /// pesquisas de recursos que usam essa classe de recurso de tipo de alta segurança. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a Account. + /// + public static string Account { + get { + return ResourceManager.GetString("Account", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a Category. + /// + public static string Category { + get { + return ResourceManager.GetString("Category", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a Transaction. + /// + public static string Transaction { + get { + return ResourceManager.GetString("Transaction", resourceCulture); + } + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx b/api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx new file mode 100644 index 0000000..aceeed7 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Account + + + Category + + + Transaction + + \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs b/api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs index b52668d..c7c44db 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs +++ b/api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs @@ -24,4 +24,20 @@ public static implicit operator ServiceResult(ServiceError error) return new ServiceResult(error: error); } } + + public class ServiceResult + { + public bool HasError => this.Error != null; + public ServiceError Error { get; protected set; } + + public ServiceResult(ServiceError error = null) + { + this.Error = error; + } + + public static implicit operator ServiceResult(ServiceError error) + { + return new ServiceResult(error: error); + } + } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs index a3e5833..1193ac1 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; using FinancialHub.Domain.Entities; using FinancialHub.Infra.Data.Repositories; using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs new file mode 100644 index 0000000..3b183f9 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs @@ -0,0 +1,98 @@ +using FinancialHub.Domain.Enums; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories +{ + public partial class BalancesRepositoryTests + { + [Test] + public async Task AddAmountAsync_EarnTransaction_AddsAmount() + { + var balanceId = Guid.NewGuid(); + var balance = this.balanceBuilder + .WithAmount(0) + .WithId(balanceId) + .Generate(); + await this.InsertData(balance); + this.context.ChangeTracker.Clear(); + + var amount = this.random.Next(10,1000); + var entity = this.transactionBuilder + .WithType(TransactionType.Earn) + .WithBalanceId(balanceId) + .WithAmount(amount) + .Generate(); + + var balanceResult = await this.balanceRepository.ChangeAmountAsync(balanceId,amount, TransactionType.Earn); + Assert.AreEqual(balance.Amount + entity.Amount, balanceResult.Amount); + } + + [Test] + public async Task AddAmountAsync_ExpenseTransaction_RemovesAmount() + { + var balanceId = Guid.NewGuid(); + var balance = this.balanceBuilder + .WithAmount(0) + .WithId(balanceId) + .Generate(); + await this.InsertData(balance); + this.context.ChangeTracker.Clear(); + + var amount = this.random.Next(10, 1000); + var entity = this.transactionBuilder + .WithType(TransactionType.Expense) + .WithBalanceId(balanceId) + .WithAmount(amount) + .Generate(); + + var balanceResult = await this.balanceRepository.ChangeAmountAsync(balanceId, amount, TransactionType.Expense); + Assert.AreEqual(balance.Amount - entity.Amount, balanceResult.Amount); + } + + [Test] + public async Task RemoveAmountAsync_EarnTransaction_RemovesAmount() + { + var balanceId = Guid.NewGuid(); + var balance = this.balanceBuilder + .WithAmount(0) + .WithId(balanceId) + .Generate(); + await this.InsertData(balance); + this.context.ChangeTracker.Clear(); + + var amount = this.random.Next(10, 1000); + var entity = this.transactionBuilder + .WithType(TransactionType.Earn) + .WithBalanceId(balanceId) + .WithAmount(amount) + .Generate(); + + var balanceResult = await this.balanceRepository.ChangeAmountAsync(balanceId, amount, TransactionType.Earn, true); + Assert.AreEqual(balance.Amount - entity.Amount, balanceResult.Amount); + } + + [Test] + public async Task RemoveAmountAsync_ExpenseTransaction_AddsAmount() + { + var balanceId = Guid.NewGuid(); + var balance = this.balanceBuilder + .WithAmount(0) + .WithId(balanceId) + .Generate(); + await this.InsertData(balance); + this.context.ChangeTracker.Clear(); + + var amount = this.random.Next(10, 1000); + var entity = this.transactionBuilder + .WithType(TransactionType.Expense) + .WithBalanceId(balanceId) + .WithAmount(amount) + .Generate(); + + var balanceResult = await this.balanceRepository.ChangeAmountAsync(balanceId, amount, TransactionType.Expense, true); + Assert.AreEqual(balance.Amount + entity.Amount, balanceResult.Amount); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs new file mode 100644 index 0000000..f27462b --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs @@ -0,0 +1,24 @@ +using FinancialHub.Domain.Entities; +using NUnit.Framework; +using System.Linq; +using System.Threading.Tasks; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories +{ + public partial class BalancesRepositoryTests + { + [Test] + public async Task CreateAsync_ShouldCreatesBalanceWithZeroAmount() + { + var item = this.GenerateObject(); + + var createdItem = await this.repository.CreateAsync(item); + + this.AssertCreated(createdItem); + Assert.Zero(createdItem.Amount); + + var databaseItem = context.Set().FirstOrDefault(x => x.Id == createdItem.Id); + Assert.Zero(databaseItem.Amount); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs new file mode 100644 index 0000000..9ad9e14 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs @@ -0,0 +1,27 @@ +using NUnit.Framework; +using FinancialHub.Domain.Entities; +using FinancialHub.Infra.Data.Repositories; +using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Domain.Tests.Builders.Entities; + +namespace FinancialHub.Infra.Data.NUnitTests.Repositories +{ + public partial class BalancesRepositoryTests : BaseRepositoryTests + { + public TransactionEntityBuilder transactionBuilder; + public BalancesRepository balanceRepository; + public BalanceEntityBuilder balanceBuilder; + + [SetUp] + protected override void Setup() + { + base.Setup(); + this.balanceRepository = new BalancesRepository(this.context); + this.balanceBuilder = new BalanceEntityBuilder(); + this.transactionBuilder = new TransactionEntityBuilder(); + + this.repository = this.balanceRepository; + this.builder = this.balanceBuilder; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs index 5926af0..b08ad99 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs @@ -16,6 +16,7 @@ public abstract partial class BaseRepositoryTests { protected BaseEntityBuilder builder; protected FinancialHubContext context; + protected Random random; protected IBaseRepository repository; @@ -37,6 +38,7 @@ protected FinancialHubContext GetContext() [SetUp] protected virtual void Setup() { + this.random = new Random(); this.context = this.GetContext(); this.context.Database.EnsureCreated(); } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs index 50788b3..51853f8 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs @@ -14,6 +14,7 @@ public virtual async Task DeleteAsync_ExistingItem_AffectsOneRow() { var items = this.GenerateData(); await this.InsertData(items); + this.context.ChangeTracker.Clear(); var affectedRows = await this.repository.DeleteAsync(items.First().Id.Value); Assert.AreEqual(1,affectedRows); @@ -26,6 +27,7 @@ public virtual async Task DeleteAsync_NonExistingItem_AffectsNothing() { var items = this.GenerateData(); await this.InsertData(items); + this.context.ChangeTracker.Clear(); var affectedRows = await this.repository.DeleteAsync(new Guid()); Assert.AreEqual(0, affectedRows); diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs index 9ab06be..e85c3a2 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs @@ -13,20 +13,20 @@ protected override void AssertCreated(TransactionEntity createdItem) { base.AssertCreated(createdItem); - Assert.IsNotNull(createdItem.Account); + Assert.IsNotNull(createdItem.BalanceId); Assert.IsNotNull(createdItem.Category); - Assert.AreEqual(createdItem.AccountId, createdItem.Account.Id); + Assert.AreEqual(createdItem.BalanceId, createdItem.Balance.Id); Assert.AreEqual(createdItem.CategoryId, createdItem.Category.Id); } [Test] - [TestCase(TestName = "Create new Transaction with valid Category and Account", Category = "Create")] + [TestCase(TestName = "Create new Transaction with valid Category and Balance", Category = "Create")] public override async Task CreateAsync_ValidItem_AddsOneRow(TransactionEntity item = null) { var entity = this.GenerateObject(); entity.Category = await this.InsertData(entity.Category); - entity.Account = await this.InsertData(entity.Account); + entity.Balance = await this.InsertData(entity.Balance); await base.CreateAsync_ValidItem_AddsOneRow(entity); } @@ -37,10 +37,10 @@ public async override Task CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferen { var entity = this.GenerateObject(); - var generatedAccount = this.GenerateAccount(entity.AccountId); + var generatedBalance = this.GenerateBalance(entity.BalanceId); var generatedCategory = this.GenerateCategory(entity.CategoryId); - await this.InsertData(generatedAccount); + await this.InsertData(generatedBalance); await this.InsertData(generatedCategory); await base.CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(entity); @@ -53,20 +53,20 @@ public override async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithThe var id = Guid.NewGuid(); item = this.GenerateObject(id); - //INSERTS ACCOUNT AND CATEGORY - var generatedAccount = this.GenerateAccount(item.AccountId); + //INSERTS BALANCE AND CATEGORY + var generatedBalance = this.GenerateBalance(item.BalanceId); var generatedCategory = this.GenerateCategory(item.CategoryId); - await this.InsertData(generatedAccount); + await this.InsertData(generatedBalance); await this.InsertData(generatedCategory); item.Category = null; - item.Account = null; + item.Balance = null; item = await this.InsertData(item); var newItem = this.GenerateObject(id); newItem.CategoryId = generatedCategory.Id.GetValueOrDefault(); - newItem.AccountId = generatedAccount.Id.GetValueOrDefault(); + newItem.BalanceId = generatedBalance.Id.GetValueOrDefault(); var result = await this.repository.CreateAsync(newItem); @@ -76,7 +76,7 @@ public override async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithThe } [Test] - [TestCase(TestName = "Create new Transaction without Updates/Creates Account or Category", Category = "Create")] + [TestCase(TestName = "Create new Transaction without Updates/Creates Balance or Category", Category = "Create")] public async Task CreateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() { #warning this test is too complex @@ -85,14 +85,14 @@ public async Task CreateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() var entity = this.GenerateObject(); //INSERTS ACCOUNT AND CATEGORY - var oldAccount = this.GenerateAccount(entity.AccountId); + var oldBalance = this.GenerateBalance(entity.BalanceId); var oldCategory = this.GenerateCategory(entity.CategoryId); - await this.InsertData(oldAccount); + await this.InsertData(oldBalance); await this.InsertData(oldCategory); - //CHANGES TRANSACTION'S CATEGORY AND ACCOUNT - entity.Account.Name = Guid.NewGuid().ToString(); + //CHANGES TRANSACTION'S CATEGORY AND BALANCE + entity.Balance.Name = Guid.NewGuid().ToString(); entity.Category.Name = Guid.NewGuid().ToString(); /***** ACT *****/ @@ -104,28 +104,28 @@ public async Task CreateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() this.AssertCreated(result); //SHOULD NOT CREATE ACCOUNTS OR CATEGORIES - Assert.AreEqual(1,this.context.Accounts.Count()); + Assert.AreEqual(1,this.context.Balances.Count()); Assert.AreEqual(1,this.context.Categories.Count()); - var account = this.context.Accounts.FirstOrDefault(x => x.Id == entity.AccountId); + var account = this.context.Balances.FirstOrDefault(x => x.Id == entity.BalanceId); var category = this.context.Categories.FirstOrDefault(x => x.Id == entity.CategoryId); //SHOULD NOT UPDATE DATABASE - Assert.AreEqual(oldAccount, account); + Assert.AreEqual(oldBalance, account); Assert.AreEqual(oldCategory, category); //SHOULD NOT RETURN THE WRONG ITEM - Assert.AreEqual(oldAccount, result.Account); + Assert.AreEqual(oldBalance, result.Balance); Assert.AreEqual(oldCategory, result.Category); } [Test] - [TestCase(TestName = "Create new Transaction with invalid Account", Category = "Create")] - public async Task CreateAsync_InvalidAccountId_ThrowsDbUpdateException() + [TestCase(TestName = "Create new Transaction with invalid Balance", Category = "Create")] + public async Task CreateAsync_InvalidBalanceId_ThrowsDbUpdateException() { var entity = this.GenerateObject(); - await this.InsertData(this.GenerateAccount()); + await this.InsertData(this.GenerateBalance()); entity.Category = await this.InsertData(entity.Category); entity.CategoryId = entity.Category.Id.GetValueOrDefault(); @@ -133,7 +133,7 @@ public async Task CreateAsync_InvalidAccountId_ThrowsDbUpdateException() Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); Assert.IsEmpty(this.context.Transactions); - Assert.AreEqual(1, this.context.Accounts.Count()); + Assert.AreEqual(1, this.context.Balances.Count()); Assert.AreEqual(1, this.context.Categories.Count()); } @@ -143,25 +143,25 @@ public async Task CreateAsync_InvalidCategoryId_ThrowsDbUpdateException() { var entity = this.GenerateObject(); - await this.InsertData(entity.Account); + await this.InsertData(entity.Balance); await this.InsertData(this.GenerateCategory()); Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); Assert.IsEmpty(this.context.Transactions); - Assert.AreEqual(1, this.context.Accounts.Count()); + Assert.AreEqual(1, this.context.Balances.Count()); Assert.AreEqual(1, this.context.Categories.Count()); } [Test] - [TestCase(TestName = "Create new Transaction with no Account", Category = "Create")] - public async Task CreateAsync_NoAccount_ThrowsDbUpdateException() + [TestCase(TestName = "Create new Transaction with no Balance", Category = "Create")] + public async Task CreateAsync_NoBalance_ThrowsDbUpdateException() { var entity = this.GenerateObject(); await this.InsertData(entity.Category); - entity.Account = null; + entity.Balance = null; Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); @@ -174,7 +174,7 @@ public async Task CreateAsync_NoCategory_ThrowsDbUpdateException() { var entity = this.GenerateObject(); - await this.InsertData(entity.Account); + await this.InsertData(entity.Balance); entity.Category = null; diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs index 9b3c797..0823c01 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs @@ -1,15 +1,15 @@ -using FinancialHub.Domain.Entities; +using System; +using NUnit.Framework; +using FinancialHub.Domain.Entities; +using FinancialHub.Infra.Data.Repositories; using FinancialHub.Domain.Tests.Builders.Entities; using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; -using FinancialHub.Infra.Data.Repositories; -using NUnit.Framework; -using System; namespace FinancialHub.Infra.Data.NUnitTests.Repositories { public partial class TransactionsRepositoryTests : BaseRepositoryTests { - private AccountEntityBuilder accountEntityBuilder; + private BalanceEntityBuilder balanceEntityBuilder; private CategoryEntityBuilder categoryEntityBuilder; [SetUp] @@ -18,7 +18,7 @@ protected override void Setup() base.Setup(); this.repository = new TransactionsRepository(this.context); - this.accountEntityBuilder = new AccountEntityBuilder(); + this.balanceEntityBuilder = new BalanceEntityBuilder(); this.categoryEntityBuilder = new CategoryEntityBuilder(); this.builder = new TransactionEntityBuilder(); @@ -27,21 +27,21 @@ protected override void Setup() protected TransactionEntity GenerateTransaction(Guid? id = null,Guid? accountId = null, Guid? categoryId = null) { var category = this.GenerateCategory(categoryId); - var account = this.GenerateAccount(accountId); + var balance = this.GenerateBalance(accountId); var build = (TransactionEntityBuilder)this.builder; if (id == null) { return build - .WithAccount(account) + .WithBalance(balance) .WithCategory(category) .Generate(); } else { return build - .WithAccount(account) + .WithBalance(balance) .WithCategory(category) .WithId(id.Value) .Generate(); @@ -60,15 +60,15 @@ protected CategoryEntity GenerateCategory(Guid? id = null) } } - protected AccountEntity GenerateAccount(Guid? id = null) + protected BalanceEntity GenerateBalance(Guid? id = null) { if (id == null) { - return this.accountEntityBuilder.Generate(); + return this.balanceEntityBuilder.Generate(); } else { - return this.accountEntityBuilder.WithId(id.Value).Generate(); + return this.balanceEntityBuilder.WithId(id.Value).Generate(); } } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs index 0480651..1d765eb 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs @@ -6,14 +6,14 @@ namespace FinancialHub.Infra.Data.NUnitTests.Repositories public partial class TransactionsRepositoryTests { [Test] - [TestCase(TestName = "Delete a Transaction without delete Category or Account", Category = "Delete")] public async Task DeleteAsync_ValidItemWithNestChild_DoesNotDeleteNestChild() { var entity = this.GenerateObject(); - await this.InsertData(entity.Account); + await this.InsertData(entity.Balance); await this.InsertData(entity.Category); await this.InsertData(entity); + this.context.ChangeTracker.Clear(); var result = await this.repository.DeleteAsync(entity.Id.Value); diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs index 3d55f77..9c7c0c5 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs @@ -11,7 +11,7 @@ public partial class TransactionsRepositoryTests { protected async Task InsertTransaction(TransactionEntity entity) { - await this.InsertData(entity.Account); + await this.InsertData(entity.Balance); await this.InsertData(entity.Category); await this.InsertData(entity); @@ -19,48 +19,48 @@ protected async Task InsertTransaction(TransactionEntity entity) } [Test] - [TestCase(TestName = "Update Transaction but no Accounts or Category", Category = "Update")] + [TestCase(TestName = "Update Transaction but no Balances or Category", Category = "Update")] public async Task UpdateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() { var entity = this.GenerateObject(); await this.InsertTransaction(entity); - var changedEntity = this.GenerateTransaction(entity.Id, entity.AccountId, entity.CategoryId); + var changedEntity = this.GenerateTransaction(entity.Id, entity.BalanceId, entity.CategoryId); var result = await this.repository.UpdateAsync(changedEntity); this.AssertCreated(result); //SHOULD NOT CREATE - Assert.AreEqual(1, this.context.Accounts.Local.Count); + Assert.AreEqual(1, this.context.Balances.Local.Count); Assert.AreEqual(1, this.context.Categories.Local.Count); - var account = this.context.Accounts.FirstOrDefault(x => x.Id == changedEntity.AccountId); + var account = this.context.Balances.FirstOrDefault(x => x.Id == changedEntity.BalanceId); var category = this.context.Categories.FirstOrDefault(x => x.Id == changedEntity.CategoryId); //SHOULD NOT UPDATE DATABASE - Assert.AreEqual(account, result.Account); + Assert.AreEqual(account, result.Balance); Assert.AreEqual(category, result.Category); } [Test] - [TestCase(TestName = "Update Transaction changing Account", Category = "Update")] - public async Task UpdateAsync_ChangeAccountId_ChangesAccount() + [TestCase(TestName = "Update Transaction changing Balance", Category = "Update")] + public async Task UpdateAsync_ChangeBalanceId_ChangesBalance() { var entity = this.GenerateObject(); await this.InsertTransaction(entity); - var newAccount = this.GenerateAccount(); - await this.InsertData(newAccount); + var newBalance = this.GenerateBalance(); + await this.InsertData(newBalance); - entity.AccountId = (Guid)newAccount.Id; + entity.BalanceId = (Guid)newBalance.Id; var result = await this.repository.CreateAsync(entity); this.AssertCreated(result); - Assert.AreEqual(newAccount.Id, result.AccountId); - Assert.AreEqual(newAccount, result.Account); + Assert.AreEqual(newBalance.Id, result.BalanceId); + Assert.AreEqual(newBalance, result.Balance); } [Test] @@ -84,8 +84,8 @@ public async Task UpdateAsync_ChangeCategoryId_ChangesCategory() } [Test] - [TestCase(TestName = "Update Transaction with invalid Account", Category = "Update")] - public async Task UpdateAsync_InvalidAccountId_ThrowsDbUpdateException() + [TestCase(TestName = "Update Transaction with invalid Balance", Category = "Update")] + public async Task UpdateAsync_InvalidBalanceId_ThrowsDbUpdateException() { var entity = this.GenerateObject(); var oldCategoryId = entity.Category.Id; diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs index 2dc2b79..a2896fc 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs @@ -17,12 +17,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) table.HasKey(t => t.Id); table.HasIndex(t => t.Id).IsUnique(true); - table.HasOne(x => x.Account) + table.HasOne(x => x.Balance) .WithMany(x => x.Transactions) - .HasForeignKey(x => x.AccountId) + .HasForeignKey(x => x.BalanceId) .HasPrincipalKey(x => x.Id) .IsRequired(true); - table.Navigation(t => t.Account).AutoInclude(); + table.Navigation(t => t.Balance).AutoInclude(); table.HasOne(x => x.Category) .WithMany(x => x.Transactions) @@ -31,11 +31,26 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .IsRequired(true); table.Navigation(t => t.Category).AutoInclude(); }); + + modelBuilder.Entity(table => + { + table.HasKey(t => t.Id); + table.HasIndex(t => t.Id).IsUnique(true); + + table.HasOne(x => x.Account) + .WithMany(x => x.Balances) + .HasForeignKey(x => x.AccountId) + .HasPrincipalKey(x => x.Id) + .IsRequired(true); + table.Navigation(t => t.Account).AutoInclude(); + }); + base.OnModelCreating(modelBuilder); } public DbSet Accounts { get; set; } public DbSet Transactions { get; set; } public DbSet Categories { get; set; } + public DbSet Balances { get; set; } } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs new file mode 100644 index 0000000..f74dea8 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs @@ -0,0 +1,57 @@ +using System; +using System.Threading.Tasks; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Infra.Data.Contexts; + +namespace FinancialHub.Infra.Data.Repositories +{ + public class BalancesRepository : BaseRepository, IBalancesRepository + { + public BalancesRepository(FinancialHubContext context) : base(context) + { + } + + public async override Task UpdateAsync(BalanceEntity obj) + { + obj.UpdateTime = DateTimeOffset.Now; + + var result = this.context.Update(obj); + this.context.Entry(result.Entity).Property(x => x.Amount).IsModified = false; + this.context.Entry(result.Entity).Property(x => x.CreationTime).IsModified = false; + + await context.SaveChangesAsync(); + await result.ReloadAsync(); + + return result.Entity; + } + + public async override Task CreateAsync(BalanceEntity obj) + { + obj.Amount = 0; + return await base.CreateAsync(obj); + } + + public async Task ChangeAmountAsync(Guid balanceId, decimal value, TransactionType transactionType, bool removed = false) + { + var balance = await this.GetByIdAsync(balanceId); + + if (transactionType == TransactionType.Earn) + { + balance.Amount = !removed ? balance.Amount + value: balance.Amount - value; + } + else + { + balance.Amount = removed ? balance.Amount + value : balance.Amount - value; + } + + balance.UpdateTime = DateTimeOffset.Now; + context.Update(balance); + await context.SaveChangesAsync(); + context.ChangeTracker.Clear(); + + return balance; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs index d409f6d..39bb39d 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs @@ -32,7 +32,7 @@ public virtual async Task CreateAsync(T obj) public virtual async Task DeleteAsync(Guid id) { - var entity = context.Set().FirstOrDefault(x => x.Id == id); + var entity = await this.GetByIdAsync(id); if(entity != null) { @@ -48,8 +48,12 @@ public virtual async Task DeleteAsync(Guid id) public virtual async Task UpdateAsync(T obj) { obj.UpdateTime = DateTimeOffset.Now; + var res = context.Set().Update(obj); + this.context.Entry(res.Entity).Property(x => x.CreationTime).IsModified = false; + await context.SaveChangesAsync(); + return res.Entity; } @@ -65,7 +69,7 @@ public virtual async Task> GetAsync(Func predicate) public virtual async Task GetByIdAsync(Guid id) { - return await context.Set().FirstOrDefaultAsync(x => x.Id == id); + return await context.Set().AsNoTracking().FirstOrDefaultAsync(x => x.Id == id); } } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs index a19ae0f..23b51c2 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs @@ -21,14 +21,14 @@ public override async Task CreateAsync(TransactionEntity obj) } obj.Category = null; - obj.Account = null; + obj.Balance = null; return await base.CreateAsync(obj); } public override async Task UpdateAsync(TransactionEntity obj) { obj.Category = null; - obj.Account = null; + obj.Balance = null; return await base.UpdateAsync(obj); } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs new file mode 100644 index 0000000..a2fa7f6 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs @@ -0,0 +1,236 @@ +// +using System; +using FinancialHub.Infra.Data.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FinancialHub.Infra.Migrations.Migrations +{ + [DbContext(typeof(FinancialHubContext))] + [Migration("20220520163358_add-balance")] + partial class addbalance + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("accounts"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("AccountId") + .HasColumnType("uniqueidentifier") + .HasColumnName("account_id"); + + b.Property("Amount") + .HasColumnType("money") + .HasColumnName("amount"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Currency") + .HasColumnType("varchar(50)") + .HasColumnName("currency"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.ToTable("balances"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("categories"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("AccountId") + .HasColumnType("uniqueidentifier") + .HasColumnName("account_id"); + + b.Property("Amount") + .HasColumnType("money") + .HasColumnName("amount"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier") + .HasColumnName("category_id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("FinishDate") + .HasColumnType("datetimeoffset") + .HasColumnName("finish_date"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Status") + .HasColumnType("int") + .HasColumnName("status"); + + b.Property("TargetDate") + .HasColumnType("datetimeoffset") + .HasColumnName("target_date"); + + b.Property("Type") + .HasColumnType("int") + .HasColumnName("type"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => + { + b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") + .WithMany("Balances") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") + .WithMany("Transactions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") + .WithMany("Transactions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Navigation("Balances"); + + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs new file mode 100644 index 0000000..1a29a44 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs @@ -0,0 +1,57 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FinancialHub.Infra.Migrations.Migrations +{ + public partial class addbalance : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "currency", + table: "accounts"); + + migrationBuilder.CreateTable( + name: "balances", + columns: table => new + { + id = table.Column(type: "uniqueidentifier", nullable: false), + name = table.Column(type: "varchar(200)", nullable: true), + currency = table.Column(type: "varchar(50)", nullable: true), + amount = table.Column(type: "money", nullable: false), + account_id = table.Column(type: "uniqueidentifier", nullable: false), + creation_time = table.Column(type: "datetimeoffset", nullable: true), + update_time = table.Column(type: "datetimeoffset", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_balances", x => x.id); + table.ForeignKey( + name: "FK_balances_accounts_account_id", + column: x => x.account_id, + principalTable: "accounts", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_balances_account_id", + table: "balances", + column: "account_id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "balances"); + + migrationBuilder.AddColumn( + name: "currency", + table: "accounts", + type: "varchar(50)", + nullable: true); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs new file mode 100644 index 0000000..43eee41 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs @@ -0,0 +1,242 @@ +// +using System; +using FinancialHub.Infra.Data.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FinancialHub.Infra.Migrations.Migrations +{ + [DbContext(typeof(FinancialHubContext))] + [Migration("20220520215117_add-balance-to-transaction")] + partial class addbalancetotransaction + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("accounts"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("AccountId") + .HasColumnType("uniqueidentifier") + .HasColumnName("account_id"); + + b.Property("Amount") + .HasColumnType("money") + .HasColumnName("amount"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Currency") + .HasColumnType("varchar(50)") + .HasColumnName("currency"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("balances"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("categories"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("Amount") + .HasColumnType("money") + .HasColumnName("amount"); + + b.Property("BalanceId") + .HasColumnType("uniqueidentifier") + .HasColumnName("balance_id"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier") + .HasColumnName("category_id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("FinishDate") + .HasColumnType("datetimeoffset") + .HasColumnName("finish_date"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Status") + .HasColumnType("int") + .HasColumnName("status"); + + b.Property("TargetDate") + .HasColumnType("datetimeoffset") + .HasColumnName("target_date"); + + b.Property("Type") + .HasColumnType("int") + .HasColumnName("type"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.HasIndex("BalanceId"); + + b.HasIndex("CategoryId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => + { + b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") + .WithMany("Balances") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.HasOne("FinancialHub.Domain.Entities.BalanceEntity", "Balance") + .WithMany("Transactions") + .HasForeignKey("BalanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") + .WithMany("Transactions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Balance"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Navigation("Balances"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => + { + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs new file mode 100644 index 0000000..086ef9f --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs @@ -0,0 +1,69 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FinancialHub.Infra.Migrations.Migrations +{ + public partial class addbalancetotransaction : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_transactions_accounts_account_id", + table: "transactions"); + + migrationBuilder.RenameColumn( + name: "account_id", + table: "transactions", + newName: "balance_id"); + + migrationBuilder.RenameIndex( + name: "IX_transactions_account_id", + table: "transactions", + newName: "IX_transactions_balance_id"); + + migrationBuilder.CreateIndex( + name: "IX_balances_id", + table: "balances", + column: "id", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_transactions_balances_balance_id", + table: "transactions", + column: "balance_id", + principalTable: "balances", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_transactions_balances_balance_id", + table: "transactions"); + + migrationBuilder.DropIndex( + name: "IX_balances_id", + table: "balances"); + + migrationBuilder.RenameColumn( + name: "balance_id", + table: "transactions", + newName: "account_id"); + + migrationBuilder.RenameIndex( + name: "IX_transactions_balance_id", + table: "transactions", + newName: "IX_transactions_account_id"); + + migrationBuilder.AddForeignKey( + name: "FK_transactions_accounts_account_id", + table: "transactions", + column: "account_id", + principalTable: "accounts", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs new file mode 100644 index 0000000..fdcafa9 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs @@ -0,0 +1,246 @@ +// +using System; +using FinancialHub.Infra.Data.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FinancialHub.Infra.Migrations.Migrations +{ + [DbContext(typeof(FinancialHubContext))] + [Migration("20220520215501_add-balance-active")] + partial class addbalanceactive + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("accounts"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("AccountId") + .HasColumnType("uniqueidentifier") + .HasColumnName("account_id"); + + b.Property("Amount") + .HasColumnType("money") + .HasColumnName("amount"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Currency") + .HasColumnType("varchar(50)") + .HasColumnName("currency"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("balances"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("categories"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("Amount") + .HasColumnType("money") + .HasColumnName("amount"); + + b.Property("BalanceId") + .HasColumnType("uniqueidentifier") + .HasColumnName("balance_id"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier") + .HasColumnName("category_id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Description") + .HasColumnType("varchar(500)") + .HasColumnName("description"); + + b.Property("FinishDate") + .HasColumnType("datetimeoffset") + .HasColumnName("finish_date"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Status") + .HasColumnType("int") + .HasColumnName("status"); + + b.Property("TargetDate") + .HasColumnType("datetimeoffset") + .HasColumnName("target_date"); + + b.Property("Type") + .HasColumnType("int") + .HasColumnName("type"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.HasIndex("BalanceId"); + + b.HasIndex("CategoryId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => + { + b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") + .WithMany("Balances") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.HasOne("FinancialHub.Domain.Entities.BalanceEntity", "Balance") + .WithMany("Transactions") + .HasForeignKey("BalanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") + .WithMany("Transactions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Balance"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Navigation("Balances"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => + { + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => + { + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs new file mode 100644 index 0000000..3d65793 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FinancialHub.Infra.Migrations.Migrations +{ + public partial class addbalanceactive : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "active", + table: "balances", + type: "bit", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "active", + table: "balances"); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs index 19a736c..97e651b 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs +++ b/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs @@ -33,10 +33,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("datetimeoffset") .HasColumnName("creation_time"); - b.Property("Currency") - .HasColumnType("varchar(50)") - .HasColumnName("currency"); - b.Property("Description") .HasColumnType("varchar(500)") .HasColumnName("description"); @@ -58,6 +54,51 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("accounts"); }); + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("AccountId") + .HasColumnType("uniqueidentifier") + .HasColumnName("account_id"); + + b.Property("Amount") + .HasColumnType("money") + .HasColumnName("amount"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Currency") + .HasColumnType("varchar(50)") + .HasColumnName("currency"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("active"); + + b.Property("Name") + .HasColumnType("varchar(200)") + .HasColumnName("name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("balances"); + }); + modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => { b.Property("Id") @@ -97,14 +138,14 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("uniqueidentifier") .HasColumnName("id"); - b.Property("AccountId") - .HasColumnType("uniqueidentifier") - .HasColumnName("account_id"); - b.Property("Amount") .HasColumnType("money") .HasColumnName("amount"); + b.Property("BalanceId") + .HasColumnType("uniqueidentifier") + .HasColumnName("balance_id"); + b.Property("CategoryId") .HasColumnType("uniqueidentifier") .HasColumnName("category_id"); @@ -143,7 +184,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("AccountId"); + b.HasIndex("BalanceId"); b.HasIndex("CategoryId"); @@ -153,26 +194,42 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("transactions"); }); - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => { b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") - .WithMany("Transactions") + .WithMany("Balances") .HasForeignKey("AccountId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Account"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => + { + b.HasOne("FinancialHub.Domain.Entities.BalanceEntity", "Balance") + .WithMany("Transactions") + .HasForeignKey("BalanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") .WithMany("Transactions") .HasForeignKey("CategoryId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Account"); + b.Navigation("Balance"); b.Navigation("Category"); }); modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => + { + b.Navigation("Balances"); + }); + + modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => { b.Navigation("Transactions"); }); diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs index ac5ef5e..4cff91c 100644 --- a/api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs @@ -1,6 +1,17 @@ using System.Net.Http; using NUnit.Framework; using FinancialHub.IntegrationTests.Setup; +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.Domain.Model; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Tests.Builders.Entities; +using System.Threading.Tasks; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Responses.Errors; +using System; +using System.Net; +using FinancialHub.IntegrationTests.Extensions; +using System.Linq; namespace FinancialHub.IntegrationTests.Base { @@ -11,11 +22,13 @@ public abstract class BaseControllerTests protected HttpClient client => fixture.Client; protected readonly string baseEndpoint; + protected readonly Random random; public BaseControllerTests(FinancialHubApiFixture fixture,string endpoint) { this.fixture = fixture; this.baseEndpoint = endpoint; + this.random = new Random(); } [SetUp] @@ -30,4 +43,158 @@ public virtual void TearDown() this.fixture.ClearData(); } } + + [Obsolete("Not used")] + [TestFixtureSource(typeof(FinancialHubApiFixture))] + public abstract class BaseControllerTests + where T : BaseModel + where Y : BaseEntity + { + protected readonly FinancialHubApiFixture fixture; + protected HttpClient client => fixture.Client; + + protected readonly string baseEndpoint; + protected readonly string name; + + protected BaseModelBuilder modelBuilder; + protected BaseEntityBuilder entityBuilder; + + public BaseControllerTests(FinancialHubApiFixture fixture, string name ,string endpoint) + { + this.fixture = fixture; + this.name = name; + this.baseEndpoint = endpoint; + } + + [SetUp] + public virtual void SetUp() + { + this.fixture.CreateDatabase(); + } + + [TearDown] + public virtual void TearDown() + { + this.fixture.ClearData(); + } + + protected virtual void AssertEqual(T expected, T result) + { + + } + + protected async Task AssertGetExists(T expected) + { + var getResponse = await this.client.GetAsync(baseEndpoint); + + var getResult = await getResponse.ReadContentAsync>(); + Assert.AreEqual(1, getResult?.Data.Count); + AssertEqual(expected, getResult!.Data.First()); + } + + [Test] + public async Task GetAll_ReturnData() + { + var data = entityBuilder.Generate(10); + this.fixture.AddData(data.ToArray()); + + var response = await this.client.GetAsync(baseEndpoint); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.AreEqual(data.Count, result?.Data.Count); + } + + [Test] + public async Task Post_ValidData_ReturnCreatedData() + { + var data = this.modelBuilder.Generate(); + + var response = await this.client.PostAsync(baseEndpoint, data); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + AssertEqual(data, result!.Data); + } + + [Test] + public async Task Post_ValidData_CreateData() + { + var body = this.modelBuilder.Generate(); + + await this.client.PostAsync(baseEndpoint, body); + + await this.AssertGetExists(body); + } + + [Test] + public async Task Put_ExistingData_ReturnUpdatedData() + { + var id = Guid.NewGuid(); + this.fixture.AddData(entityBuilder.WithId(id).Generate()); + + var body = this.modelBuilder.WithId(id).Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + Assert.AreEqual(body.Id, result?.Data.Id); + AssertEqual(body, result!.Data); + } + + [Test] + public async Task Put_ExistingData_UpdatesData() + { + var id = Guid.NewGuid(); + this.fixture.AddData(entityBuilder.WithId(id).Generate()); + + var body = this.modelBuilder.WithId(id).Generate(); + await this.client.PutAsync($"{baseEndpoint}/{id}", body); + + await this.AssertGetExists(body); + } + + [Test] + public async Task Put_NonExistingData_ReturnNotFoundError() + { + var id = Guid.NewGuid(); + var body = this.modelBuilder.WithId(id).Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); + Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); + + var result = await response.ReadContentAsync(); + Assert.AreEqual($"Not found {name} with id {id}", result!.Message); + } + + [Test] + public async Task Delete_ReturnNoContent() + { + var id = Guid.NewGuid(); + + var data = entityBuilder.WithId(id).Generate(); + this.fixture.AddData(data); + + var response = await this.client.DeleteAsync($"{baseEndpoint}/{id}"); + Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); + } + + [Test] + public async Task Delete_RemovesDataFromDatabase() + { + var id = Guid.NewGuid(); + + var data = entityBuilder.WithId(id).Generate(); + this.fixture.AddData(data); + + await this.client.DeleteAsync($"{baseEndpoint}/{id}"); + + var getResponse = await this.client.GetAsync(baseEndpoint); + var getResult = await getResponse.ReadContentAsync>(); + Assert.IsEmpty(getResult!.Data); + } + } } diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs index e56c5a9..ffbc35d 100644 --- a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs @@ -16,8 +16,9 @@ namespace FinancialHub.IntegrationTests { public class AccountsControllerTests : BaseControllerTests { - private AccountEntityBuilder dataBuilder; - private AccountModelBuilder builder; + private AccountEntityBuilder entityBuilder; + private AccountModelBuilder modelBuilder; + private BalanceEntityBuilder balanceBuilder; public AccountsControllerTests(FinancialHubApiFixture fixture) : base(fixture, "/accounts") { @@ -26,8 +27,9 @@ public AccountsControllerTests(FinancialHubApiFixture fixture) : base(fixture, " public override void SetUp() { - this.dataBuilder = new AccountEntityBuilder(); - this.builder = new AccountModelBuilder(); + this.modelBuilder = new AccountModelBuilder(); + this.entityBuilder = new AccountEntityBuilder(); + this.balanceBuilder = new BalanceEntityBuilder(); base.SetUp(); } @@ -35,7 +37,6 @@ protected static void AssertEqual(AccountModel expected, AccountModel result) { Assert.AreEqual(expected.Name, result.Name); Assert.AreEqual(expected.Description, result.Description); - Assert.AreEqual(expected.Currency, result.Currency); Assert.AreEqual(expected.IsActive, result.IsActive); } @@ -48,10 +49,36 @@ protected async Task AssertGetExists(AccountModel expected) AssertEqual(expected, getResult!.Data.First()); } + protected void Populate(int amount = 10) + { + var account = this.entityBuilder.Generate(); + var data = this.balanceBuilder.WithAccountId(account.Id).Generate(amount); + this.fixture.AddData(account); + this.fixture.AddData(data.ToArray()); + } + + [Test] + public async Task GetAccountsBalances_ReturnBalances() + { + var expectedAmount = this.random.Next(1, 10); + this.Populate(this.random.Next(1, 10)); + + var account = this.entityBuilder.Generate(); + var data = this.balanceBuilder.WithAccountId(account.Id).Generate(expectedAmount); + this.fixture.AddData(account); + this.fixture.AddData(data.ToArray()); + + var response = await this.client.GetAsync($"{baseEndpoint}/{account.Id}/balances"); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.AreEqual(expectedAmount, result?.Data.Count); + } + [Test] public async Task GetAll_ReturnAccounts() { - var data = dataBuilder.Generate(10); + var data = entityBuilder.Generate(10); this.fixture.AddData(data.ToArray()); var response = await this.client.GetAsync(baseEndpoint); @@ -64,7 +91,7 @@ public async Task GetAll_ReturnAccounts() [Test] public async Task Post_ValidAccount_ReturnCreatedAccount() { - var data = this.builder.Generate(); + var data = this.modelBuilder.Generate(); var response = await this.client.PostAsync(baseEndpoint, data); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); @@ -77,7 +104,7 @@ public async Task Post_ValidAccount_ReturnCreatedAccount() [Test] public async Task Post_ValidAccount_CreateAccount() { - var body = this.builder.Generate(); + var body = this.modelBuilder.Generate(); await this.client.PostAsync(baseEndpoint, body); @@ -88,9 +115,9 @@ public async Task Post_ValidAccount_CreateAccount() public async Task Put_ExistingAccount_ReturnUpdatedAccount() { var id = Guid.NewGuid(); - this.fixture.AddData(dataBuilder.WithId(id).Generate()); + this.fixture.AddData(entityBuilder.WithId(id).Generate()); - var body = this.builder.WithId(id).Generate(); + var body = this.modelBuilder.WithId(id).Generate(); var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); @@ -105,9 +132,9 @@ public async Task Put_ExistingAccount_ReturnUpdatedAccount() public async Task Put_ExistingAccount_UpdatesAccount() { var id = Guid.NewGuid(); - this.fixture.AddData(dataBuilder.WithId(id).Generate()); + this.fixture.AddData(entityBuilder.WithId(id).Generate()); - var body = this.builder.WithId(id).Generate(); + var body = this.modelBuilder.WithId(id).Generate(); await this.client.PutAsync($"{baseEndpoint}/{id}", body); await this.AssertGetExists(body); @@ -117,7 +144,7 @@ public async Task Put_ExistingAccount_UpdatesAccount() public async Task Put_NonExistingAccount_ReturnNotFoundError() { var id = Guid.NewGuid(); - var body = this.builder.WithId(id).Generate(); + var body = this.modelBuilder.WithId(id).Generate(); var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); @@ -131,7 +158,7 @@ public async Task Delete_ReturnNoContent() { var id = Guid.NewGuid(); - var data = dataBuilder.WithId(id).Generate(); + var data = entityBuilder.WithId(id).Generate(); this.fixture.AddData(data); var response = await this.client.DeleteAsync($"{baseEndpoint}/{id}"); @@ -143,7 +170,7 @@ public async Task Delete_RemovesAccountFromDatabase() { var id = Guid.NewGuid(); - var data = dataBuilder.WithId(id).Generate(); + var data = entityBuilder.WithId(id).Generate(); this.fixture.AddData(data); await this.client.DeleteAsync($"{baseEndpoint}/{id}"); diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs new file mode 100644 index 0000000..12f7522 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs @@ -0,0 +1,220 @@ +using System; +using System.Net; +using System.Threading.Tasks; +using System.Linq; +using NUnit.Framework; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Tests.Builders.Entities; +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.IntegrationTests.Base; +using FinancialHub.IntegrationTests.Setup; +using FinancialHub.IntegrationTests.Extensions; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Responses.Errors; + +namespace FinancialHub.IntegrationTests +{ + public class BalancesControllerTests : BaseControllerTests + { + private BalanceEntityBuilder entityBuilder; + private BalanceModelBuilder modelBuilder; + private AccountEntityBuilder accountBuilder; + + public BalancesControllerTests(FinancialHubApiFixture fixture) : base(fixture ,"/balances") + { + } + + public override void SetUp() + { + this.entityBuilder = new BalanceEntityBuilder(); + this.modelBuilder = new BalanceModelBuilder(); + this.accountBuilder = new AccountEntityBuilder(); + base.SetUp(); + } + + protected static void AssertEqual(BalanceModel expected, BalanceModel result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.AccountId, result.AccountId); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + + protected static void AssertEqual(BalanceModel expected, BalanceEntity result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.AccountId, result.AccountId); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + + protected void AssertExists(BalanceModel expected) + { + var data = this.fixture.GetData(); + AssertEqual(expected, data.First()); + } + + [Test] + public async Task Post_ValidBalance_ReturnsCreatedBalance() + { + var account = this.accountBuilder.Generate(); + this.fixture.AddData(account); + var data = this.modelBuilder.WithAccountId(account.Id).Generate(); + + var response = await this.client.PostAsync(baseEndpoint, data); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + AssertEqual(data, result!.Data); + } + + [Test] + public async Task Post_ValidBalance_CreatesBalance() + { + var account = this.accountBuilder.Generate(); + this.fixture.AddData(account); + var body = this.modelBuilder.WithAccountId(account.Id).Generate(); + + await this.client.PostAsync(baseEndpoint, body); + + this.AssertExists(body); + } + + [Test] + public async Task Post_ValidBalance_CreatesBalanceWithAmountZero() + { + var account = this.accountBuilder.Generate(); + this.fixture.AddData(account); + var body = this.modelBuilder.WithAccountId(account.Id).Generate(); + + var response = await this.client.PostAsync(baseEndpoint, body); + var result = await response.ReadContentAsync>(); + Assert.Zero(result!.Data.Amount); + } + + [Test] + public async Task Put_ExistingBalance_ReturnsUpdatedBalance() + { + var account = this.accountBuilder.Generate(); + this.fixture.AddData(account); + + var id = Guid.NewGuid(); + var entity = entityBuilder + .WithAccountId(account.Id) + .WithId(id) + .Generate(); + this.fixture.AddData(entity); + + var data = this.modelBuilder + .WithAccountId(account.Id) + .WithId(id) + .Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{id}", data); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.IsNotNull(result?.Data); + AssertEqual(data, result!.Data); + } + + [Test] + public async Task Put_ExistingBalance_UpdatesBalance() + { + var account = this.accountBuilder.Generate(); + this.fixture.AddData(account); + + var id = Guid.NewGuid(); + var entity = entityBuilder + .WithAccountId(account.Id) + .WithId(id) + .Generate(); + this.fixture.AddData(entity); + + var data = this.modelBuilder + .WithAccountId(account.Id) + .WithId(id) + .Generate(); + + await this.client.PutAsync($"{baseEndpoint}/{id}", data); + + this.AssertExists(data); + } + + [Test] + public async Task Put_ExistingBalance_DoesNotUpdatesBalanceAmount() + { + var account = this.accountBuilder.Generate(); + this.fixture.AddData(account); + + var id = Guid.NewGuid(); + var entity = entityBuilder + .WithAccountId(account.Id) + .WithAmount(0) + .WithId(id) + .Generate(); + this.fixture.AddData(entity); + + var data = this.modelBuilder + .WithAccountId(account.Id) + .WithId(id) + .Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{id}", data); + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + + var result = await response.ReadContentAsync>(); + Assert.Zero(result!.Data.Amount); + } + + [Test] + public async Task Put_NotExistingBalance_ReturnsNotFound() + { + var account = this.accountBuilder.Generate(); + this.fixture.AddData(account); + + var entity = entityBuilder + .WithAccountId(account.Id) + .Generate(); + this.fixture.AddData(entity); + + var id = Guid.NewGuid(); + var data = this.modelBuilder + .WithAccountId(account.Id) + .WithId(id) + .Generate(); + + var response = await this.client.PutAsync($"{baseEndpoint}/{id}", data); + Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); + + var result = await response.ReadContentAsync(); + Assert.AreEqual(result?.Message, $"Not found Balance with id {id}"); + } + + [Test] + public async Task Delete_ReturnsNoContent() + { + var id = Guid.NewGuid(); + + var data = entityBuilder.WithId(id).Generate(); + this.fixture.AddData(data); + + var response = await this.client.DeleteAsync($"{baseEndpoint}/{id}"); + Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); + } + + [Test] + public async Task Delete_RemovesBalanceFromDatabase() + { + var id = Guid.NewGuid(); + + var data = entityBuilder.WithId(id).Generate(); + this.fixture.AddData(data); + + await this.client.DeleteAsync($"{baseEndpoint}/{id}"); + + var result = this.fixture.GetData(); + Assert.IsEmpty(result); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs index 7fb946b..8d82d91 100644 --- a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs @@ -33,7 +33,7 @@ public override void SetUp() protected static void AssertEqual(TransactionModel expected, TransactionModel result) { - Assert.AreEqual(expected.AccountId, result.AccountId); + Assert.AreEqual(expected.BalanceId, result.BalanceId); Assert.AreEqual(expected.CategoryId, result.CategoryId); Assert.AreEqual(expected.TargetDate, result.TargetDate); Assert.AreEqual(expected.FinishDate, result.FinishDate); @@ -57,10 +57,10 @@ protected TransactionModel CreateValidTransaction(bool isActive = true) var model = entityBuilder.Generate(); this.fixture.AddData(model.Category); - this.fixture.AddData(model.Account); + this.fixture.AddData(model.Balance); var data = entityBuilder - .WithAccountId(model.Account.Id) + .WithBalanceId(model.Balance.Id) .WithCategoryId(model.Category.Id) .WithActiveStatus(isActive) .Generate(); @@ -69,7 +69,7 @@ protected TransactionModel CreateValidTransaction(bool isActive = true) { Id = data.Id, CategoryId = data.CategoryId, - AccountId = data.AccountId, + BalanceId = data.BalanceId, Description = data.Description, FinishDate = data.FinishDate, TargetDate = data.TargetDate, @@ -84,22 +84,26 @@ protected TransactionModel InsertTransaction(bool isActive = true) { var model = entityBuilder.Generate(); - this.fixture.AddData(model.Category); - this.fixture.AddData(model.Account); + var account = this.fixture.AddData(model.Balance.Account).First(); + model.Balance.Account = null; + model.Balance.AccountId = account.Id.GetValueOrDefault(); + + var balance = this.fixture.AddData(model.Balance).First(); + var category = this.fixture.AddData(model.Category).First(); var data = entityBuilder - .WithAccountId(model.Account.Id) - .WithCategoryId(model.Category.Id) + .WithBalanceId(balance.Id) + .WithCategoryId(category.Id) .WithActiveStatus(isActive) .Generate(); - this.fixture.AddData(data); + data = this.fixture.AddData(data).First(); return new TransactionModel() { Id = data.Id, CategoryId = data.CategoryId, - AccountId = data.AccountId, + BalanceId = data.BalanceId, Description = data.Description, FinishDate = data.FinishDate, TargetDate = data.TargetDate, @@ -115,10 +119,10 @@ protected TransactionModel[] InsertTransactions(bool isActive = true) var model = entityBuilder.Generate(); this.fixture.AddData(model.Category); - this.fixture.AddData(model.Account); + this.fixture.AddData(model.Balance); var data = entityBuilder - .WithAccountId(model.Account.Id) + .WithBalanceId(model.Balance.Id) .WithCategoryId(model.Category.Id) .WithActiveStatus(isActive) .Generate(10); @@ -130,7 +134,7 @@ protected TransactionModel[] InsertTransactions(bool isActive = true) { Id = x.Id, CategoryId = x.CategoryId, - AccountId = x.AccountId, + BalanceId = x.BalanceId, Description = x.Description, FinishDate = x.FinishDate, TargetDate = x.TargetDate, @@ -195,7 +199,7 @@ public async Task Put_ExistingTransaction_ReturnUpdatedTransaction() var data = this.InsertTransaction(true); var body = this.modelBuilder - .WithAccountId(data.AccountId) + .WithBalanceId(data.BalanceId) .WithCategoryId(data.CategoryId) .WithActiveStatus(data.IsActive) .WithId(data.Id.GetValueOrDefault()) @@ -216,7 +220,7 @@ public async Task Put_ExistingTransaction_UpdatesTransaction() var data = this.InsertTransaction(true); var body = this.modelBuilder - .WithAccountId(data.AccountId) + .WithBalanceId(data.BalanceId) .WithCategoryId(data.CategoryId) .WithActiveStatus(data.IsActive) .WithId(data.Id.GetValueOrDefault()) diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs b/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs index 137ea12..9fbf229 100644 --- a/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs +++ b/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Net.Http; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; @@ -7,6 +8,7 @@ using FinancialHub.Domain.Entities; using System.Collections; using FinancialHub.IntegrationTests.Extensions; +using System.Collections.Generic; namespace FinancialHub.IntegrationTests.Setup { @@ -31,7 +33,7 @@ public FinancialHubApiFixture() this.Client = this.Api.CreateClient(); } - public void AddData(params T[] data) + public T[] AddData(params T[] data) where T : BaseEntity { using (var scope = this.Api.Server.Services.CreateScope()) @@ -39,6 +41,21 @@ public void AddData(params T[] data) var context = scope.ServiceProvider.GetRequiredService(); context.Set().AddRange(data); context.SaveChanges(); + + context.ChangeTracker.Clear(); + + var res = context.Set().ToArray(); + return res.Where(x => data.Any(y => y.Id == x.Id)).ToArray(); + } + } + + public IEnumerable GetData() + where T : BaseEntity + { + using (var scope = this.Api.Server.Services.CreateScope()) + { + var context = scope.ServiceProvider.GetRequiredService(); + return context.Set().ToArray(); } } diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs new file mode 100644 index 0000000..64e9ec3 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs @@ -0,0 +1,129 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Results.Errors; +using Moq; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class AccountBalanceServiceTests + { + [Test] + public async Task CreateAsync_CreatesAccount() + { + var account = this.accountModelBuilder.Generate(); + + this.accountsService + .Setup(x => x.CreateAsync(account)) + .ReturnsAsync(account) + .Verifiable(); + this.balanceService + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await + Task.FromResult( + new ServiceResult(x) + ) + ) + .Verifiable(); + + var result = await this.service.CreateAsync(account); + + this.accountsService.Verify(x => x.CreateAsync(account),Times.Once); + } + + [Test] + public async Task CreateAsync_CreatesDefaultBalance() + { + var account = this.accountModelBuilder.Generate(); + + this.accountsService + .Setup(x => x.CreateAsync(account)) + .ReturnsAsync(account) + .Verifiable(); + this.balanceService + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await + Task.FromResult( + new ServiceResult(x) + ) + ) + .Verifiable(); + + var result = await this.service.CreateAsync(account); + this.balanceService.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); + } + + [Test] + public async Task CreateAsync_ValidAccount_ReturnsCreatedAccount() + { + var account = this.accountModelBuilder.Generate(); + + this.accountsService + .Setup(x => x.CreateAsync(account)) + .ReturnsAsync(account) + .Verifiable(); + this.balanceService + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await + Task.FromResult( + new ServiceResult(x) + ) + ) + .Verifiable(); + + var result = await this.service.CreateAsync(account); + + Assert.IsFalse(result.HasError); + Assert.AreEqual(account.Name,result.Data.Name); + Assert.AreEqual(account.Description,result.Data.Description); + Assert.AreEqual(account.IsActive,result.Data.IsActive); + } + + [Test] + public async Task CreateAsync_ErrorOnCreateAccount_ReturnsError() + { + var account = this.accountModelBuilder.Generate(); + var error = new ServiceError(1,"Account Error"); + + this.accountsService + .Setup(x => x.CreateAsync(account)) + .ReturnsAsync(account) + .Verifiable(); + this.balanceService + .Setup(x => x.CreateAsync(It.IsAny())) + .ReturnsAsync(error) + .Verifiable(); + + var result = await this.service.CreateAsync(account); + + Assert.IsTrue(result.HasError); + Assert.AreEqual(error.Message, result.Error.Message); + } + + [Test] + public async Task CreateAsync_ErrorOnCreateDefaultBalance_ReturnsError() + { + var account = this.accountModelBuilder.Generate(); + var error = new ServiceError(1, "Balance Error"); + + this.accountsService + .Setup(x => x.CreateAsync(account)) + .ReturnsAsync(error) + .Verifiable(); + this.balanceService + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await + Task.FromResult( + new ServiceResult(x) + ) + ) + .Verifiable(); + + var result = await this.service.CreateAsync(account); + + Assert.IsTrue(result.HasError); + Assert.AreEqual(error.Message, result.Error.Message); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs new file mode 100644 index 0000000..6ab9145 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs @@ -0,0 +1,37 @@ +using System; +using Moq; +using NUnit.Framework; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Services.Services; +using FinancialHub.Domain.Tests.Builders.Models; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class AccountBalanceServiceTests + { + protected Random random; + protected AccountModelBuilder accountModelBuilder; + protected BalanceModelBuilder balanceModelBuilder; + + private IAccountBalanceService service; + + private Mock balanceService; + private Mock accountsService; + + [SetUp] + public void Setup() + { + this.balanceService = new Mock(); + this.accountsService = new Mock(); + this.service = new AccountBalanceService( + balanceService.Object, + accountsService.Object + ); + + this.random = new Random(); + + this.accountModelBuilder = new AccountModelBuilder(); + this.balanceModelBuilder = new BalanceModelBuilder(); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs new file mode 100644 index 0000000..a897aed --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs @@ -0,0 +1,147 @@ +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; +using FinancialHub.Domain.Results.Errors; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class AccountBalanceServiceTests + { + [Test] + public async Task DeleteAsync_RemovesBalances() + { + var expectedResult = random.Next(1, 100); + var account = this.accountModelBuilder.Generate(); + var balances = this.balanceModelBuilder + .WithAccount(account) + .Generate(expectedResult); + + this.accountsService + .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(0) + .Verifiable(); + this.balanceService + .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(balances) + .Verifiable(); + this.balanceService + .Setup(x => x.DeleteAsync(It.IsAny())) + .ReturnsAsync(1) + .Verifiable(); + + var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); + + Assert.AreEqual(expectedResult, result.Data); + + this.balanceService.Verify(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault()),Times.Once); + this.balanceService.Verify(x => x.DeleteAsync(It.IsAny()),Times.Exactly(expectedResult)); + } + + [Test] + public async Task DeleteAsync_RemovesAccount() + { + var account = this.accountModelBuilder.Generate(); + var balances = this.balanceModelBuilder + .WithAccount(account) + .Generate(0); + + this.accountsService + .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(1) + .Verifiable(); + + this.balanceService + .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(balances) + .Verifiable(); + + var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); + + Assert.AreEqual(1, result.Data); + + this.accountsService.Verify(x => x.DeleteAsync(account.Id.GetValueOrDefault()), Times.Once); + } + + [Test] + public async Task DeleteAsync_AccountDeletionError_ReturnsError() + { + var expectedResult = new ServiceError(1,"Error"); + var account = this.accountModelBuilder.Generate(); + var balances = this.balanceModelBuilder + .WithAccount(account) + .Generate(0); + + this.accountsService + .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(expectedResult) + .Verifiable(); + this.balanceService + .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(balances) + .Verifiable(); + var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); + + Assert.IsTrue(result.HasError); + Assert.AreEqual(expectedResult,result.Error); + Assert.AreEqual(0, result.Data); + } + + [Test] + public async Task DeleteAsync_BalanceDeletionError_ReturnsError() + { + var expectedResult = new ServiceError(1, "Error"); + var account = this.accountModelBuilder.Generate(); + var balances = this.balanceModelBuilder + .WithAccount(account) + .Generate(1); + + this.accountsService + .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(1) + .Verifiable(); + this.balanceService + .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(balances) + .Verifiable(); + this.balanceService + .Setup(x => x.DeleteAsync(It.IsAny())) + .ReturnsAsync(expectedResult) + .Verifiable(); + + var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); + + Assert.IsTrue(result.HasError); + Assert.AreEqual(expectedResult, result.Error); + Assert.AreEqual(0, result.Data); + } + + [Test] + public async Task DeleteAsync_Success_ReturnsRemovedBalancesAndAccount() + { + var expectedResult = random.Next(1, 100); + var account = this.accountModelBuilder.Generate(); + var balances = this.balanceModelBuilder + .WithAccount(account) + .Generate(expectedResult); + + this.accountsService + .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(1) + .Verifiable(); + this.balanceService + .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) + .ReturnsAsync(balances) + .Verifiable(); + this.balanceService + .Setup(x => x.DeleteAsync(It.IsAny())) + .ReturnsAsync(1) + .Verifiable(); + + var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); + + Assert.IsFalse(result.HasError); + Assert.AreEqual(expectedResult + 1, result.Data); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs index f6c79b9..74235e8 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs @@ -1,4 +1,8 @@ -using AutoMapper; +using System; +using System.Collections.Generic; +using AutoMapper; +using Moq; +using NUnit.Framework; using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Mappers; using FinancialHub.Domain.Interfaces.Repositories; @@ -7,10 +11,6 @@ using FinancialHub.Domain.Tests.Builders.Models; using FinancialHub.Services.Mappers; using FinancialHub.Services.Services; -using Moq; -using NUnit.Framework; -using System; -using System.Collections.Generic; namespace FinancialHub.Services.NUnitTests.Services { @@ -51,7 +51,8 @@ public void Setup() this.accountModelBuilder = new AccountModelBuilder(); } - public ICollection GenerateAccounts(){ + public ICollection GenerateAccounts() + { return this.accountEntityBuilder.Generate(random.Next(5,10)); } } diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs index d876894..73531e3 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs @@ -9,7 +9,6 @@ namespace FinancialHub.Services.NUnitTests.Services public partial class AccountsServiceTests { [Test] - [TestCase(Description = "Update valid account", Category = "Delete")] public async Task DeleteAsync_RepositorySuccess_ReturnsAccountModel() { var expectedResult = random.Next(1,100); @@ -27,7 +26,6 @@ public async Task DeleteAsync_RepositorySuccess_ReturnsAccountModel() } [Test] - [TestCase(Description = "Update repository exception", Category = "Delete")] public void DeleteAsync_RepositoryException_ThrowsException() { var guid = Guid.NewGuid(); diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs index ed0b4f1..b45a5c0 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs @@ -12,7 +12,6 @@ namespace FinancialHub.Services.NUnitTests.Services { public partial class AccountsServiceTests { - //TODO: change mock when filter by user [Test] [TestCase(Description = "Get by user sucess return",Category = "Get")] public async Task GetByUsersAsync_ValidUser_ReturnsAccounts() diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs new file mode 100644 index 0000000..6170f05 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs @@ -0,0 +1,99 @@ +using System.Threading.Tasks; +using Moq; +using NUnit.Framework; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class BalancesServiceTests + { + [Test] + public async Task CreateAsync_ValidatesIfAccountExists() + { + var model = this.balanceModelBuilder.Generate(); + + this.accountsRepository + .Setup(x => x.GetByIdAsync(model.AccountId)) + .ReturnsAsync(this.mapper.Map(model.Account)) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.CreateAsync(model); + + this.accountsRepository.Verify(x => x.GetByIdAsync(model.AccountId), Times.Once); + } + + [Test] + public async Task CreateAsync_CreatesBalance() + { + var model = this.balanceModelBuilder.Generate(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.accountsRepository + .Setup(x => x.GetByIdAsync(model.AccountId)) + .ReturnsAsync(this.mapper.Map(model.Account)) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.CreateAsync(model); + + this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); + } + + [Test] + public async Task CreateAsync_ValidBalanceModel_ReturnsBalanceModel() + { + var model = this.balanceModelBuilder.Generate(); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.accountsRepository + .Setup(x => x.GetByIdAsync(model.AccountId)) + .ReturnsAsync(this.mapper.Map(model.Account)) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.CreateAsync(model); + + Assert.IsNotNull(result.Data); + Assert.IsInstanceOf>(result); + } + + [Test] + public async Task CreateAsync_InvalidAccountModel_ReturnsNotFoundError() + { + var model = this.balanceModelBuilder.Generate(); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.CreateAsync(model); + + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Account with id {model.AccountId}", result.Error.Message); + + this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Never); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs new file mode 100644 index 0000000..6a7d078 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using AutoMapper; +using Moq; +using NUnit.Framework; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Entities; +using FinancialHub.Services.Mappers; +using FinancialHub.Services.Services; +using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Tests.Builders.Entities; +using FinancialHub.Domain.Tests.Builders.Models; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class BalancesServiceTests + { + protected Random random; + protected BalanceEntityBuilder balanceEntityBuilder; + protected BalanceModelBuilder balanceModelBuilder; + + private IBalancesService service; + + private IMapper mapper; + private Mock mapperWrapper; + private Mock repository; + private Mock accountsRepository; + + private void MockMapper() + { + mapper = new MapperConfiguration(mc => + { + mc.AddProfile(new FinancialHubAutoMapperProfile()); + } + ).CreateMapper(); + + this.mapperWrapper = new Mock(); + } + + [SetUp] + public void Setup() + { + this.MockMapper(); + + this.repository = new Mock(); + this.accountsRepository = new Mock(); + this.service = new BalancesService( + mapperWrapper.Object, + repository.Object, + accountsRepository.Object + ); + + this.random = new Random(); + + this.balanceEntityBuilder = new BalanceEntityBuilder(); + this.balanceModelBuilder = new BalanceModelBuilder(); + } + + private void SetUpMapper() + { + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + } + + public ICollection GenerateBalances() + { + return this.balanceEntityBuilder.Generate(random.Next(5, 10)); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs new file mode 100644 index 0000000..52652d5 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs @@ -0,0 +1,42 @@ +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class BalancesServiceTests + { + [Test] + public async Task DeleteAsync_RemovesBalance() + { + var expectedResult = random.Next(1, 100); + var guid = Guid.NewGuid(); + this.repository + .Setup(x => x.DeleteAsync(guid)) + .Returns(async () => await Task.FromResult(expectedResult)) + .Verifiable(); + + await this.service.DeleteAsync(guid); + + this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); + } + + [Test] + public async Task DeleteAsync_RepositorySuccess_ReturnsRemovedBalances() + { + var expectedResult = random.Next(1,100); + var guid = Guid.NewGuid(); + this.repository + .Setup(x => x.DeleteAsync(guid)) + .Returns(async () => await Task.FromResult(expectedResult)) + .Verifiable(); + + var result = await this.service.DeleteAsync(guid); + + Assert.IsInstanceOf>(result); + Assert.AreEqual(expectedResult,result.Data); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs new file mode 100644 index 0000000..ce38553 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs @@ -0,0 +1,79 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class BalancesServiceTests + { + [Test] + public async Task GetByAccountAsync_ValidAccount_ReturnsBalances() + { + var firstEntity = this.balanceEntityBuilder.Generate(); + var entitiesMock = this.balanceEntityBuilder + .WithAccount(firstEntity.Account) + .Generate(random.Next(5, 10)); + + this.repository + .Setup(x => x.GetAsync(It.IsAny>())) + .ReturnsAsync(entitiesMock.ToArray()) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map>(It.IsAny>())) + .Returns>((ent) => this.mapper.Map>(ent)) + .Verifiable(); + + var result = await this.service.GetAllByAccountAsync(firstEntity.Account.Id.GetValueOrDefault()); + + Assert.IsInstanceOf>>(result); + Assert.IsFalse(result.HasError); + Assert.AreEqual(entitiesMock.Count, result.Data.Count); + + this.repository.Verify(x => x.GetAsync(It.IsAny>()), Times.Once); + } + + [Test] + public async Task GetByIdAsync_ValidId_ReturnsBalance() + { + var entity = this.balanceEntityBuilder.Generate(); + + this.repository + .Setup(x => x.GetByIdAsync(entity.Id.GetValueOrDefault())) + .ReturnsAsync(entity) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.GetByIdAsync(entity.Id.GetValueOrDefault()); + + Assert.IsInstanceOf>(result); + Assert.IsFalse(result.HasError); + Assert.AreEqual(entity.AccountId , result.Data.AccountId); + Assert.AreEqual(entity.Amount , result.Data.Amount); + Assert.AreEqual(entity.Name , result.Data.Name); + Assert.AreEqual(entity.IsActive , result.Data.IsActive); + + this.repository.Verify(x => x.GetByIdAsync(entity.Id.GetValueOrDefault()), Times.Once); + } + + [Test] + public async Task GetByIdAsync_InvalidId_ReturnsNotFoundError() + { + var entity = this.balanceEntityBuilder.Generate(); + + this.SetUpMapper(); + + var result = await this.service.GetByIdAsync(entity.Id.GetValueOrDefault()); + + Assert.IsInstanceOf>(result); + Assert.IsTrue(result.HasError); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs new file mode 100644 index 0000000..b3f32e1 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs @@ -0,0 +1,149 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class BalancesServiceTests + { + [Test] + public async Task UpdateAsync_ValidatesIfAccountExists() + { + var model = this.balanceModelBuilder.Generate(); + + this.accountsRepository + .Setup(x => x.GetByIdAsync(model.AccountId)) + .ReturnsAsync(this.mapper.Map(model.Account)) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.CreateAsync(model); + + this.accountsRepository.Verify(x => x.GetByIdAsync(model.AccountId), Times.Once); + } + + [Test] + public async Task UpdateAsync_ValidatesIfBalanceExists() + { + var model = this.balanceModelBuilder.Generate(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(default(BalanceEntity)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + } + + [Test] + public async Task UpdateAsync_UpdatesBalance() + { + var model = this.balanceModelBuilder.Generate(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.accountsRepository + .Setup(x => x.GetByIdAsync(model.AccountId)) + .ReturnsAsync(this.mapper.Map(model.Account)) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); + } + + [Test] + public async Task UpdateAsync_ValidBalanceModel_ReturnsBalanceModel() + { + var model = this.balanceModelBuilder.Generate(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.accountsRepository + .Setup(x => x.GetByIdAsync(model.AccountId)) + .ReturnsAsync(this.mapper.Map(model.Account)) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsInstanceOf>(result); + Assert.IsNotNull(result.Data); + } + + [Test] + public async Task UpdateAsync_NonExistingBalanceId_ReturnsResultError() + { + var model = this.balanceModelBuilder.Generate(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(default(BalanceEntity)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsInstanceOf>(result); + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Balance with id {model.Id}", result.Error.Message); + + this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); + } + + [Test] + public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() + { + var model = this.balanceModelBuilder.Generate(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsInstanceOf>(result); + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Account with id {model.AccountId}", result.Error.Message); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs index b2e7238..5e2739d 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs @@ -1,74 +1,160 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; +using System; +using System.Threading.Tasks; using Moq; using NUnit.Framework; -using System; -using System.Threading.Tasks; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Enums; namespace FinancialHub.Services.NUnitTests.Services { public partial class TransactionsServiceTests { [Test] - [TestCase(Description = "Create valid Transaction", Category = "Create")] - public async Task CreateAsync_ValidTransactionModel_ReturnsTransactionModel() + public async Task CreateAsync_ValidTransaction_CreatesTransaction() { var model = this.transactionModelBuilder.Generate(); + this.categoriesRepository + .Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)); + + this.balancesRepository + .Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(this.mapper.Map(model.Balance)); + this.repository .Setup(x => x.CreateAsync(It.IsAny())) .Returns(async (x) => await Task.FromResult(x)) .Verifiable(); - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) + this.SetUpMapper(); + + await this.service.CreateAsync(model); + + this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); + } + + [Test] + public async Task CreateAsync_CommitedActiveTransaction_UpdatesBalance() + { + var model = this.transactionModelBuilder + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + var balanceEntity = this.mapper.Map(model.Balance); + + this.categoriesRepository + .Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) .Verifiable(); - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) + this.balancesRepository + .Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(balanceEntity) .Verifiable(); - var result = await this.service.CreateAsync(model); + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); - Assert.IsNotNull(result.Data); - Assert.IsInstanceOf>(result); + this.SetUpMapper(); - this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); - this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); - this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); + await this.service.CreateAsync(model); + + this.balancesRepository.Verify(x => x.ChangeAmountAsync(model.BalanceId, model.Amount,model.Type,false), Times.Once); } [Test] - [TestCase(Description = "Create repository exception", Category = "Create")] - public void CreateAsync_RepositoryException_ThrowsException() + public async Task CreateAsync_NotCommitedTransaction_DoesNotUpdatesBalance() { - var model = this.transactionModelBuilder.Generate(); - var exc = new Exception("mock"); + var model = this.transactionModelBuilder + .WithStatus(TransactionStatus.NotCommitted) + .Generate(); + var balanceEntity = this.mapper.Map(model.Balance); + + this.categoriesRepository + .Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository + .Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(balanceEntity) + .Verifiable(); this.repository .Setup(x => x.CreateAsync(It.IsAny())) - .Throws(exc) + .Returns(async (x) => await Task.FromResult(x)) .Verifiable(); - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); + this.SetUpMapper(); + + await this.service.CreateAsync(model); + + this.balancesRepository.Verify(x => x.ChangeAmountAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); + } + + [Test] + public async Task CreateAsync_ValidTransaction_ReturnsCreatedTransaction() + { + var model = this.transactionModelBuilder.Generate(); - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) + this.categoriesRepository + .Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)); + + this.balancesRepository + .Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(this.mapper.Map(model.Balance)); + + this.repository + .Setup(x => x.CreateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) .Verifiable(); - var exception = Assert.ThrowsAsync( - async () => await this.service.CreateAsync(model) - ); + this.SetUpMapper(); + + var result = await this.service.CreateAsync(model); + + Assert.IsNotNull(result.Data); + Assert.IsInstanceOf>(result); + } + + [Test] + public async Task CreateAsync_InvalidCategory_ReturnsNotFoundError() + { + var model = this.transactionModelBuilder.Generate(); + + this.SetUpMapper(); + + this.balancesRepository + .Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(this.mapper.Map(model.Balance)); + + var result = await this.service.CreateAsync(model); + + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error.Message); + } + + [Test] + public async Task CreateAsync_InvalidBalance_ReturnsNotFoundError() + { + var model = this.transactionModelBuilder.Generate(); + + this.SetUpMapper(); + + this.categoriesRepository + .Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)); + + var result = await this.service.CreateAsync(model); - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error.Message); } } } diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs index 7f382e1..c5a8991 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs @@ -3,6 +3,7 @@ using FinancialHub.Domain.Interfaces.Mappers; using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Models; using FinancialHub.Domain.Tests.Builders.Entities; using FinancialHub.Domain.Tests.Builders.Models; using FinancialHub.Services.Mappers; @@ -25,6 +26,8 @@ public partial class TransactionsServiceTests private IMapper mapper; private Mock mapperWrapper; private Mock repository; + private Mock balancesRepository; + private Mock categoriesRepository; private void MockMapper() { @@ -43,7 +46,9 @@ public void Setup() this.MockMapper(); this.repository = new Mock(); - this.service = new TransactionsService(mapperWrapper.Object,repository.Object); + this.balancesRepository = new Mock(); + this.categoriesRepository = new Mock(); + this.service = new TransactionsService(mapperWrapper.Object,repository.Object,balancesRepository.Object,categoriesRepository.Object); this.random = new Random(); @@ -51,6 +56,19 @@ public void Setup() this.transactionModelBuilder = new TransactionModelBuilder(); } + private void SetUpMapper() + { + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((ent) => this.mapper.Map(ent)) + .Verifiable(); + + this.mapperWrapper + .Setup(x => x.Map(It.IsAny())) + .Returns((model) => this.mapper.Map(model)) + .Verifiable(); + } + public ICollection GenerateTransactions() { return this.transactionBuilder.Generate(random.Next(5, 10)); diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs index 445a53d..beeaab6 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs @@ -1,7 +1,7 @@ -using FinancialHub.Domain.Results; +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Results; using Moq; using NUnit.Framework; -using System; using System.Threading.Tasks; namespace FinancialHub.Services.NUnitTests.Services @@ -9,41 +9,131 @@ namespace FinancialHub.Services.NUnitTests.Services public partial class TransactionsServiceTests { [Test] - [TestCase(Description = "Update valid Transaction", Category = "Delete")] - public async Task DeleteAsync_RepositorySuccess_ReturnsTransactionModel() + public async Task DeleteAsync_ExistingTransaction_RemovesTransactions() { - var expectedResult = random.Next(1,100); - var guid = Guid.NewGuid(); + var expectedResult = random.Next(1, 100); + var transaction = this.transactionBuilder.Generate(); + var guid = transaction.Id.GetValueOrDefault(); + this.repository .Setup(x => x.DeleteAsync(guid)) - .Returns(async () => await Task.FromResult(expectedResult)) + .ReturnsAsync(expectedResult) .Verifiable(); + this.repository + .Setup(x => x.GetByIdAsync(guid)) + .ReturnsAsync(transaction); + + this.SetUpMapper(); + + await this.service.DeleteAsync(guid); + + this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); + } + + [Test] + public async Task DeleteAsync_ExistingTransaction_ReturnsRemovedTransactions() + { + var expectedResult = random.Next(1,100); + var transaction = this.transactionBuilder.Generate(); + var guid = transaction.Id.GetValueOrDefault(); + this.repository + .Setup(x => x.DeleteAsync(guid)) + .ReturnsAsync(expectedResult); + this.repository + .Setup(x => x.GetByIdAsync(guid)) + .ReturnsAsync(transaction); + + this.SetUpMapper(); + var result = await this.service.DeleteAsync(guid); Assert.IsInstanceOf>(result); Assert.AreEqual(expectedResult,result.Data); - this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); } [Test] - [TestCase(Description = "Update repository exception", Category = "Delete")] - public void DeleteAsync_RepositoryException_ThrowsException() + public async Task DeleteAsync_NotExistingTransaction_ReturnsNotFoundError() + { + var transaction = this.transactionBuilder.Generate(); + var guid = transaction.Id.GetValueOrDefault(); + + this.repository + .Setup(x => x.GetByIdAsync(guid)); + + var result = await this.service.DeleteAsync(guid); + + Assert.Zero(result.Data); + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Transaction with id {guid}", result.Error.Message); + } + + [Test] + public async Task DeleteAsync_NotExistingTransaction_DoesNotRemovesTransactions() { - var guid = Guid.NewGuid(); - var exc = new Exception("mock"); + var transaction = this.transactionBuilder.Generate(); + var guid = transaction.Id.GetValueOrDefault(); + + this.repository + .Setup(x => x.GetByIdAsync(guid)); + + await this.service.DeleteAsync(guid); + + this.repository.Verify(x => x.GetByIdAsync(guid),Times.Once); + } + + [TestCase(TransactionStatus.Committed, false)] + [TestCase(TransactionStatus.NotCommitted, true)] + [TestCase(TransactionStatus.NotCommitted, false)] + public async Task DeleteAsync_ExistingNotCommitedOrInactiveTransaction_RemovesBalanceAmount( + TransactionStatus status, bool isActive + ) + { + var expectedResult = random.Next(1, 100); + var transaction = this.transactionBuilder + .WithStatus(status) + .WithActiveStatus(isActive) + .Generate(); + var guid = transaction.Id.GetValueOrDefault(); this.repository .Setup(x => x.DeleteAsync(guid)) - .Throws(exc) - .Verifiable(); + .ReturnsAsync(expectedResult); + this.repository + .Setup(x => x.GetByIdAsync(guid)) + .ReturnsAsync(transaction); + + this.SetUpMapper(); + + await this.service.DeleteAsync(guid); + + this.balancesRepository.Verify(x => x.ChangeAmountAsync(transaction.BalanceId,transaction.Amount,transaction.Type,true), Times.Never); + } + + [TestCase(TransactionStatus.Committed, true)] + public async Task DeleteAsync_ExistingCommitedAndActiveTransaction_RemovesBalanceAmount( + TransactionStatus status, bool isActive + ) + { + var expectedResult = random.Next(1, 100); + var transaction = this.transactionBuilder + .WithStatus(status) + .WithActiveStatus(isActive) + .Generate(); + var guid = transaction.Id.GetValueOrDefault(); + + this.repository + .Setup(x => x.DeleteAsync(guid)) + .ReturnsAsync(expectedResult); + this.repository + .Setup(x => x.GetByIdAsync(guid)) + .ReturnsAsync(transaction); - var exception = Assert.ThrowsAsync( - async () => await this.service.DeleteAsync(guid) - ); + this.SetUpMapper(); + + await this.service.DeleteAsync(guid); - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.DeleteAsync(guid), Times.Once()); + this.balancesRepository.Verify(x => x.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type,true), Times.Once); } } } diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs index c9efb90..c37e3d8 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs @@ -1,24 +1,20 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Filters; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using Moq; +using NUnit.Framework; +using FinancialHub.Domain.Entities; using FinancialHub.Domain.Models; +using FinancialHub.Domain.Filters; using FinancialHub.Domain.Queries; using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace FinancialHub.Services.NUnitTests.Services { public partial class TransactionsServiceTests { - //TODO: change mock when filter by user - //TODO: add validation tests - //TODO: add filter validation tests [Test] - [TestCase(Description = "Get by user sucess return",Category = "Get")] public async Task GetByUsersAsync_ValidUser_ReturnsTransactions() { var filter = new TransactionFilter(); @@ -26,8 +22,7 @@ public async Task GetByUsersAsync_ValidUser_ReturnsTransactions() this.repository .Setup(x => x.GetAsync(It.IsAny>())) - .ReturnsAsync(entitiesMock.ToArray()) - .Verifiable(); + .ReturnsAsync(entitiesMock.ToArray()); this.mapperWrapper .Setup(x => x.Map(It.IsAny())) @@ -39,49 +34,47 @@ public async Task GetByUsersAsync_ValidUser_ReturnsTransactions() .Returns>((ent) => this.mapper.Map>(ent)) .Verifiable(); + this.SetUpMapper(); + var result = await this.service.GetAllByUserAsync(string.Empty, filter); Assert.IsInstanceOf>>(result); Assert.IsFalse(result.HasError); - Assert.AreEqual(entitiesMock.Count(), result.Data.Count); - - this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); - this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); - this.repository.Verify(x => x.GetAsync(It.IsAny>()), Times.Once()); + Assert.AreEqual(entitiesMock.Count, result.Data.Count); } - - [Test] - [TestCase(Description = "Get by user repository exception", Category = "Get")] - public void GetByUsersAsync_RepositoryException_ThrowsException() + [Test] + public async Task GetByIdAsync_ExistingTransaction_ReturnsTransaction() { - var filter = new TransactionFilter(); + var id = Guid.NewGuid(); + var transaction = this.transactionBuilder + .WithId(id) + .Generate(); - var entitiesMock = this.GenerateTransactions(); - var exc = new Exception("mock"); + this.repository + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(transaction); - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); + this.SetUpMapper(); - this.repository - .Setup(x => x.GetAsync(It.IsAny>())) - .Throws(exc) - .Verifiable(); + var result = await this.service.GetByIdAsync(id); - this.mapperWrapper - .Setup(x => x.Map>(It.IsAny>())) - .Returns>((ent) => this.mapper.Map>(ent)) - .Verifiable(); + Assert.IsFalse(result.HasError); + Assert.IsInstanceOf>(result); + Assert.AreEqual(transaction.Id, result.Data.Id); + } + + [Test] + public async Task GetByIdAsync_NonExistingTransaction_ReturnsNotFoundError() + { + var id = Guid.NewGuid(); + + this.SetUpMapper(); - var exception = Assert.ThrowsAsync( - async ()=> await this.service.GetAllByUserAsync(string.Empty, filter) - ); + var result = await this.service.GetByIdAsync(id); - Assert.IsInstanceOf(exc.GetType(), exception); - this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); - this.repository.Verify(x => x.GetAsync(It.IsAny>()), Times.Once()); + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Transaction with id {id}", result.Error.Message); } } } diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs index 4455ee7..e331a2a 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs +++ b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs @@ -1,21 +1,29 @@ -using FinancialHub.Domain.Entities; +using Moq; +using NUnit.Framework; +using System.Threading.Tasks; +using FinancialHub.Domain.Entities; using FinancialHub.Domain.Models; using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; +using FinancialHub.Domain.Enums; using System; -using System.Threading.Tasks; namespace FinancialHub.Services.NUnitTests.Services { public partial class TransactionsServiceTests { [Test] - [TestCase(Description = "Update valid Transaction", Category = "Update")] - public async Task UpdateAsync_ValidTransactionModel_ReturnsTransactionModel() + public async Task UpdateAsync_ValidTransaction_UpdatesTransaction() { var model = this.transactionModelBuilder.Generate(); + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(this.mapper.Map(model.Balance)) + .Verifiable(); + this.repository .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) .ReturnsAsync(this.mapper.Map(model)) @@ -26,30 +34,270 @@ public async Task UpdateAsync_ValidTransactionModel_ReturnsTransactionModel() .Returns(async (x) => await Task.FromResult(x)) .Verifiable(); - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) + this.SetUpMapper(); + + await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); + } + + [TestCase(TransactionStatus.NotCommitted, true, TransactionStatus.Committed, true)] + [TestCase(TransactionStatus.Committed, false, TransactionStatus.Committed, true)] + [TestCase(TransactionStatus.NotCommitted, false, TransactionStatus.Committed, true)] + public async Task UpdateAsync_CommitedAndActiveTransaction_AddsBalance( + TransactionStatus oldStatus, bool oldIsActive, + TransactionStatus newStatus, bool newIsActive) + { + var oldModel = this.transactionBuilder + .WithStatus(oldStatus) + .WithActiveStatus(oldIsActive) + .Generate(); + var model = this.transactionModelBuilder + .WithStatus(newStatus) + .WithActiveStatus(newIsActive) + .Generate(); + + var balance = this.mapper.Map(model.Balance); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(balance) + .Verifiable(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(oldModel) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + + await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + this.balancesRepository.Verify(x => x.ChangeAmountAsync(balance.Id.GetValueOrDefault(),model.Amount, model.Type,false)); + } + + [TestCase(TransactionStatus.Committed, true, TransactionStatus.NotCommitted, true)] + [TestCase(TransactionStatus.Committed, true, TransactionStatus.NotCommitted, false)] + [TestCase(TransactionStatus.Committed, true, TransactionStatus.Committed, false)] + public async Task UpdateAsync_NotCommitedOrInactiveTransaction_RemovesBalance( + TransactionStatus oldStatus, bool oldIsActive, + TransactionStatus newStatus, bool newIsActive) + { + var oldModel = this.transactionBuilder + .WithStatus(oldStatus) + .WithActiveStatus(oldIsActive) + .Generate(); + var model = this.transactionModelBuilder + .WithStatus(newStatus) + .WithActiveStatus(newIsActive) + .Generate(); + + var balance = this.mapper.Map(model.Balance); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(balance) + .Verifiable(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(oldModel) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + + await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + this.balancesRepository.Verify(x => x.ChangeAmountAsync(balance.Id.GetValueOrDefault(),model.Amount, model.Type,true)); + //this.balancesRepository.Verify(x => x.RemoveAmountAsync(It.IsAny()), Times.Once); + } + + [TestCase(TransactionStatus.NotCommitted, true, TransactionStatus.NotCommitted, true)] + [TestCase(TransactionStatus.NotCommitted, true, TransactionStatus.Committed, false)] + [TestCase(TransactionStatus.NotCommitted, true, TransactionStatus.NotCommitted, false)] + [TestCase(TransactionStatus.NotCommitted, false, TransactionStatus.NotCommitted, true)] + [TestCase(TransactionStatus.NotCommitted, false, TransactionStatus.NotCommitted, false)] + [TestCase(TransactionStatus.NotCommitted, false, TransactionStatus.Committed, false)] + [TestCase(TransactionStatus.Committed, false, TransactionStatus.NotCommitted, true)] + [TestCase(TransactionStatus.Committed, false, TransactionStatus.NotCommitted, false)] + [TestCase(TransactionStatus.Committed, false, TransactionStatus.Committed, false)] + public async Task UpdateAsync_NoStatusOrTypeChanges_DoesNotUpdate( + TransactionStatus oldStatus, bool oldIsActive, + TransactionStatus newStatus, bool newIsActive) + { + var oldModel = this.transactionBuilder + .WithStatus(oldStatus) + .WithActiveStatus(oldIsActive) + .Generate(); + var model = this.transactionModelBuilder + .WithStatus(newStatus) + .WithActiveStatus(newIsActive) + .Generate(); + + var balance = this.mapper.Map(model.Balance); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(balance) + .Verifiable(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(oldModel) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + + await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + this.balancesRepository.Verify(x => x.ChangeAmountAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); + } + + [Test] + public async Task UpdateAsync_DifferentAmounts_ChangesBalance() + { + var oldAmount = random.Next(1, 10); + var oldModel = this.transactionBuilder + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .WithAmount(oldAmount) + .Generate(); + var balance = this.mapper.Map(oldModel.Balance); + + var newAmount = random.Next(11, 100); + var model = this.transactionModelBuilder + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .WithBalanceId(balance.Id) + .WithAmount(newAmount) + .Generate(); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(balance) + .Verifiable(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(oldModel) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + + await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + this.balancesRepository.Verify(x => x.ChangeAmountAsync(model.BalanceId, oldAmount - newAmount, model.Type, false), Times.Once); + } + + [Test] + public async Task UpdateAsync_BalanceChanges_MoveAmountsFromOldBalanceToNewBalance() + { + var oldAmount = random.Next(1,10); + var oldModel = this.transactionBuilder + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .WithAmount(oldAmount) + .Generate(); + var oldBalance = this.mapper.Map(oldModel.Balance); + + var newAmount = random.Next(11,100); + var model = this.transactionModelBuilder + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .WithAmount(newAmount) + .Generate(); + var balance = this.mapper.Map(model.Balance); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(oldModel.BalanceId)) + .ReturnsAsync(oldBalance) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(balance) + .Verifiable(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(oldModel) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + + await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + this.balancesRepository.Verify(x => x.ChangeAmountAsync(oldModel.BalanceId, oldAmount, oldModel.Type, true), Times.Once); + this.balancesRepository.Verify(x => x.ChangeAmountAsync(model.BalanceId, newAmount, model.Type, false),Times.Once); + } + + [Test] + public async Task UpdateAsync_ValidTransaction_ReturnsTransaction() + { + var model = this.transactionModelBuilder.Generate(); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(this.mapper.Map(model.Balance)) .Verifiable(); - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) .Verifiable(); + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); Assert.IsNotNull(result); Assert.IsInstanceOf>(result); - - this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); - - this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); - this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); } [Test] - [TestCase(Description = "Update non existing Transaction", Category = "Update")] public async Task UpdateAsync_NonExistingTransactionId_ReturnsResultError() { var model = this.transactionModelBuilder.Generate(); @@ -68,44 +316,50 @@ public async Task UpdateAsync_NonExistingTransactionId_ReturnsResultError() Assert.IsInstanceOf>(result); Assert.IsTrue(result.HasError); - - this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); } [Test] - [TestCase(Description = "Update repository exception", Category = "Update")] - public void UpdateAsync_RepositoryException_ThrowsException() + public async Task UpdateAsync_InvalidCategory_ReturnsNotFoundError() { var model = this.transactionModelBuilder.Generate(); - var exc = new Exception("mock"); + + this.SetUpMapper(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(this.mapper.Map(model.Balance)) + .Verifiable(); this.repository .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) .ReturnsAsync(this.mapper.Map(model)) .Verifiable(); - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Throws(exc) - .Verifiable(); + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error.Message); + } + + [Test] + public async Task UpdateAsync_InvalidBalance_ReturnsNotFoundError() + { + var model = this.transactionModelBuilder.Generate(); + + this.SetUpMapper(); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) .Verifiable(); - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) .Verifiable(); - var exception = Assert.ThrowsAsync( - async () => await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model) - ); + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once()); + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error.Message); } } } diff --git a/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs b/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs index 4bb5246..c369c28 100644 --- a/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs +++ b/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs @@ -14,6 +14,7 @@ public FinancialHubAutoMapperProfile() CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); + CreateMap().ReverseMap(); //Queries CreateMap().ReverseMap(); diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs new file mode 100644 index 0000000..b8dd357 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs @@ -0,0 +1,76 @@ +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; + +namespace FinancialHub.Services.Services +{ + public class AccountBalanceService : IAccountBalanceService + { + private readonly IBalancesService balancesService; + private readonly IAccountsService accountsService; + + public AccountBalanceService(IBalancesService balancesService,IAccountsService accountsService) + { + this.balancesService = balancesService; + this.accountsService = accountsService; + } + + public async Task> CreateAsync(AccountModel account) + { + var createdAccount = await this.accountsService.CreateAsync(account); + + if(createdAccount.HasError) + { + return createdAccount.Error; + } + + var balance = new BalanceModel() + { + Name = $"{createdAccount.Data.Name} Default Balance", + AccountId = createdAccount.Data.Id.GetValueOrDefault(), + IsActive = createdAccount.Data.IsActive + }; + var createdBalance = await this.balancesService.CreateAsync(balance); + + if (createdBalance.HasError) + { + return createdBalance.Error; + } + + return createdAccount; + } + + public async Task> DeleteAsync(Guid accountId) + { + int removedLines = 0; + + var balances = await this.balancesService.GetAllByAccountAsync(accountId); + + foreach (var balance in balances.Data) + { + var balanceResult = await this.balancesService.DeleteAsync(balance.Id.GetValueOrDefault()); + if (balanceResult.HasError) + { + return balanceResult.Error; + } + + removedLines += balanceResult.Data; + } + + var accountResult = await this.accountsService.DeleteAsync(accountId); + if (accountResult.HasError) + { + return accountResult.Error; + } + + removedLines += accountResult.Data; + + return removedLines; + } + + public async Task>> GetBalancesByAccountAsync(Guid accountId) + { + return await this.balancesService.GetAllByAccountAsync(accountId); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs index fdd916e..34a6445 100644 --- a/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs +++ b/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs @@ -1,5 +1,4 @@ -using AutoMapper; -using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Mappers; using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Domain.Interfaces.Services; diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs new file mode 100644 index 0000000..23aaebf --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs @@ -0,0 +1,104 @@ +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Results.Errors; + +namespace FinancialHub.Services.Services +{ + public class BalancesService : IBalancesService + { + private readonly IMapperWrapper mapper; + private readonly IBalancesRepository repository; + private readonly IAccountsRepository accountsRepository; + + public BalancesService(IMapperWrapper mapper, + IBalancesRepository repository, IAccountsRepository accountsRepository + ) + { + this.mapper = mapper; + this.repository = repository; + this.accountsRepository = accountsRepository; + } + + private async Task ValidateAccountAsync(BalanceEntity balance) + { + var accountResult = await this.accountsRepository.GetByIdAsync(balance.AccountId); + + if(accountResult == null) + { + return new NotFoundError($"Not found Account with id {balance.AccountId}"); + } + + return new ServiceResult(); + } + + public async Task> CreateAsync(BalanceModel balance) + { + var entity = this.mapper.Map(balance); + entity.Amount = 0; + + var validationResult = await this.ValidateAccountAsync(entity); + if (validationResult.HasError) + { + return validationResult.Error; + } + + entity = await this.repository.CreateAsync(entity); + + return mapper.Map(entity); + } + + public async Task> DeleteAsync(Guid id) + { + var count = await this.repository.DeleteAsync(id); + + return new ServiceResult(count); + } + + public async Task> GetByIdAsync(Guid id) + { + var entity = await this.repository.GetByIdAsync(id); + + if(entity == null) + { + return new NotFoundError($"Not found Balance with id {id}"); + } + + return this.mapper.Map(entity); + } + + public async Task>> GetAllByAccountAsync(Guid accountId) + { + var entities = await this.repository.GetAsync(x => x.AccountId == accountId); + + var list = this.mapper.Map>(entities); + + return list.ToArray(); + } + + public async Task> UpdateAsync(Guid id, BalanceModel balance) + { + var entityResult = await this.GetByIdAsync(id); + if (entityResult.HasError) + { + return entityResult.Error; + } + + var entity = this.mapper.Map(balance); + entity.Id = id; + + var validationResult = await this.ValidateAccountAsync(entity); + if (validationResult.HasError) + { + return validationResult.Error; + } + + entity = await this.repository.UpdateAsync(entity); + + return mapper.Map(entity); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs b/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs index ca4c480..e5e63a4 100644 --- a/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs +++ b/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs @@ -7,6 +7,7 @@ using FinancialHub.Domain.Interfaces.Mappers; using FinancialHub.Domain.Results; using FinancialHub.Domain.Results.Errors; +using FinancialHub.Domain.Enums; namespace FinancialHub.Services.Services { @@ -14,24 +15,72 @@ public class TransactionsService : ITransactionsService { private readonly IMapperWrapper mapper; private readonly ITransactionsRepository repository; + private readonly IBalancesRepository balancesRepository; + private readonly ICategoriesRepository categoriesRepository; - public TransactionsService(IMapperWrapper mapper, ITransactionsRepository repository) + public TransactionsService( + IMapperWrapper mapper, + ITransactionsRepository repository, + IBalancesRepository balancesRepository, ICategoriesRepository categoriesRepository + ) { this.mapper = mapper; this.repository = repository; + this.balancesRepository = balancesRepository; + this.categoriesRepository = categoriesRepository; } - public async Task> CreateAsync(TransactionModel category) + private async Task> ValidateTransaction(TransactionEntity transaction) { - var entity = mapper.Map(category); + var balance = await this.balancesRepository.GetByIdAsync(transaction.BalanceId); + if (balance == null) + { + return new NotFoundError($"Not found Balance with id {transaction.BalanceId}"); + } + + var category = await this.categoriesRepository.GetByIdAsync(transaction.CategoryId); + if (category == null) + { + return new NotFoundError($"Not found Category with id {transaction.CategoryId}"); + } + + return true; + } + + public async Task> CreateAsync(TransactionModel transaction) + { + var entity = mapper.Map(transaction); + + var validation = await this.ValidateTransaction(entity); + if (validation.HasError) + { + return new ServiceResult(error: validation.Error); + } entity = await this.repository.CreateAsync(entity); + if (entity.Status == TransactionStatus.Committed && entity.IsActive) + { + await this.balancesRepository.ChangeAmountAsync(entity.BalanceId,entity.Amount,entity.Type); + } + return mapper.Map(entity); } public async Task> DeleteAsync(Guid id) { + var transactionResult = await this.GetByIdAsync(id); + if (transactionResult.HasError) + { + return transactionResult.Error; + } + var transaction = transactionResult.Data; + + if (transaction.Status == TransactionStatus.Committed && transaction.IsActive) + { + await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type,true); + } + return await this.repository.DeleteAsync(id); } @@ -49,18 +98,56 @@ public async Task>> GetAllByUserAsyn public async Task> UpdateAsync(Guid id, TransactionModel transaction) { - var entity = await this.repository.GetByIdAsync(id); + var oldTransactionResult = await this.GetByIdAsync(id); + if (oldTransactionResult.HasError) + { + return oldTransactionResult.Error; + } + var oldTransaction = oldTransactionResult.Data; + var newTransaction = this.mapper.Map(transaction); - if (entity == null) + var validation = await this.ValidateTransaction(newTransaction); + if (validation.HasError) { - return new NotFoundError($"Not found Transaction with id {id}"); + return new ServiceResult(error: validation.Error); } - entity = this.mapper.Map(transaction); + newTransaction = await this.repository.UpdateAsync(newTransaction); - entity = await this.repository.UpdateAsync(entity); + if (transaction.IsPaid && oldTransaction.IsPaid) + { + if (transaction.BalanceId != oldTransaction.BalanceId) + { + await this.balancesRepository.ChangeAmountAsync(oldTransaction.BalanceId, oldTransaction.Amount, oldTransaction.Type, true); + await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type); + } + else if(transaction.Amount != oldTransaction.Amount) + { + var amountDifference = oldTransaction.Amount - transaction.Amount; + await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, amountDifference, transaction.Type); + } + } + else if (transaction.IsPaid && (!oldTransaction.IsActive || transaction.Status != oldTransaction.Status)) + { + await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type); + } + else if (oldTransaction.IsPaid && (!transaction.IsActive || transaction.Status != oldTransaction.Status)) + { + await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type, true); + } - return mapper.Map(entity); + return mapper.Map(newTransaction); + } + + public async Task> GetByIdAsync(Guid id) + { + var transaction = await this.repository.GetByIdAsync(id); + if (transaction == null) + { + return new NotFoundError($"Not found Transaction with id {id}"); + } + + return mapper.Map(transaction); } } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs index 71888bf..38469f5 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs @@ -20,7 +20,7 @@ public async Task CreateAccount_ServiceSuccess_ReturnsOk() var body = this.accountModelBuilder.Generate(); var mockResult = new ServiceResult(body); - this.mockService + this.mockAccountService .Setup(x => x.CreateAsync(body)) .ReturnsAsync(mockResult) .Verifiable(); @@ -35,7 +35,7 @@ public async Task CreateAccount_ServiceSuccess_ReturnsOk() var listResponse = result?.Value as SaveResponse; Assert.AreEqual(mockResult.Data, listResponse?.Data); - this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + this.mockAccountService.Verify(x => x.CreateAsync(body), Times.Once); } [Test] @@ -47,7 +47,7 @@ public async Task CreateAccount_ServiceError_ReturnsBadRequest() var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - this.mockService + this.mockAccountService .Setup(x => x.CreateAsync(body)) .ReturnsAsync(mockResult) .Verifiable(); @@ -63,7 +63,7 @@ public async Task CreateAccount_ServiceError_ReturnsBadRequest() Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); - this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + this.mockAccountService.Verify(x => x.CreateAsync(body), Times.Once); } } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs index 70dcfca..c63f396 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs @@ -7,10 +7,6 @@ namespace FinancialHub.WebApi.NUnitTests.Controllers { - //TODO: start to use : - //https://docs.educationsmediagroup.com/unit-testing-csharp/nunit/parameterized-tests - //or - //https://docs.nunit.org/articles/nunit/writing-tests/attributes/theory.html public partial class AccountsControllerTests { private Random random; @@ -19,6 +15,7 @@ public partial class AccountsControllerTests private AccountsController controller; private Mock mockService; + private Mock mockAccountService; [SetUp] public void Setup() @@ -28,7 +25,8 @@ public void Setup() this.accountModelBuilder = new AccountModelBuilder(); this.mockService = new Mock(); - this.controller = new AccountsController(this.mockService.Object); + this.mockAccountService = new Mock(); + this.controller = new AccountsController(mockAccountService.Object ,this.mockService.Object); } } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs new file mode 100644 index 0000000..cd80f89 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs @@ -0,0 +1,68 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Results.Errors; +using Microsoft.AspNetCore.Mvc; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class BalancesControllerTests + { + [Test] + public async Task CreateBalance_ServiceSuccess_ReturnsOk() + { + var body = this.balanceModelBuilder.Generate(); + var mockResult = new ServiceResult(body); + + this.mockService + .Setup(x => x.CreateAsync(body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.CreateBalance(body); + + var result = response as ObjectResult; + + Assert.AreEqual(200, result?.StatusCode); + Assert.IsInstanceOf>(result?.Value); + + var listResponse = result?.Value as SaveResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + } + + [Test] + [TestCase(Description = "Create account returns Bad Request", Category = "Create")] + public async Task CreateBalance_ServiceError_ReturnsBadRequest() + { + var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; + var body = this.balanceModelBuilder.Generate(); + + var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); + + this.mockService + .Setup(x => x.CreateAsync(body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.CreateBalance(body); + + var result = response as ObjectResult; + + Assert.AreEqual(400, result?.StatusCode); + Assert.IsInstanceOf(result?.Value); + + var listResponse = result?.Value as ValidationErrorResponse; + Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + + this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs new file mode 100644 index 0000000..abe26a8 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs @@ -0,0 +1,30 @@ +using Moq; +using NUnit.Framework; +using FinancialHub.WebApi.Controllers; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Tests.Builders.Models; +using System; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class BalancesControllerTests + { + private Random random; + + private BalanceModelBuilder balanceModelBuilder; + + private BalancesController controller; + private Mock mockService; + + [SetUp] + public void Setup() + { + this.random = new Random(); + + this.balanceModelBuilder = new BalanceModelBuilder(); + + this.mockService = new Mock(); + this.controller = new BalancesController(this.mockService.Object); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs new file mode 100644 index 0000000..703ab02 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Mvc; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class BalancesControllerTests + { + [Test] + public async Task DeleteMyBalances_ServiceSuccess_ReturnsNoContent() + { + var mock = this.balanceModelBuilder.Generate(); + var response = await this.controller.DeleteBalance(mock.Id.GetValueOrDefault()); + + var result = response as ObjectResult; + + Assert.IsNull(result?.Value); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs new file mode 100644 index 0000000..65b3094 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs @@ -0,0 +1,69 @@ +using System; +using System.Threading.Tasks; +using NUnit.Framework; +using Moq; +using Microsoft.AspNetCore.Mvc; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Results.Errors; +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; + +namespace FinancialHub.WebApi.NUnitTests.Controllers +{ + public partial class BalancesControllerTests + { + [Test] + public async Task UpdateBalance_Valid_ReturnsOk() + { + var body = this.balanceModelBuilder.Generate(); + var guid = body.Id.GetValueOrDefault(); + var mockResult = new ServiceResult(body); + + this.mockService + .Setup(x => x.UpdateAsync(guid, body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.UpdateBalance(guid, body); + + var result = response as ObjectResult; + + Assert.AreEqual(200, result?.StatusCode); + Assert.IsInstanceOf>(result?.Value); + + var listResponse = result?.Value as SaveResponse; + Assert.AreEqual(mockResult.Data, listResponse?.Data); + + this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); + } + + [Test] + public async Task UpdateBalance_Invalid_ReturnsBadRequest() + { + var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; + var body = this.balanceModelBuilder.Generate(); + var guid = body.Id.GetValueOrDefault(); + + var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); + + this.mockService + .Setup(x => x.UpdateAsync(guid,body)) + .ReturnsAsync(mockResult) + .Verifiable(); + + var response = await this.controller.UpdateBalance(guid,body); + + var result = response as ObjectResult; + + Assert.AreEqual(400, result?.StatusCode); + Assert.IsInstanceOf(result?.Value); + + var listResponse = result?.Value as ValidationErrorResponse; + Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + + this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs new file mode 100644 index 0000000..d6770e3 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs @@ -0,0 +1,85 @@ +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.WebApi.Validators; +using NUnit.Framework; + +namespace FinancialHub.WebApi.NUnitTests.Validators +{ + public class AccountValidatorTests + { + private AccountModelBuilder builder; + private readonly AccountValidator validator; + + public AccountValidatorTests() + { + this.validator = new AccountValidator(); + } + + [SetUp] + public void SetUp() + { + this.builder = new AccountModelBuilder(); + } + + [Test] + public void Account_Valid_ReturnsSuccess() + { + var account = builder.Generate(); + + var result = validator.Validate(account); + + Assert.IsTrue(result.IsValid); + Assert.IsEmpty(result.Errors); + } + + [TestCase("")] + [TestCase(null)] + public void Account_NullOrEmptyName_ReturnsRequiredError(string invalidName) + { + var account = builder.WithName(invalidName).Generate(); + + var result = validator.Validate(account); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual("Name is required",result.Errors[0].ErrorMessage); + } + + [Test] + public void Account_BigName_ReturnsMaxLengthError() + { + var invalidName = new string('a',201); + var account = builder.WithName(invalidName).Generate(); + + var result = validator.Validate(account); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual($"Name exceeds the max length of 200", result.Errors[0].ErrorMessage); + } + + [TestCase("")] + [TestCase(null)] + public void Account_NullOrEmptyDescription_ReturnsSuccess(string description) + { + var account = builder.WithDescription(description).Generate(); + + var result = validator.Validate(account); + + Assert.IsTrue(result.IsValid); + Assert.IsEmpty(result.Errors); + } + + [Test] + public void Account_BigDescription_ReturnsMaxLengthError() + { + var invalidDescription = new string('a', 501); + var account = builder.WithDescription(invalidDescription).Generate(); + + var result = validator.Validate(account); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual($"Description exceeds the max length of 500", result.Errors[0].ErrorMessage); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs new file mode 100644 index 0000000..a2c9d62 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs @@ -0,0 +1,86 @@ +using NUnit.Framework; +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.WebApi.Validators; +using System; + +namespace FinancialHub.WebApi.NUnitTests.Validators +{ + public class BalanceValidatorTests + { + private BalanceModelBuilder builder; + private readonly BalanceValidator validator; + + public BalanceValidatorTests() + { + this.validator = new BalanceValidator(); + } + + [SetUp] + public void SetUp() + { + this.builder = new BalanceModelBuilder(); + } + + [Test] + public void Balance_Valid_ReturnsSuccess() + { + var balance = builder.Generate(); + + var result = validator.Validate(balance); + + Assert.IsTrue(result.IsValid); + Assert.IsEmpty(result.Errors); + } + + [TestCase("")] + [TestCase(null)] + public void Balance_NullOrEmptyName_ReturnsRequiredError(string invalidName) + { + var account = builder.WithName(invalidName).Generate(); + + var result = validator.Validate(account); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual("Name is required", result.Errors[0].ErrorMessage); + } + + [Test] + public void Balance_BigName_ReturnsMaxLengthError() + { + var invalidName = new string('a', 201); + var account = builder.WithName(invalidName).Generate(); + + var result = validator.Validate(account); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual($"Name exceeds the max length of 200", result.Errors[0].ErrorMessage); + } + + [Test] + public void Balance_EmptyAccountId_ReturnsRequiredError() + { + var invalidId = Guid.Empty; + var account = builder.WithAccountId(invalidId).Generate(); + + var result = validator.Validate(account); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual("Account Id is required", result.Errors[0].ErrorMessage); + } + + [Test] + public void Balance_NullAccountId_ReturnsRequiredError() + { + var account = builder.WithAccountId((Guid)default).Generate(); + + var result = validator.Validate(account); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual("Account Id is required", result.Errors[0].ErrorMessage); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs new file mode 100644 index 0000000..583967b --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs @@ -0,0 +1,85 @@ +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.WebApi.Validators; +using NUnit.Framework; + +namespace FinancialHub.WebApi.NUnitTests.Validators +{ + public class CategoryValidatorTests + { + private CategoryModelBuilder builder; + private readonly CategoryValidator validator; + + public CategoryValidatorTests() + { + this.validator = new CategoryValidator(); + } + + [SetUp] + public void SetUp() + { + this.builder = new CategoryModelBuilder(); + } + + [Test] + public void CategoryValidator_ValidCategory_ReturnsSuccess() + { + var category = builder.Generate(); + + var result = validator.Validate(category); + + Assert.IsTrue(result.IsValid); + Assert.IsEmpty(result.Errors); + } + + [TestCase("")] + [TestCase(null)] + public void CategoryValidator_NullOrEmptyName_ReturnsRequiredError(string invalidName) + { + var category = builder.WithName(invalidName).Generate(); + + var result = validator.Validate(category); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual("Name is required", result.Errors[0].ErrorMessage); + } + + [Test] + public void CategoryValidator_BigName_ReturnsMaxLengthError() + { + var invalidName = new string('a', 201); + var category = builder.WithName(invalidName).Generate(); + + var result = validator.Validate(category); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual($"Name exceeds the max length of 200", result.Errors[0].ErrorMessage); + } + + [TestCase("")] + [TestCase(null)] + public void CategoryValidator_NullOrEmptyDescription_ReturnsSuccess(string description) + { + var category = builder.WithDescription(description).Generate(); + + var result = validator.Validate(category); + + Assert.IsTrue(result.IsValid); + Assert.IsEmpty(result.Errors); + } + + [Test] + public void CategoryValidator_BigDescription_ReturnsMaxLengthError() + { + var invalidDescription = new string('a', 501); + var category = builder.WithDescription(invalidDescription).Generate(); + + var result = validator.Validate(category); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual($"Description exceeds the max length of 500", result.Errors[0].ErrorMessage); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs new file mode 100644 index 0000000..0d82eae --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs @@ -0,0 +1,86 @@ +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.WebApi.Validators; +using NUnit.Framework; + +namespace FinancialHub.WebApi.NUnitTests.Validators +{ + public class TransactionValidatorTests + { + private TransactionModelBuilder builder; + private readonly TransactionValidator validator; + + public TransactionValidatorTests() + { + this.validator = new TransactionValidator(); + } + + [SetUp] + public void SetUp() + { + this.builder = new TransactionModelBuilder(); + } + + [Test] + public void TransactionValidator_ValidCategory_ReturnsSuccess() + { + var transaction = builder.Generate(); + + var result = validator.Validate(transaction); + + Assert.IsTrue(result.IsValid); + Assert.IsEmpty(result.Errors); + } + + [TestCase("")] + [TestCase(null)] + public void TransactionValidator_NullOrEmptyDescription_ReturnsSuccess(string description) + { + var transaction = builder.WithDescription(description).Generate(); + + var result = validator.Validate(transaction); + + Assert.IsTrue(result.IsValid); + Assert.IsEmpty(result.Errors); + } + + [Test] + public void TransactionValidator_BigDescription_ReturnsMaxLengthError() + { + var invalidDescription = new string('a', 501); + var transaction = builder.WithDescription(invalidDescription).Generate(); + + var result = validator.Validate(transaction); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual("Description exceeds the max length of 500", result.Errors[0].ErrorMessage); + } + + [Test] + public void TransactionValidator_TypeOutOfEnum_ReturnsError() + { + var type = 999; + var transaction = builder.WithType((TransactionType)type).Generate(); + + var result = validator.Validate(transaction); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual("Type has a range of values which does not include '999'", result.Errors[0].ErrorMessage); + } + + [Test] + public void TransactionValidator_StatusOutOfEnum_ReturnsError() + { + var status = 999; + var transaction = builder.WithStatus((TransactionStatus)status).Generate(); + + var result = validator.Validate(transaction); + + Assert.IsFalse(result.IsValid); + Assert.IsNotEmpty(result.Errors); + Assert.AreEqual("Status has a range of values which does not include '999'", result.Errors[0].ErrorMessage); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs index f9e16f0..253219b 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs @@ -14,13 +14,24 @@ namespace FinancialHub.WebApi.Controllers [ProducesErrorResponseType(typeof(Exception))] public class AccountsController : Controller { + private readonly IAccountBalanceService accountBalanceService; private readonly IAccountsService service; - public AccountsController(IAccountsService service) + public AccountsController(IAccountBalanceService accountBalanceService,IAccountsService service) { + this.accountBalanceService = accountBalanceService; this.service = service; } + [HttpGet("{accountId}/balances")] + [ProducesResponseType(typeof(ListResponse), 200)] + public async Task GetAccountBalances([FromRoute] Guid accountId) + { + var result = await this.accountBalanceService.GetBalancesByAccountAsync(accountId); + + return Ok(new ListResponse(result.Data)); + } + /// /// Get all accounts of the system (will be changed to only one user) /// @@ -42,7 +53,7 @@ public async Task GetMyAccounts() [ProducesResponseType(typeof(ValidationErrorResponse), 400)] public async Task CreateAccount([FromBody] AccountModel account) { - var result = await service.CreateAsync(account); + var result = await this.accountBalanceService.CreateAsync(account); if (result.HasError) { @@ -52,7 +63,7 @@ public async Task CreateAccount([FromBody] AccountModel account) ); } - return Ok( new SaveResponse(result.Data)); + return Ok(new SaveResponse(result.Data)); } /// @@ -86,7 +97,7 @@ public async Task UpdateAccount([FromRoute] Guid id, [FromBody] A [HttpDelete("{id}")] public async Task DeleteAccount([FromRoute] Guid id) { - await service.DeleteAsync(id); + await accountBalanceService.DeleteAsync(id); return NoContent(); } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs new file mode 100644 index 0000000..dbdc668 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs @@ -0,0 +1,68 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Responses.Success; +using FinancialHub.Domain.Responses.Errors; + +namespace FinancialHub.WebApi.Controllers +{ + [ApiController] + [Route("[controller]")] + [Produces("application/json")] + [ProducesErrorResponseType(typeof(Exception))] + public class BalancesController : Controller + { + private readonly IBalancesService service; + + public BalancesController(IBalancesService service) + { + this.service = service; + } + + [HttpPost] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] + public async Task CreateBalance([FromBody] BalanceModel balance) + { + var result = await this.service.CreateAsync(balance); + + if (result.HasError) + { + return StatusCode( + result.Error.Code, + new ValidationErrorResponse(result.Error.Message) + ); + } + + return Ok(new SaveResponse(result.Data)); + } + + [HttpPut("{id}")] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(NotFoundErrorResponse), 404)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] + public async Task UpdateBalance([FromRoute] Guid id, [FromBody] BalanceModel balance) + { + var response = await this.service.UpdateAsync(id, balance); + + if (response.HasError) + { + return StatusCode( + response.Error.Code, + new ValidationErrorResponse(response.Error.Message) + ); + } + + return Ok(new SaveResponse(response.Data)); + } + + [HttpDelete("{id}")] + public async Task DeleteBalance([FromRoute] Guid id) + { + await this.service.DeleteAsync(id); + return NoContent(); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs index 68218d8..d3956db 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs @@ -41,7 +41,7 @@ public async Task GetMyTransactions([FromQuery] TransactionFilter /// Transaction to be created public async Task CreateTransaction([FromBody] TransactionModel transaction) { - var result = await service.CreateAsync(transaction); + var result = await this.service.CreateAsync(transaction); if (result.HasError) { @@ -64,7 +64,7 @@ public async Task CreateTransaction([FromBody] TransactionModel t /// transaction changes public async Task UpdateTransaction([FromRoute] Guid id, [FromBody] TransactionModel transaction) { - var result = await service.UpdateAsync(id, transaction); + var result = await this.service.UpdateAsync(id, transaction); if (result.HasError) { diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs index 69ac8b9..907ad07 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -7,7 +7,11 @@ using Microsoft.Extensions.DependencyInjection; using FinancialHub.Domain.Interfaces.Mappers; using FinancialHub.Services.Mappers; +using FluentValidation; using FinancialHub.Domain.Mappers; +using FinancialHub.Domain.Models; +using FinancialHub.WebApi.Validators; +using FluentValidation.AspNetCore; namespace FinancialHub.WebApi.Extensions.Configurations { @@ -30,6 +34,8 @@ public static IServiceCollection AddRepositories(this IServiceCollection service services.AddScoped(); services.AddScoped(); services.AddScoped(); + + services.AddScoped(); return services; } @@ -41,6 +47,22 @@ public static IServiceCollection AddServices(this IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); + + services.AddScoped(); + return services; + } + + public static IServiceCollection AddValidators(this IServiceCollection services) + { + services.AddFluentValidation(x => + { + x.AutomaticValidationEnabled = true; + x.DisableDataAnnotationsValidation = true; + }); + services.AddScoped, AccountValidator>(); + services.AddScoped, CategoryValidator>(); + services.AddScoped, TransactionValidator>(); return services; } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj index 9298059..90afc92 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -10,6 +10,7 @@ + @@ -35,4 +36,19 @@ + + + True + True + ErrorMessages.resx + + + + + + ResXFileCodeGenerator + ErrorMessages.Designer.cs + + + diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs b/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs deleted file mode 100644 index 6fa98d6..0000000 --- a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHubAutoMapperProfile.cs +++ /dev/null @@ -1,22 +0,0 @@ -using AutoMapper; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Filters; -using FinancialHub.Domain.Queries; - -namespace FinancialHub.WebApi -{ - public class FinancialHubAutoMapperProfile : Profile - { - public FinancialHubAutoMapperProfile() - { - //Entities - CreateMap().ReverseMap(); - CreateMap().ReverseMap(); - CreateMap().ReverseMap(); - - //Queries - CreateMap().ReverseMap(); - } - } -} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs b/api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs new file mode 100644 index 0000000..346f095 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs @@ -0,0 +1,99 @@ +//------------------------------------------------------------------------------ +// +// O código foi gerado por uma ferramenta. +// Versão de Tempo de Execução:4.0.30319.42000 +// +// As alterações ao arquivo poderão causar comportamento incorreto e serão perdidas se +// o código for gerado novamente. +// +//------------------------------------------------------------------------------ + +namespace FinancialHub.WebApi.Resources { + using System; + + + /// + /// Uma classe de recurso de tipo de alta segurança, para pesquisar cadeias de caracteres localizadas etc. + /// + // Essa classe foi gerada automaticamente pela classe StronglyTypedResourceBuilder + // através de uma ferramenta como ResGen ou Visual Studio. + // Para adicionar ou remover um associado, edite o arquivo .ResX e execute ResGen novamente + // com a opção /str, ou recrie o projeto do VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class ErrorMessages { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ErrorMessages() { + } + + /// + /// Retorna a instância de ResourceManager armazenada em cache usada por essa classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.WebApi.Resources.ErrorMessages", typeof(ErrorMessages).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Substitui a propriedade CurrentUICulture do thread atual para todas as + /// pesquisas de recursos que usam essa classe de recurso de tipo de alta segurança. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} exceeds the max length of {MaxLength}. + /// + internal static string ExceedMaxLength { + get { + return ResourceManager.GetString("ExceedMaxLength", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} must be greater than {ComparisonValue}. + /// + internal static string GreaterThan { + get { + return ResourceManager.GetString("GreaterThan", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} has a range of values which does not include '{PropertyValue}'. + /// + internal static string OutOfEnum { + get { + return ResourceManager.GetString("OutOfEnum", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} is required. + /// + internal static string Required { + get { + return ResourceManager.GetString("Required", resourceCulture); + } + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx b/api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx new file mode 100644 index 0000000..cb3d55b --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + {PropertyName} exceeds the max length of {MaxLength} + + + {PropertyName} must be greater than {ComparisonValue} + + + {PropertyName} has a range of values which does not include '{PropertyValue}' + + + {PropertyName} is required + + \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs index bfa6b13..ccf5bd4 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs +++ b/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs @@ -36,6 +36,7 @@ public void ConfigureServices(IServiceCollection services) services.AddRepositories(); services.AddServices(); + services.AddValidators(); services.AddApiConfigurations(); //services.AddHealthCheck(); diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs b/api/src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs new file mode 100644 index 0000000..5b31e68 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs @@ -0,0 +1,22 @@ +using FinancialHub.Domain.Models; +using FinancialHub.WebApi.Resources; +using FluentValidation; + +namespace FinancialHub.WebApi.Validators +{ + public class AccountValidator : AbstractValidator + { + public AccountValidator() + { + RuleFor(x => x.Name) + .NotEmpty() + .WithMessage(ErrorMessages.Required) + .Length(0,200) + .WithMessage(ErrorMessages.ExceedMaxLength); + + RuleFor(x => x.Description) + .Length(0, 500) + .WithMessage(ErrorMessages.ExceedMaxLength); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs b/api/src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs new file mode 100644 index 0000000..4f688a9 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs @@ -0,0 +1,22 @@ +using FinancialHub.Domain.Models; +using FinancialHub.WebApi.Resources; +using FluentValidation; + +namespace FinancialHub.WebApi.Validators +{ + public class BalanceValidator : AbstractValidator + { + public BalanceValidator() : base() + { + RuleFor(x => x.Name) + .NotEmpty() + .WithMessage(ErrorMessages.Required) + .Length(0, 200) + .WithMessage(ErrorMessages.ExceedMaxLength); + + RuleFor(x => x.AccountId) + .NotEmpty() + .WithMessage(ErrorMessages.Required); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs b/api/src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs new file mode 100644 index 0000000..08ab766 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs @@ -0,0 +1,22 @@ +using FinancialHub.Domain.Models; +using FinancialHub.WebApi.Resources; +using FluentValidation; + +namespace FinancialHub.WebApi.Validators +{ + public class CategoryValidator : AbstractValidator + { + public CategoryValidator() + { + RuleFor(x => x.Name) + .NotEmpty() + .WithMessage(ErrorMessages.Required) + .Length(0,200) + .WithMessage(ErrorMessages.ExceedMaxLength); + + RuleFor(x => x.Description) + .Length(0,500) + .WithMessage(ErrorMessages.ExceedMaxLength); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs b/api/src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs new file mode 100644 index 0000000..3096473 --- /dev/null +++ b/api/src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs @@ -0,0 +1,28 @@ +using FinancialHub.Domain.Models; +using FinancialHub.WebApi.Resources; +using FluentValidation; + +namespace FinancialHub.WebApi.Validators +{ + public class TransactionValidator : AbstractValidator + { + public TransactionValidator() + { + RuleFor(x => x.Description) + .Length(0, 500) + .WithMessage(ErrorMessages.ExceedMaxLength); + + RuleFor(x => x.Amount) + .GreaterThan(0) + .WithMessage(ErrorMessages.GreaterThan); + + RuleFor(x => x.Status) + .IsInEnum() + .WithMessage(ErrorMessages.OutOfEnum); + + RuleFor(x => x.Type) + .IsInEnum() + .WithMessage(ErrorMessages.OutOfEnum); + } + } +} From deb36486845d3bd15949f95d0cc1d928b757b19e Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Wed, 15 Mar 2023 12:53:19 -0300 Subject: [PATCH 10/30] Release/v0.3.1 (#125) * Adds : Updates balance when creating a transaction by creating a new service * Adds : TransactionBalanceService Tests * Adds : TransactionBalanceService.Update * Adds : TransactionBalanceService * Adds : TransactionBalanceService.CreateAsync service * Adds : TransactionBalanceTests UpdateAmount Same Balance * Adds : TransactionBalance.UpdateAsync different balances tests * Updates : api_basic_flow.yml * Updates : sonarcloud.yml * Migrates : the project to the rootfolder * Fix Balance updates * Fix : BalanceServiceTest Coverage * Fix : Unit tests and Fixture * Fix : BalanceService UnitTests * Fix : code complexity by separating it into methods * Removes : /api folder * Removes : TransactionServiceTests that changes Balance --- .github/workflows/api_basic_flow.yml | 14 +- .github/workflows/sonarcloud.yml | 10 +- CHANGELOG.md | 15 +- README.md | 15 +- .../TransactionsServiceTests.update.cs | 365 ----------------- .../financial-hub-api-dev.postman_environment | 0 .../api/financial-hub-api.postman_collection | 0 {api/docs => docs}/database/database.drawio | 0 .../database/financial-hub_DDL.sql | 0 {api/src => src}/FinancialHub/.editorconfig | 0 {api/src => src}/FinancialHub/Dockerfile | 0 .../Builders/Entities/AccountEntityBuilder.cs | 0 .../Builders/Entities/BalanceEntityBuilder.cs | 0 .../Builders/Entities/BaseEntityBuilder.cs | 0 .../Entities/CategoryEntityBuilder.cs | 0 .../Entities/TransactionEntityBuilder.cs | 0 .../Builders/Models/AccountModelBuilder.cs | 0 .../Builders/Models/BalanceModelBuilder.cs | 0 .../Builders/Models/BaseModelBuilder.cs | 0 .../Builders/Models/CategoryModelBuilder.cs | 0 .../Models/TransactionModelBuilder.cs | 0 .../FinancialHub.Domain.Tests.csproj | 0 .../Queries/TransactionQueryTests.cs | 0 .../Entities/AccountEntity.cs | 0 .../Entities/BalanceEntity.cs | 0 .../Entities/BaseEntity.cs | 0 .../Entities/CategoryEntity.cs | 0 .../Entities/TransactionEntity.cs | 0 .../Enums/TransactionStatus.cs | 0 .../Enums/TransactionType.cs | 0 .../Filters/TransactionFilter.cs | 0 .../FinancialHub.Domain.csproj | 4 +- .../Interfaces/Mappers/IMapperWrapper.cs | 0 .../Repositories/IAccountsRepository.cs | 0 .../Repositories/IBalancesRepository.cs | 1 + .../Repositories/IBaseRepository.cs | 0 .../Repositories/ICategoriesRepository.cs | 0 .../Repositories/ITransactionsRepository.cs | 0 .../Services/IAccountBalanceService.cs | 0 .../Interfaces/Services/IAccountsService.cs | 0 .../Interfaces/Services/IBalancesService.cs | 2 + .../Interfaces/Services/ICategoriesService.cs | 0 .../Services/ITransactionBalanceService.cs | 14 + .../Services/ITransactionsService.cs | 0 .../Models/AccountModel.cs | 0 .../Models/BalanceModel.cs | 0 .../FinancialHub.Domain/Models/BaseModel.cs | 0 .../Models/CategoryModel.cs | 0 .../Models/TransactionModel.cs | 0 .../Queries/TransactionQuery.cs | 0 .../FinancialHubConcepts.Designer.cs | 0 .../Resources/FinancialHubConcepts.resx | 0 .../Responses/Errors/BaseErrorResponse.cs | 0 .../Responses/Errors/NotFoundErrorResponse.cs | 0 .../Errors/ValidationErrorResponse.cs | 0 .../Responses/Success/BaseResponse.cs | 0 .../Responses/Success/ListResponse.cs | 0 .../Success/PaginatedListResponse.cs | 0 .../Responses/Success/SaveResponse.cs | 0 .../Results/Errors/InvalidDataError.cs | 0 .../Results/Errors/NotFoundError.cs | 0 .../Results/Errors/ServiceError.cs | 0 .../Results/ServiceResult.cs | 0 .../FinancialHub.Infra.Data.NUnitTests.csproj | 0 .../Accounts/AccountsRepositoryTests.cs | 0 .../BalancesRepositoryTests.amount.cs | 0 .../BalancesRepositoryTests.create.cs | 0 .../Balances/BalancesRepositoryTests.cs | 0 .../Base/BaseRepositoryTests.create.cs | 0 .../Repositories/Base/BaseRepositoryTests.cs | 0 .../Base/BaseRepositoryTests.delete.cs | 0 .../Base/BaseRepositoryTests.get.cs | 0 .../Base/BaseRepositoryTests.update.cs | 0 .../Categories/CategoriesRepositoryTests.cs | 0 .../TransactionsRepositoryTests.create.cs | 0 .../TransactionsRepositoryTests.cs | 0 .../TransactionsRepositoryTests.delete.cs | 0 .../TransactionsRepositoryTests.update.cs | 0 .../Contexts/FinancialHubContext.cs | 0 .../FinancialHub.Infra.Data.csproj | 0 .../Repositories/AccountsRepository.cs | 0 .../Repositories/BalancesRepository.cs | 11 + .../Repositories/BaseRepository.cs | 0 .../Repositories/CategoriesRepository.cs | 0 .../Repositories/TransactionsRepository.cs | 0 .../FinancialHub.Infra.Migrations.csproj | 0 .../20220407152032_v0.2.4.Designer.cs | 0 .../Migrations/20220407152032_v0.2.4.cs | 0 .../20220520163358_add-balance.Designer.cs | 0 .../Migrations/20220520163358_add-balance.cs | 0 ...117_add-balance-to-transaction.Designer.cs | 0 ...220520215117_add-balance-to-transaction.cs | 0 ...20520215501_add-balance-active.Designer.cs | 0 .../20220520215501_add-balance-active.cs | 0 .../FinancialHubContextModelSnapshot.cs | 0 .../Base/BaseControllerTests.cs | 0 .../Controllers/AccountsControllerTests.cs | 0 .../Controllers/BalancesControllerTests.cs | 0 .../Controllers/CategoriesControllerTests.cs | 0 .../TransactionsControllerTests.cs | 0 .../Extensions/HttpClientExtensions.cs | 0 .../HttpResponseMessageExtensions.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.IntegrationTests.csproj | 0 .../Setup/DbConnectionStringManager.cs | 0 .../Setup/FinancialHubFixture.cs | 1 + .../FinancialHub.Services.NUnitTests.csproj | 0 .../AccountBalanceServiceTests.create.cs | 0 .../AccountBalanceServiceTests.cs | 0 .../AccountBalanceServiceTests.delete.cs | 0 .../Accounts/AccountsServiceTests.create.cs | 0 .../Services/Accounts/AccountsServiceTests.cs | 0 .../Accounts/AccountsServiceTests.delete.cs | 0 .../Accounts/AccountsServiceTests.get.cs | 0 .../Accounts/AccountsServiceTests.update.cs | 0 .../Balances/BalancesServiceTests.create.cs | 0 .../Services/Balances/BalancesServiceTests.cs | 0 .../Balances/BalancesServiceTests.delete.cs | 0 .../Balances/BalancesServiceTests.get.cs | 0 .../Balances/BalancesServiceTests.update.cs | 17 +- .../BalancesServiceTests.updateamount.cs | 91 +++++ .../CategoriesServiceTests.create.cs | 0 .../Categories/CategoriesServiceTests.cs | 0 .../CategoriesServiceTests.delete.cs | 0 .../Categories/CategoriesServiceTests.get.cs | 0 .../CategoriesServiceTests.update.cs | 0 .../BaseTransactionBalanceTests.cs | 38 ++ .../TransactionBalanceTests.create.cs | 118 ++++++ .../TransactionBalanceTests.cs | 9 + .../TransactionBalanceTests.update.cs | 136 +++++++ .../TransactionBalanceTests.updateamount.cs | 382 ++++++++++++++++++ .../TransactionsServiceTests.create.cs | 62 --- .../Transactions/TransactionsServiceTests.cs | 0 .../TransactionsServiceTests.delete.cs | 0 .../TransactionsServiceTests.get.cs | 0 .../TransactionsServiceTests.update.cs | 137 +++++++ .../FinancialHub.Services.csproj | 0 .../Mappers/FinancialHubAutoMapperProfile.cs | 0 .../Mappers/FinancialHubMapperWrapper.cs | 0 .../Services/AccountBalanceService.cs | 0 .../Services/AccountsService.cs | 0 .../Services/BalancesService.cs | 17 +- .../Services/CategoriesService.cs | 0 .../Services/TransactionBalanceService.cs | 185 +++++++++ .../Services/TransactionsService.cs | 27 +- .../AccountsControllerTests.create.cs | 0 .../Accounts/AccountsControllerTests.cs | 0 .../AccountsControllerTests.delete.cs | 0 .../Accounts/AccountsControllerTests.get.cs | 0 .../AccountsControllerTests.update.cs | 0 .../BalancesControllerTests.create.cs | 0 .../Balances/BalancesControllerTests.cs | 0 .../BalancesControllerTests.delete.cs | 0 .../BalancesControllerTests.update.cs | 0 .../CategoriesControllerTests.create.cs | 0 .../Categories/CategoriesControllerTests.cs | 0 .../CategoriesControllerTests.delete.cs | 0 .../CategoriesControllerTests.get.cs | 0 .../CategoriesControllerTests.update.cs | 0 .../TransactionsControllerTests.create.cs | 12 +- .../TransactionsControllerTests.cs | 4 +- .../TransactionsControllerTests.delete.cs | 0 .../TransactionsControllerTests.get.cs | 0 .../TransactionsControllerTests.update.cs | 0 .../FinancialHub.WebApi.NUnitTests.csproj | 0 .../Validators/AccountValidatorTests.cs | 0 .../Validators/BalanceValidatorTests.cs | 0 .../Validators/CategoryValidatorTests.cs | 0 .../Validators/TransactionValidatorTests.cs | 0 .../Controllers/AccountsController.cs | 0 .../Controllers/BalancesController.cs | 0 .../Controllers/Base/BaseController.cs | 0 .../Controllers/CategoriesController.cs | 0 .../Controllers/TransactionsController.cs | 7 +- .../IServiceCollectionExtensions.cs | 1 + .../FinancialHub.WebApi.csproj | 0 .../FinancialHub.WebApi/Program.cs | 0 .../Properties/launchSettings.json | 0 .../Resources/ErrorMessages.Designer.cs | 0 .../Resources/ErrorMessages.resx | 0 .../FinancialHub.WebApi/Startup.cs | 0 .../Validators/AccountValidator.cs | 0 .../Validators/BalanceValidator.cs | 0 .../Validators/CategoryValidator.cs | 0 .../Validators/TransactionValidator.cs | 0 .../appsettings.Development.json | 0 .../FinancialHub.WebApi/appsettings.json | 0 .../src => src}/FinancialHub/FinancialHub.sln | 0 .../FinancialHub/docker-compose.yml | 0 189 files changed, 1194 insertions(+), 501 deletions(-) delete mode 100644 api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs rename {api/docs => docs}/api/environments/financial-hub-api-dev.postman_environment (100%) rename {api/docs => docs}/api/financial-hub-api.postman_collection (100%) rename {api/docs => docs}/database/database.drawio (100%) rename {api/docs => docs}/database/financial-hub_DDL.sql (100%) rename {api/src => src}/FinancialHub/.editorconfig (100%) rename {api/src => src}/FinancialHub/Dockerfile (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj (84%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs (83%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs (87%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs (100%) create mode 100644 src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs rename {api/src => src}/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs (83%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs (98%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs (91%) create mode 100644 src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs (100%) create mode 100644 src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs create mode 100644 src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs create mode 100644 src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs create mode 100644 src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs create mode 100644 src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs (58%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs (100%) create mode 100644 src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs rename {api/src => src}/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services/Services/AccountsService.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.Services/Services/BalancesService.cs (86%) rename {api/src => src}/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs (100%) create mode 100644 src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs rename {api/src => src}/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs (77%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs (83%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs (76%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs (91%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs (96%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Program.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Startup.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/appsettings.Development.json (100%) rename {api/src => src}/FinancialHub/FinancialHub.WebApi/appsettings.json (100%) rename {api/src => src}/FinancialHub/FinancialHub.sln (100%) rename {api/src => src}/FinancialHub/docker-compose.yml (100%) diff --git a/.github/workflows/api_basic_flow.yml b/.github/workflows/api_basic_flow.yml index 59c65f0..4728cb8 100644 --- a/.github/workflows/api_basic_flow.yml +++ b/.github/workflows/api_basic_flow.yml @@ -5,15 +5,15 @@ on: branches: - 'main' paths: - - 'api/src/FinancialHub/*' - - 'api/src/FinancialHub/**' + - 'src/FinancialHub/*' + - 'src/FinancialHub/**' pull_request: branches: - 'main' - 'release/**' paths: - - 'api/src/FinancialHub/*' - - 'api/src/FinancialHub/**' + - 'src/FinancialHub/*' + - 'src/FinancialHub/**' jobs: build: @@ -39,12 +39,12 @@ jobs: - name: Restore dependencies run: dotnet restore - working-directory: './api/src/FinancialHub/' + working-directory: './src/FinancialHub/' - name: Build run: dotnet build --no-restore - working-directory: './api/src/FinancialHub/' + working-directory: './src/FinancialHub/' - name: Test run: dotnet test --no-build --verbosity normal - working-directory: './api/src/FinancialHub/' + working-directory: './src/FinancialHub/' diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index f124f1a..2e22d03 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -5,15 +5,15 @@ on: branches: - 'main' paths: - - 'api/src/FinancialHub/*' - - 'api/src/FinancialHub/**' + - 'src/FinancialHub/*' + - 'src/FinancialHub/**' pull_request: branches: - 'main' - 'release/**' paths: - - 'api/src/FinancialHub/*' - - 'api/src/FinancialHub/**' + - 'src/FinancialHub/*' + - 'src/FinancialHub/**' permissions: pull-requests: read @@ -25,7 +25,7 @@ jobs: defaults: run: - working-directory: ./api/src/FinancialHub/ + working-directory: ./src/FinancialHub/ steps: - name: Set up JDK 11 diff --git a/CHANGELOG.md b/CHANGELOG.md index 876287f..a478e7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -## API -* ### [v0.2.4](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.4) -* ### [v0.2.3](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.3) -* ### [v0.2.2](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.2) -* ### [v0.2.1](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.1) -* ### [v0.2.0](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.2.0) -* ### [v0.1.0](https://github.com/Chingling152/my-financial-hub/releases/tag/v0.1.0) +* ### [v0.3.1](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.3.1) +* ### [v0.3.0](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.3.0) +* ### [v0.2.4](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.4) +* ### [v0.2.3](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.3) +* ### [v0.2.2](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.2) +* ### [v0.2.1](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.1) +* ### [v0.2.0](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.0) +* ### [v0.1.0](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.1.0) diff --git a/README.md b/README.md index e15b7b4..9ccc0ec 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,20 @@ # My Financial Hub - [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Chingling152_my-financial-hub&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Chingling152_my-financial-hub) ## What's planned for the future - -- ### Api - - **[Monthly Milestones](https://github.com/Chingling152/my-financial-hub/issues/9)** - - **[Earns/Expenses Portion](https://github.com/Chingling152/my-financial-hub/issues/10)** - - **Transaction exports (xlsx,pdf)** - - **Earns/Expenses average** - - **Earns/Expenses predictions** +- **[Monthly Milestones](https://github.com/Chingling152/my-financial-hub/issues/9)** +- **[Earns/Expenses Portion](https://github.com/Chingling152/my-financial-hub/issues/10)** +- **Transaction exports (xlsx, pdf)** +- **Earns/Expenses average** +- **Earns/Expenses predictions** ## Requeriments -- ### Api * Docker (optional) * .NET 6.0 * SQL Server ## How to Start -### Api * Run the Dockerfile in root project to create the database (optional) * Configure the **ConnectionStrings** in the file **appsettings.Development.json** with your SQL Server database * Initial configuration (pick one) diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs b/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs deleted file mode 100644 index e331a2a..0000000 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs +++ /dev/null @@ -1,365 +0,0 @@ -using Moq; -using NUnit.Framework; -using System.Threading.Tasks; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Enums; -using System; - -namespace FinancialHub.Services.NUnitTests.Services -{ - public partial class TransactionsServiceTests - { - [Test] - public async Task UpdateAsync_ValidTransaction_UpdatesTransaction() - { - var model = this.transactionModelBuilder.Generate(); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(this.mapper.Map(model.Balance)) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); - } - - [TestCase(TransactionStatus.NotCommitted, true, TransactionStatus.Committed, true)] - [TestCase(TransactionStatus.Committed, false, TransactionStatus.Committed, true)] - [TestCase(TransactionStatus.NotCommitted, false, TransactionStatus.Committed, true)] - public async Task UpdateAsync_CommitedAndActiveTransaction_AddsBalance( - TransactionStatus oldStatus, bool oldIsActive, - TransactionStatus newStatus, bool newIsActive) - { - var oldModel = this.transactionBuilder - .WithStatus(oldStatus) - .WithActiveStatus(oldIsActive) - .Generate(); - var model = this.transactionModelBuilder - .WithStatus(newStatus) - .WithActiveStatus(newIsActive) - .Generate(); - - var balance = this.mapper.Map(model.Balance); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(balance) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(oldModel) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - this.balancesRepository.Verify(x => x.ChangeAmountAsync(balance.Id.GetValueOrDefault(),model.Amount, model.Type,false)); - } - - [TestCase(TransactionStatus.Committed, true, TransactionStatus.NotCommitted, true)] - [TestCase(TransactionStatus.Committed, true, TransactionStatus.NotCommitted, false)] - [TestCase(TransactionStatus.Committed, true, TransactionStatus.Committed, false)] - public async Task UpdateAsync_NotCommitedOrInactiveTransaction_RemovesBalance( - TransactionStatus oldStatus, bool oldIsActive, - TransactionStatus newStatus, bool newIsActive) - { - var oldModel = this.transactionBuilder - .WithStatus(oldStatus) - .WithActiveStatus(oldIsActive) - .Generate(); - var model = this.transactionModelBuilder - .WithStatus(newStatus) - .WithActiveStatus(newIsActive) - .Generate(); - - var balance = this.mapper.Map(model.Balance); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(balance) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(oldModel) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - this.balancesRepository.Verify(x => x.ChangeAmountAsync(balance.Id.GetValueOrDefault(),model.Amount, model.Type,true)); - //this.balancesRepository.Verify(x => x.RemoveAmountAsync(It.IsAny()), Times.Once); - } - - [TestCase(TransactionStatus.NotCommitted, true, TransactionStatus.NotCommitted, true)] - [TestCase(TransactionStatus.NotCommitted, true, TransactionStatus.Committed, false)] - [TestCase(TransactionStatus.NotCommitted, true, TransactionStatus.NotCommitted, false)] - [TestCase(TransactionStatus.NotCommitted, false, TransactionStatus.NotCommitted, true)] - [TestCase(TransactionStatus.NotCommitted, false, TransactionStatus.NotCommitted, false)] - [TestCase(TransactionStatus.NotCommitted, false, TransactionStatus.Committed, false)] - [TestCase(TransactionStatus.Committed, false, TransactionStatus.NotCommitted, true)] - [TestCase(TransactionStatus.Committed, false, TransactionStatus.NotCommitted, false)] - [TestCase(TransactionStatus.Committed, false, TransactionStatus.Committed, false)] - public async Task UpdateAsync_NoStatusOrTypeChanges_DoesNotUpdate( - TransactionStatus oldStatus, bool oldIsActive, - TransactionStatus newStatus, bool newIsActive) - { - var oldModel = this.transactionBuilder - .WithStatus(oldStatus) - .WithActiveStatus(oldIsActive) - .Generate(); - var model = this.transactionModelBuilder - .WithStatus(newStatus) - .WithActiveStatus(newIsActive) - .Generate(); - - var balance = this.mapper.Map(model.Balance); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(balance) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(oldModel) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - this.balancesRepository.Verify(x => x.ChangeAmountAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); - } - - [Test] - public async Task UpdateAsync_DifferentAmounts_ChangesBalance() - { - var oldAmount = random.Next(1, 10); - var oldModel = this.transactionBuilder - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .WithAmount(oldAmount) - .Generate(); - var balance = this.mapper.Map(oldModel.Balance); - - var newAmount = random.Next(11, 100); - var model = this.transactionModelBuilder - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .WithBalanceId(balance.Id) - .WithAmount(newAmount) - .Generate(); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(balance) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(oldModel) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - this.balancesRepository.Verify(x => x.ChangeAmountAsync(model.BalanceId, oldAmount - newAmount, model.Type, false), Times.Once); - } - - [Test] - public async Task UpdateAsync_BalanceChanges_MoveAmountsFromOldBalanceToNewBalance() - { - var oldAmount = random.Next(1,10); - var oldModel = this.transactionBuilder - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .WithAmount(oldAmount) - .Generate(); - var oldBalance = this.mapper.Map(oldModel.Balance); - - var newAmount = random.Next(11,100); - var model = this.transactionModelBuilder - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .WithAmount(newAmount) - .Generate(); - var balance = this.mapper.Map(model.Balance); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(oldModel.BalanceId)) - .ReturnsAsync(oldBalance) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(balance) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(oldModel) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - this.balancesRepository.Verify(x => x.ChangeAmountAsync(oldModel.BalanceId, oldAmount, oldModel.Type, true), Times.Once); - this.balancesRepository.Verify(x => x.ChangeAmountAsync(model.BalanceId, newAmount, model.Type, false),Times.Once); - } - - [Test] - public async Task UpdateAsync_ValidTransaction_ReturnsTransaction() - { - var model = this.transactionModelBuilder.Generate(); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(this.mapper.Map(model.Balance)) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsNotNull(result); - Assert.IsInstanceOf>(result); - } - - [Test] - public async Task UpdateAsync_NonExistingTransactionId_ReturnsResultError() - { - var model = this.transactionModelBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(default(TransactionEntity)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsInstanceOf>(result); - Assert.IsTrue(result.HasError); - } - - [Test] - public async Task UpdateAsync_InvalidCategory_ReturnsNotFoundError() - { - var model = this.transactionModelBuilder.Generate(); - - this.SetUpMapper(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(this.mapper.Map(model.Balance)) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error.Message); - } - - [Test] - public async Task UpdateAsync_InvalidBalance_ReturnsNotFoundError() - { - var model = this.transactionModelBuilder.Generate(); - - this.SetUpMapper(); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error.Message); - } - } -} diff --git a/api/docs/api/environments/financial-hub-api-dev.postman_environment b/docs/api/environments/financial-hub-api-dev.postman_environment similarity index 100% rename from api/docs/api/environments/financial-hub-api-dev.postman_environment rename to docs/api/environments/financial-hub-api-dev.postman_environment diff --git a/api/docs/api/financial-hub-api.postman_collection b/docs/api/financial-hub-api.postman_collection similarity index 100% rename from api/docs/api/financial-hub-api.postman_collection rename to docs/api/financial-hub-api.postman_collection diff --git a/api/docs/database/database.drawio b/docs/database/database.drawio similarity index 100% rename from api/docs/database/database.drawio rename to docs/database/database.drawio diff --git a/api/docs/database/financial-hub_DDL.sql b/docs/database/financial-hub_DDL.sql similarity index 100% rename from api/docs/database/financial-hub_DDL.sql rename to docs/database/financial-hub_DDL.sql diff --git a/api/src/FinancialHub/.editorconfig b/src/FinancialHub/.editorconfig similarity index 100% rename from api/src/FinancialHub/.editorconfig rename to src/FinancialHub/.editorconfig diff --git a/api/src/FinancialHub/Dockerfile b/src/FinancialHub/Dockerfile similarity index 100% rename from api/src/FinancialHub/Dockerfile rename to src/FinancialHub/Dockerfile diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj b/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj rename to src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj diff --git a/api/src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs rename to src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs b/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs rename to src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs b/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs rename to src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs b/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs rename to src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs b/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs rename to src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs b/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs rename to src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs b/src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs rename to src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs b/src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs rename to src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs b/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs rename to src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj b/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj similarity index 84% rename from api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj rename to src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj index 7f771d4..24f4ca2 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj +++ b/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj @@ -5,7 +5,9 @@ - + + + diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs similarity index 83% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs index d005b67..dbaf617 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs +++ b/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs @@ -8,5 +8,6 @@ namespace FinancialHub.Domain.Interfaces.Repositories public interface IBalancesRepository : IBaseRepository { Task ChangeAmountAsync(Guid balanceId,decimal value, TransactionType transactionType, bool removed = false); + Task ChangeAmountAsync(Guid balanceId,decimal value); } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs similarity index 87% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs index fee7ffb..0a14038 100644 --- a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs +++ b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs @@ -16,6 +16,8 @@ public interface IBalancesService Task> UpdateAsync(Guid id, BalanceModel balance); + Task> UpdateAmountAsync(Guid id, decimal newAmount); + Task> DeleteAsync(Guid id); } } diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs new file mode 100644 index 0000000..5f2854d --- /dev/null +++ b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs @@ -0,0 +1,14 @@ +using System; +using System.Threading.Tasks; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; + +namespace FinancialHub.Domain.Interfaces.Services +{ + public interface ITransactionBalanceService + { + Task> CreateTransactionAsync(TransactionModel transaction); + Task> UpdateTransactionAsync(Guid id,TransactionModel transaction); + Task UpdateAmountAsync(TransactionModel oldTransaction, TransactionModel newTransaction); + } +} diff --git a/api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs rename to src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs b/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs rename to src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs b/src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs rename to src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs b/src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs rename to src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs b/src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs rename to src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs b/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs rename to src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs b/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs rename to src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs b/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs rename to src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx b/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx rename to src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs b/src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs rename to src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs b/src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs rename to src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs b/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs rename to src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs b/src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs rename to src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs b/src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs rename to src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs b/src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs rename to src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs b/src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs rename to src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs b/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs rename to src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs b/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs rename to src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs b/src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs rename to src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs diff --git a/api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs b/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs rename to src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs rename to src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs b/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs rename to src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj b/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj rename to src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs rename to src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs similarity index 83% rename from api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs rename to src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs index f74dea8..8492daf 100644 --- a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs +++ b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs @@ -53,5 +53,16 @@ public async Task ChangeAmountAsync(Guid balanceId, decimal value return balance; } + + public async Task ChangeAmountAsync(Guid balanceId, decimal value) + { + var balance = await this.GetByIdAsync(balanceId); + balance.Amount = value; + balance.UpdateTime = DateTimeOffset.Now; + + context.Update(balance); + await context.SaveChangesAsync(); + return balance; + } } } diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs rename to src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs rename to src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs rename to src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj b/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj rename to src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs b/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs rename to src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs b/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs rename to src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs b/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs rename to src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs b/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs rename to src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs b/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs rename to src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs b/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs rename to src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs b/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs rename to src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs b/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs rename to src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs diff --git a/api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs b/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs rename to src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj b/src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj rename to src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs diff --git a/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs similarity index 98% rename from api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs rename to src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs index 9fbf229..1afa026 100644 --- a/api/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs +++ b/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs @@ -9,6 +9,7 @@ using System.Collections; using FinancialHub.IntegrationTests.Extensions; using System.Collections.Generic; +using FinancialHub.Services.Mappers; namespace FinancialHub.IntegrationTests.Setup { diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj b/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj rename to src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs similarity index 91% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs index b3f32e1..583177d 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs @@ -3,7 +3,6 @@ using FinancialHub.Domain.Results; using Moq; using NUnit.Framework; -using System; using System.Threading.Tasks; namespace FinancialHub.Services.NUnitTests.Services @@ -19,10 +18,14 @@ public async Task UpdateAsync_ValidatesIfAccountExists() .Setup(x => x.GetByIdAsync(model.AccountId)) .ReturnsAsync(this.mapper.Map(model.Account)) .Verifiable(); + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); this.SetUpMapper(); - var result = await this.service.CreateAsync(model); + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); this.accountsRepository.Verify(x => x.GetByIdAsync(model.AccountId), Times.Once); } @@ -31,15 +34,17 @@ public async Task UpdateAsync_ValidatesIfAccountExists() public async Task UpdateAsync_ValidatesIfBalanceExists() { var model = this.balanceModelBuilder.Generate(); - + var id = model.Id.GetValueOrDefault(); this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .Setup(x => x.GetByIdAsync(id)) .ReturnsAsync(default(BalanceEntity)) .Verifiable(); - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + var result = await this.service.UpdateAsync(id, model); - this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Balance with id {id}", result.Error.Message); + this.repository.Verify(x => x.GetByIdAsync(id), Times.Once); } [Test] diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs new file mode 100644 index 0000000..c4cd972 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs @@ -0,0 +1,91 @@ +using System.Threading.Tasks; +using Moq; +using NUnit.Framework; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using System; +using FinancialHub.Domain.Results.Errors; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class BalancesServiceTests + { + [Test] + public async Task UpdateAmountAsync_UpdatesBalanceAmount() + { + var id = Guid.NewGuid(); + var model = this.balanceModelBuilder.WithId(id).Generate(); + var entity = this.mapper.Map(model); + var amount = this.random.Next(1000, 10000); + this.repository + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(entity); + + this.repository + .Setup(x => x.ChangeAmountAsync(id, amount)) + .ReturnsAsync(entity) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.UpdateAmountAsync(id, amount); + + this.repository.Verify(x => x.ChangeAmountAsync(id, amount), Times.Once); + } + + [Test] + public async Task UpdateAmountAsync_ValidBalanceModel_ReturnsBalanceModel() + { + var id = Guid.NewGuid(); + var model = this.balanceModelBuilder.WithId(id).Generate(); + var entity = this.mapper.Map(model); + var amount = this.random.Next(1000, 10000); + + this.repository + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(entity); + + this.repository + .Setup(x => x.ChangeAmountAsync(id, amount)) + .ReturnsAsync(entity); + + this.accountsRepository + .Setup(x => x.GetByIdAsync(model.AccountId)) + .ReturnsAsync(this.mapper.Map(model.Account)); + + this.SetUpMapper(); + + var result = await this.service.UpdateAmountAsync(id, amount); + + Assert.IsInstanceOf>(result); + Assert.IsNotNull(result.Data); + } + + [Test] + public async Task UpdateAmountAsync_NonExistingBalanceId_ReturnsResultError() + { + var id = Guid.NewGuid(); + var model = this.balanceModelBuilder.WithId(id).Generate(); + var entity = this.mapper.Map(model); + var amount = this.random.Next(1000, 10000); + + this.repository + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(default(BalanceEntity)) + .Verifiable(); + this.repository + .Setup(x => x.ChangeAmountAsync(id, amount)) + .Verifiable(); + + var result = await this.service.UpdateAmountAsync(id, amount); + + Assert.IsInstanceOf>(result); + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Balance with id {id}", result.Error.Message); + + this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs new file mode 100644 index 0000000..c77f0a6 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs @@ -0,0 +1,38 @@ +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.Services.Services; +using Moq; +using NUnit.Framework; +using System; + +namespace FinancialHub.Services.NUnitTests.Services.TransactionBalance +{ + public abstract class BaseTransactionBalanceTests + { + protected Random random; + + protected Mock balancesService; + protected Mock transactionsService; + + protected BalanceModelBuilder balanceModelBuilder; + protected TransactionModelBuilder transactionModelBuilder; + + protected ITransactionBalanceService service; + + [SetUp] + public void Setup() + { + this.balancesService = new Mock(); + this.transactionsService = new Mock(); + this.service = new TransactionBalanceService( + transactionsService.Object, + balancesService.Object + ); + + this.random = new Random(); + + this.balanceModelBuilder = new BalanceModelBuilder(); + this.transactionModelBuilder = new TransactionModelBuilder(); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs new file mode 100644 index 0000000..a743218 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs @@ -0,0 +1,118 @@ +using Moq; +using NUnit.Framework; +using System.Threading.Tasks; +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Results.Errors; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionBalanceTests + { + [TestCase(TransactionType.Earn)] + [TestCase(TransactionType.Expense)] + public async Task CreateTransactionAsync_PaidTransaction_ShouldReturnCreatedTransaction(TransactionType type) + { + var transaction = this.transactionModelBuilder + .WithType(type) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + var balance = this.balanceModelBuilder + .WithAmount(0) + .WithId(transaction.BalanceId) + .Generate(); + + this.transactionsService + .Setup(x => x.CreateAsync(transaction)) + .ReturnsAsync(transaction).Verifiable(); + this.balancesService + .Setup(x => x.GetByIdAsync(transaction.BalanceId)) + .ReturnsAsync(balance); + this.balancesService + .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, transaction.Amount)); + + var result = await this.service.CreateTransactionAsync(transaction); + + Assert.AreEqual(transaction, result.Data); + Assert.IsFalse(result.HasError); + Assert.IsNull(result.Error); + } + + [TestCase(TransactionType.Earn)] + [TestCase(TransactionType.Expense)] + public async Task CreateTransactionAsync_PaidTransaction_ShouldUpdateBalance(TransactionType type) + { + var transaction = this.transactionModelBuilder + .WithType(type) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + var balance = this.balanceModelBuilder + .WithId(transaction.BalanceId) + .Generate(); + var expectedResult = + type == TransactionType.Earn? + balance.Amount + transaction.Amount: + balance.Amount - transaction.Amount; + + this.transactionsService + .Setup(x => x.CreateAsync(transaction)) + .ReturnsAsync(transaction) + .Verifiable(); + this.balancesService + .Setup(x => x.GetByIdAsync(transaction.BalanceId)) + .ReturnsAsync(balance) + .Verifiable(); + this.balancesService + .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, expectedResult)) + .Verifiable(); + + await this.service.CreateTransactionAsync(transaction); + + this.transactionsService.Verify(x => x.CreateAsync(transaction), Times.Once); + this.balancesService.Verify(x => x.GetByIdAsync(transaction.BalanceId), Times.Once); + this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, expectedResult), Times.Once); + } + + [Test] + public async Task CreateTransactionAsync_TransactionCreationFailed_ReturnsServiceError() + { + var transaction = this.transactionModelBuilder + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + + var error = new ServiceError(1, "Error message"); + this.transactionsService + .Setup(x => x.CreateAsync(transaction)) + .ReturnsAsync(error) + .Verifiable(); + + var result = await this.service.CreateTransactionAsync(transaction); + + Assert.IsNull(result.Data); + Assert.IsTrue(result.HasError); + Assert.AreEqual(error ,result.Error); + } + + [Test] + public async Task CreateTransactionAsync_NotPaidTransaction_ShouldNotUpdateBalance() + { + var transaction = this.transactionModelBuilder + .WithStatus(TransactionStatus.NotCommitted) + .WithActiveStatus(true) + .Generate(); + + this.transactionsService + .Setup(x => x.CreateAsync(transaction)) + .ReturnsAsync(transaction) + .Verifiable(); + + await this.service.CreateTransactionAsync(transaction); + + this.transactionsService.Verify(x => x.CreateAsync(transaction), Times.Once); + this.balancesService.Verify(x => x.GetByIdAsync(transaction.BalanceId), Times.Never); + this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny()), Times.Never); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs new file mode 100644 index 0000000..fb9ac1a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs @@ -0,0 +1,9 @@ +using FinancialHub.Services.NUnitTests.Services.TransactionBalance; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionBalanceTests : BaseTransactionBalanceTests + { + + } +} diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs new file mode 100644 index 0000000..e72c3ef --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs @@ -0,0 +1,136 @@ +using System; +using System.Threading.Tasks; +using Moq; +using NUnit.Framework; +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Results.Errors; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionBalanceTests + { + [Test] + public async Task UpdateTransactionAsync_ValidTransactionWithDifferentBalances_UpdatesBalancesAmount() + { + var oldBalance = this.balanceModelBuilder.Generate(); + var newBalance = this.balanceModelBuilder.Generate(); + var id = Guid.NewGuid(); + + var oldTransaction = this.transactionModelBuilder + .WithType(TransactionType.Earn) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .WithBalance(oldBalance) + .WithId(id) + .Generate(); + var newTransaction = this.transactionModelBuilder + .WithType(TransactionType.Earn) + .WithStatus(TransactionStatus.NotCommitted) + .WithActiveStatus(true) + .WithBalance(newBalance) + .WithId(id) + .Generate(); + + this.transactionsService + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(oldTransaction); + this.transactionsService + .Setup(x => x.UpdateAsync(id, newTransaction)) + .ReturnsAsync(newTransaction); + + this.balancesService + .Setup(x => x.GetByIdAsync(oldTransaction.BalanceId)) + .ReturnsAsync(oldBalance); + this.balancesService + .Setup(x => x.GetByIdAsync(newTransaction.BalanceId)) + .ReturnsAsync(newBalance); + this.balancesService + .Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny())) + .Verifiable(); + + var result = await this.service.UpdateTransactionAsync(id, newTransaction); + + Assert.IsFalse(result.HasError); + Assert.AreSame(newTransaction, result.Data); + this.balancesService + .Verify( + x => x.UpdateAmountAsync(It.IsAny(), It.IsAny()), + Times.Between(1,2, Moq.Range.Inclusive) + ); + } + + [Test] + public async Task UpdateTransactionAsync_ValidTransactionWithSameBalance_UpdatesBalanceAmount() + { + var balance = this.balanceModelBuilder.Generate(); + var id = Guid.NewGuid(); + + var oldTransaction = this.transactionModelBuilder + .WithType(TransactionType.Earn) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .WithBalance(balance) + .WithId(id) + .Generate(); + var newTransaction = this.transactionModelBuilder + .WithType(TransactionType.Earn) + .WithStatus(TransactionStatus.NotCommitted) + .WithActiveStatus(true) + .WithBalance(balance) + .WithId(id) + .Generate(); + + this.transactionsService + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(oldTransaction); + this.transactionsService + .Setup(x => x.UpdateAsync(id, newTransaction)) + .ReturnsAsync(newTransaction); + + this.balancesService + .Setup(x => x.GetByIdAsync(newTransaction.BalanceId)) + .ReturnsAsync(balance); + this.balancesService + .Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny())) + .Verifiable(); + + var result = await this.service.UpdateTransactionAsync(id, newTransaction); + + Assert.IsFalse(result.HasError); + Assert.AreSame(newTransaction, result.Data); + this.balancesService + .Verify( + x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny()), + Times.Once + ); + } + + [Test] + public async Task UpdateTransactionAsync_TransactionUpdateFailed_ReturnsUpdateError() + { + var balance = this.balanceModelBuilder.Generate(); + var id = Guid.NewGuid(); + var newTransaction = this.transactionModelBuilder + .WithType(TransactionType.Earn) + .WithStatus(TransactionStatus.NotCommitted) + .WithActiveStatus(true) + .WithBalance(balance) + .WithId(id) + .Generate(); + + var error = new ServiceError(1, "Update error message"); + this.transactionsService + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(newTransaction); + + this.transactionsService + .Setup(x => x.UpdateAsync(id, newTransaction)) + .ReturnsAsync(error); + + var result = await this.service.UpdateTransactionAsync(id, newTransaction); + + Assert.IsTrue(result.HasError); + Assert.AreEqual(error.Message, result.Error.Message); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs new file mode 100644 index 0000000..d589072 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs @@ -0,0 +1,382 @@ +using FinancialHub.Domain.Enums; +using FinancialHub.Services.NUnitTests.Services.TransactionBalance; +using Moq; +using NUnit.Framework; +using System; +using System.Threading.Tasks; + +namespace FinancialHub.Services.NUnitTests.Services +{ + //TODO: fix UpdateAmount in test names + //TOOD: maybe separate some testcases + public partial class TransactionBalanceTests + { + class UpdateAmountAsync + { + class SameBalance : BaseTransactionBalanceTests + { + [TestCase(TransactionStatus.NotCommitted, TransactionType.Expense, true)] + [TestCase(TransactionStatus.NotCommitted, TransactionType.Earn, true)] + [TestCase(TransactionStatus.NotCommitted, TransactionType.Expense, false)] + [TestCase(TransactionStatus.NotCommitted, TransactionType.Earn, false)] + [TestCase(TransactionStatus.Committed, TransactionType.Expense, false)] + [TestCase(TransactionStatus.Committed, TransactionType.Earn, false)] + public async Task NotPaid_DoNotUpdatesAmount( + TransactionStatus status, TransactionType type, bool activeStatus + ) + { + var balance = this.balanceModelBuilder.Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(status) + .WithType(type) + .WithActiveStatus(activeStatus) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(status) + .WithType(type) + .WithActiveStatus(activeStatus) + .Generate(); + + await this.service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(It.IsAny(), It.IsAny()), Times.Never); + } + + [TestCase(TransactionStatus.Committed, TransactionType.Expense)] + [TestCase(TransactionStatus.Committed, TransactionType.Earn)] + public async Task NoChanges_DoNotUpdateAmount(TransactionStatus status, TransactionType type) + { + var balance = this.balanceModelBuilder.Generate(); + var transactionId = Guid.NewGuid(); + var oldTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(status) + .WithType(type) + .WithActiveStatus(true) + .WithId(transactionId) + .Generate(); + + await this.service.UpdateAmountAsync(oldTransaction, oldTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(It.IsAny(), It.IsAny()), Times.Never); + } + + [TestCase(TransactionType.Expense, TransactionType.Expense)] + [TestCase(TransactionType.Expense, TransactionType.Earn)] + [TestCase(TransactionType.Earn, TransactionType.Earn)] + [TestCase(TransactionType.Earn, TransactionType.Expense)] + public async Task PaidToNotPaid_RemovesAmountUpdates(TransactionType oldType, TransactionType type) + { + var balanceId = Guid.NewGuid(); + var balance = this.balanceModelBuilder + .WithId(balanceId) + .Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.NotCommitted) + .WithType(oldType) + .WithActiveStatus(true) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.Committed) + .WithType(type) + .WithActiveStatus(true) + .Generate(); + + var expectedResult = + type == TransactionType.Earn ? + balance.Amount + newTransaction.Amount : + balance.Amount - newTransaction.Amount; + this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); + + await service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); + } + + [TestCase(TransactionType.Expense)] + [TestCase(TransactionType.Earn)] + public async Task DifferentAmount_AddsDifference(TransactionType type) + { + var balanceId = Guid.NewGuid(); + var startValue = random.Next(1000, 10000); + var balance = this.balanceModelBuilder + .WithAmount(startValue) + .WithId(balanceId) + .Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.Committed) + .WithType(type) + .WithActiveStatus(true) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.Committed) + .WithType(type) + .WithActiveStatus(true) + .Generate(); + var expectedResult = + type == TransactionType.Earn ? + startValue + newTransaction.Amount - oldTransaction.Amount : + startValue + oldTransaction.Amount - newTransaction.Amount; + this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); + + await service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); + } + + [Test] + public async Task ExpenseToEarn_AddsRevemovedAmount() + { + var balanceId = Guid.NewGuid(); + var startValue = random.Next(1000, 10000); + var balance = this.balanceModelBuilder + .WithAmount(startValue) + .WithId(balanceId) + .Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.Committed) + .WithType(TransactionType.Expense) + .WithActiveStatus(true) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.Committed) + .WithType(TransactionType.Earn) + .WithActiveStatus(true) + .Generate(); + + var expectedResult = startValue + (newTransaction.Amount + oldTransaction.Amount); + this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); + + await service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); + } + + [Test] + public async Task EarnToExpense_RemovesAddedAmount() { + var balanceId = Guid.NewGuid(); + var startValue = random.Next(1000, 10000); + var balance = this.balanceModelBuilder + .WithAmount(startValue) + .WithId(balanceId) + .Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.Committed) + .WithType(TransactionType.Earn) + .WithActiveStatus(true) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.Committed) + .WithType(TransactionType.Expense) + .WithActiveStatus(true) + .Generate(); + + var expectedResult = startValue - oldTransaction.Amount - newTransaction.Amount; + this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); + + await service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); + } + + [TestCase(TransactionType.Expense, TransactionType.Expense)] + [TestCase(TransactionType.Expense, TransactionType.Earn)] + [TestCase(TransactionType.Earn, TransactionType.Earn)] + [TestCase(TransactionType.Earn, TransactionType.Expense)] + public async Task PaidToNotPaid_RemovesAmountChanges(TransactionType oldType, TransactionType type) + { + var balanceId = Guid.NewGuid(); + var balance = this.balanceModelBuilder + .WithId(balanceId) + .Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.Committed) + .WithType(oldType) + .WithActiveStatus(true) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithBalance(balance) + .WithStatus(TransactionStatus.NotCommitted) + .WithType(type) + .WithActiveStatus(true) + .Generate(); + + var expectedResult = + type == TransactionType.Earn ? + balance.Amount - newTransaction.Amount: + balance.Amount + newTransaction.Amount; + this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); + + await service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); + } + } + + class DifferenteBalance : BaseTransactionBalanceTests + { + [TestCase(TransactionType.Expense, TransactionType.Expense)] + [TestCase(TransactionType.Expense, TransactionType.Earn)] + [TestCase(TransactionType.Earn, TransactionType.Earn)] + [TestCase(TransactionType.Earn, TransactionType.Expense)] + public async Task NotPaidToPaid_AppliesAmountChangesOnNewBalance(TransactionType oldType, TransactionType type) + { + var oldBalance = this.balanceModelBuilder.Generate(); + var newBalance = this.balanceModelBuilder.Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithBalance(oldBalance) + .WithType(oldType) + .WithStatus(TransactionStatus.NotCommitted) + .WithActiveStatus(true) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithBalance(newBalance) + .WithType(type) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + var expectedResult = + type == TransactionType.Earn? + newBalance.Amount + newTransaction.Amount: + newBalance.Amount - newTransaction.Amount; + + this.balancesService.Setup(x => x.UpdateAmountAsync(oldTransaction.BalanceId, It.IsAny())); + this.balancesService.Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedResult)); + + await this.service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(oldTransaction.BalanceId, It.IsAny()), Times.Never); + this.balancesService.Verify(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedResult), Times.Once); + } + + [TestCase(TransactionType.Expense, TransactionType.Expense)] + [TestCase(TransactionType.Expense, TransactionType.Earn)] + [TestCase(TransactionType.Earn, TransactionType.Earn)] + [TestCase(TransactionType.Earn, TransactionType.Expense)] + public async Task NotPaidToPaid_RemoveAmountChangesFromOldBalance(TransactionType oldType, TransactionType type) + { + var oldStartValue = 0; + var oldBalance = this.balanceModelBuilder.WithAmount(oldStartValue).Generate(); + var newBalance = this.balanceModelBuilder.WithAmount(oldStartValue).Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithAmount(10) + .WithBalance(oldBalance) + .WithType(oldType) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithAmount(10) + .WithBalance(newBalance) + .WithType(type) + .WithStatus(TransactionStatus.NotCommitted) + .WithActiveStatus(true) + .Generate(); + var expectedResult = + oldType == TransactionType.Earn ? + oldBalance.Amount - oldTransaction.Amount : + oldBalance.Amount + oldTransaction.Amount; + + this.balancesService.Setup(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedResult)); + this.balancesService.Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny())); + + await this.service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedResult), Times.Once); + this.balancesService.Verify(x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny()), Times.Never); + } + + [Test] + public async Task EarnTransactions_RemovesAmountFromOldBalanceAndSentToNewBalance() + { + var oldBalance = this.balanceModelBuilder.Generate(); + var newBalance = this.balanceModelBuilder.Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithBalance(oldBalance) + .WithType(TransactionType.Earn) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithBalance(newBalance) + .WithType(TransactionType.Earn) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + + var expectedOldBalanceAmount = oldBalance.Amount - oldTransaction.Amount; + var expectedNewBalanceAmount = newBalance.Amount + newTransaction.Amount; + + this.balancesService.Setup(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedOldBalanceAmount)); + this.balancesService.Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedNewBalanceAmount)); + + await this.service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedOldBalanceAmount), Times.Once); + this.balancesService.Verify(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedNewBalanceAmount), Times.Once); + } + + [Test] + public async Task ExpenseTransactions_RemovesAmountFromOldBalanceAndSentToNewBalance() + { + var oldBalance = this.balanceModelBuilder.Generate(); + var newBalance = this.balanceModelBuilder.Generate(); + + var oldTransaction = this.transactionModelBuilder + .WithBalance(oldBalance) + .WithType(TransactionType.Expense) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + + var newTransaction = this.transactionModelBuilder + .WithBalance(newBalance) + .WithType(TransactionType.Expense) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .Generate(); + + var expectedOldBalanceAmount = oldBalance.Amount + oldTransaction.Amount; + var expectedNewBalanceAmount = newBalance.Amount - newTransaction.Amount; + + this.balancesService.Setup(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedOldBalanceAmount)); + this.balancesService.Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedNewBalanceAmount)); + + await this.service.UpdateAmountAsync(oldTransaction, newTransaction); + + this.balancesService.Verify(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedOldBalanceAmount), Times.Once); + this.balancesService.Verify(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedNewBalanceAmount), Times.Once); + } + } + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs similarity index 58% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs index 5e2739d..00c724b 100644 --- a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs @@ -5,7 +5,6 @@ using FinancialHub.Domain.Entities; using FinancialHub.Domain.Models; using FinancialHub.Domain.Results; -using FinancialHub.Domain.Enums; namespace FinancialHub.Services.NUnitTests.Services { @@ -36,67 +35,6 @@ public async Task CreateAsync_ValidTransaction_CreatesTransaction() this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); } - [Test] - public async Task CreateAsync_CommitedActiveTransaction_UpdatesBalance() - { - var model = this.transactionModelBuilder - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - var balanceEntity = this.mapper.Map(model.Balance); - - this.categoriesRepository - .Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository - .Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(balanceEntity) - .Verifiable(); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.CreateAsync(model); - - this.balancesRepository.Verify(x => x.ChangeAmountAsync(model.BalanceId, model.Amount,model.Type,false), Times.Once); - } - - [Test] - public async Task CreateAsync_NotCommitedTransaction_DoesNotUpdatesBalance() - { - var model = this.transactionModelBuilder - .WithStatus(TransactionStatus.NotCommitted) - .Generate(); - var balanceEntity = this.mapper.Map(model.Balance); - - this.categoriesRepository - .Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository - .Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(balanceEntity) - .Verifiable(); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.CreateAsync(model); - - this.balancesRepository.Verify(x => x.ChangeAmountAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); - } - [Test] public async Task CreateAsync_ValidTransaction_ReturnsCreatedTransaction() { diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs rename to src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs new file mode 100644 index 0000000..182e7ec --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs @@ -0,0 +1,137 @@ +using Moq; +using NUnit.Framework; +using System.Threading.Tasks; +using FinancialHub.Domain.Entities; +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionsServiceTests + { + [Test] + public async Task UpdateAsync_ValidTransaction_UpdatesTransaction() + { + var model = this.transactionModelBuilder.Generate(); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(this.mapper.Map(model.Balance)) + .Verifiable(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + + await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); + } + + [Test] + public async Task UpdateAsync_ValidTransaction_ReturnsTransaction() + { + var model = this.transactionModelBuilder.Generate(); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(this.mapper.Map(model.Balance)) + .Verifiable(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + this.SetUpMapper(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsNotNull(result); + Assert.IsInstanceOf>(result); + } + + [Test] + public async Task UpdateAsync_NonExistingTransactionId_ReturnsResultError() + { + var model = this.transactionModelBuilder.Generate(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(default(TransactionEntity)) + .Verifiable(); + + this.repository + .Setup(x => x.UpdateAsync(It.IsAny())) + .Returns(async (x) => await Task.FromResult(x)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsInstanceOf>(result); + Assert.IsTrue(result.HasError); + } + + [Test] + public async Task UpdateAsync_InvalidCategory_ReturnsNotFoundError() + { + var model = this.transactionModelBuilder.Generate(); + + this.SetUpMapper(); + + this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) + .ReturnsAsync(this.mapper.Map(model.Balance)) + .Verifiable(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error.Message); + } + + [Test] + public async Task UpdateAsync_InvalidBalance_ReturnsNotFoundError() + { + var model = this.transactionModelBuilder.Generate(); + + this.SetUpMapper(); + + this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) + .ReturnsAsync(this.mapper.Map(model.Category)) + .Verifiable(); + + this.repository + .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .ReturnsAsync(this.mapper.Map(model)) + .Verifiable(); + + var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + + Assert.IsTrue(result.HasError); + Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error.Message); + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj b/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj rename to src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj diff --git a/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs b/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs rename to src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs diff --git a/api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs b/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs rename to src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs b/src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs rename to src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs b/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs rename to src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs b/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs similarity index 86% rename from api/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs rename to src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs index 23aaebf..f116db8 100644 --- a/api/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs +++ b/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs @@ -74,9 +74,7 @@ public async Task>> GetAllByAccountAsync { var entities = await this.repository.GetAsync(x => x.AccountId == accountId); - var list = this.mapper.Map>(entities); - - return list.ToArray(); + return this.mapper.Map>(entities).ToArray(); } public async Task> UpdateAsync(Guid id, BalanceModel balance) @@ -100,5 +98,18 @@ public async Task> UpdateAsync(Guid id, BalanceModel return mapper.Map(entity); } + + public async Task> UpdateAmountAsync(Guid id, decimal newAmount) + { + var balanceResult = await this.GetByIdAsync(id); + if (balanceResult.HasError) + { + return balanceResult.Error; + } + + var newBalance = await repository.ChangeAmountAsync(id, newAmount); + + return mapper.Map(newBalance); + } } } diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs b/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs rename to src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs diff --git a/src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs b/src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs new file mode 100644 index 0000000..5c43cfa --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs @@ -0,0 +1,185 @@ +using FinancialHub.Domain.Models; +using FinancialHub.Domain.Results; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Enums; + +namespace FinancialHub.Services.Services +{ + public class TransactionBalanceService : ITransactionBalanceService + { + private readonly ITransactionsService transactionsService; + private readonly IBalancesService balancesService; + + public TransactionBalanceService(ITransactionsService transactionsService, IBalancesService balancesService) + { + this.transactionsService = transactionsService; + this.balancesService = balancesService; + } + + private static (decimal oldAmount, decimal newAmount) UpdateAmountDifferentBalances(TransactionModel oldTransaction, TransactionModel newTransaction) + { + var oldAmount = oldTransaction.Balance.Amount; + var newAmount = newTransaction.Balance.Amount; + + if (oldTransaction.IsPaid) + { + oldAmount = + oldTransaction.Type == TransactionType.Earn ? + oldAmount - oldTransaction.Amount : + oldAmount + oldTransaction.Amount; + } + + if (newTransaction.IsPaid) + { + newAmount = + newTransaction.Type == TransactionType.Earn ? + newAmount + newTransaction.Amount : + newAmount - newTransaction.Amount; + } + + return (oldAmount, newAmount); + } + + private static decimal UpdateAmountDifferentStatus(TransactionModel newTransaction) + { + var newAmount = newTransaction.Balance.Amount; + + if (newTransaction.IsPaid) + { + if (newTransaction.Type == TransactionType.Earn) + return newAmount + newTransaction.Amount; + else + return newAmount - newTransaction.Amount; + } + else + { + if (newTransaction.Type == TransactionType.Earn) + return newAmount - newTransaction.Amount; + else + return newAmount + newTransaction.Amount; + } + } + + private static decimal UpdateAmountSameStatus(TransactionModel oldTransaction, TransactionModel newTransaction) + { + var newAmount = newTransaction.Balance.Amount; + + if (newTransaction.Type == oldTransaction.Type) + { + decimal difference; + if (oldTransaction.Type == TransactionType.Earn) + difference = newTransaction.Amount - oldTransaction.Amount; + else + difference = oldTransaction.Amount - newTransaction.Amount; + + return newAmount + difference; + } + else + { + var difference = oldTransaction.Amount + newTransaction.Amount; + if (oldTransaction.Type == TransactionType.Earn) + return newAmount - difference; + else + return newAmount + difference; + } + } + + private static decimal UpdateAmountSameBalance(TransactionModel oldTransaction, TransactionModel newTransaction) + { + var newAmount = newTransaction.Balance.Amount; + if (oldTransaction.IsPaid != newTransaction.IsPaid) + { + return UpdateAmountDifferentStatus(newTransaction); + } + else if (oldTransaction.IsPaid && newTransaction.IsPaid) + { + return UpdateAmountSameStatus(oldTransaction, newTransaction); + } + return newAmount; + } + + public async Task UpdateAmountAsync(TransactionModel oldTransaction, TransactionModel newTransaction) + { + if(oldTransaction.IsPaid || newTransaction.IsPaid) + { + if (oldTransaction.BalanceId != newTransaction.BalanceId) + { + var (oldAmount, newAmount) = UpdateAmountDifferentBalances(oldTransaction, newTransaction); + + if (oldAmount != oldTransaction.Balance.Amount) + await this.balancesService.UpdateAmountAsync(oldTransaction.BalanceId, oldAmount); + if (newAmount != newTransaction.Balance.Amount) + await this.balancesService.UpdateAmountAsync(newTransaction.BalanceId, newAmount); + } + else + { + var newAmount = UpdateAmountSameBalance(oldTransaction, newTransaction); + + if(newAmount != newTransaction.Balance.Amount) + { + await this.balancesService.UpdateAmountAsync(newTransaction.BalanceId, newAmount); + } + } + } + } + + public async Task> CreateTransactionAsync(TransactionModel transaction) + { + var transactionResult = await transactionsService.CreateAsync(transaction); + + if(transactionResult.HasError) { + return transactionResult; + } + + if(transactionResult.Data.IsPaid) + { + var balanceResult = await balancesService.GetByIdAsync(transaction.BalanceId); + if(balanceResult.HasError) { + return balanceResult.Error; + } + + if (transaction.Type == TransactionType.Earn) + { + await balancesService.UpdateAmountAsync(transaction.BalanceId, balanceResult.Data.Amount + transaction.Amount); + } + else + { + await balancesService.UpdateAmountAsync(transaction.BalanceId, balanceResult.Data.Amount - transaction.Amount); + } + } + + return transactionResult; + } + + public async Task> UpdateTransactionAsync(Guid id, TransactionModel transaction) + { + var oldTransactionResult = await transactionsService.GetByIdAsync(id); + + var transactionResult = await transactionsService.UpdateAsync(id, transaction); + if (transactionResult.HasError) + { + return transactionResult; + } + + var oldTransaction = oldTransactionResult.Data; + var newTransaction = transactionResult.Data; + var balanceResult = await balancesService.GetByIdAsync(newTransaction.BalanceId); + + if (newTransaction.BalanceId == oldTransaction.BalanceId) + { + oldTransaction.Balance = balanceResult.Data; + newTransaction.Balance = balanceResult.Data; + } + else + { + var oldBalanceResult = await balancesService.GetByIdAsync(oldTransaction.BalanceId); + + oldTransaction.Balance = oldBalanceResult.Data; + newTransaction.Balance = balanceResult.Data; + } + await this.UpdateAmountAsync(oldTransaction, newTransaction); + + return transactionResult; + } + } +} diff --git a/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs b/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs similarity index 77% rename from api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs rename to src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs index e5e63a4..525f58a 100644 --- a/api/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs +++ b/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs @@ -58,11 +58,11 @@ public async Task> CreateAsync(TransactionModel } entity = await this.repository.CreateAsync(entity); - + /* if (entity.Status == TransactionStatus.Committed && entity.IsActive) { await this.balancesRepository.ChangeAmountAsync(entity.BalanceId,entity.Amount,entity.Type); - } + }*/ return mapper.Map(entity); } @@ -103,7 +103,6 @@ public async Task> UpdateAsync(Guid id, Transact { return oldTransactionResult.Error; } - var oldTransaction = oldTransactionResult.Data; var newTransaction = this.mapper.Map(transaction); var validation = await this.ValidateTransaction(newTransaction); @@ -114,28 +113,6 @@ public async Task> UpdateAsync(Guid id, Transact newTransaction = await this.repository.UpdateAsync(newTransaction); - if (transaction.IsPaid && oldTransaction.IsPaid) - { - if (transaction.BalanceId != oldTransaction.BalanceId) - { - await this.balancesRepository.ChangeAmountAsync(oldTransaction.BalanceId, oldTransaction.Amount, oldTransaction.Type, true); - await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type); - } - else if(transaction.Amount != oldTransaction.Amount) - { - var amountDifference = oldTransaction.Amount - transaction.Amount; - await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, amountDifference, transaction.Type); - } - } - else if (transaction.IsPaid && (!oldTransaction.IsActive || transaction.Status != oldTransaction.Status)) - { - await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type); - } - else if (oldTransaction.IsPaid && (!transaction.IsActive || transaction.Status != oldTransaction.Status)) - { - await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type, true); - } - return mapper.Map(newTransaction); } diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs similarity index 83% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs index 40e1d55..42d5040 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs +++ b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs @@ -20,8 +20,8 @@ public async Task CreateTransaction_Valid_ReturnsOk() var body = this.transactionModelBuilder.Generate(); var mockResult = new ServiceResult(body); - this.mockService - .Setup(x => x.CreateAsync(body)) + this.mockTransactionBalanceServiceService + .Setup(x => x.CreateTransactionAsync(body)) .ReturnsAsync(mockResult) .Verifiable(); @@ -35,7 +35,7 @@ public async Task CreateTransaction_Valid_ReturnsOk() var listResponse = result?.Value as SaveResponse; Assert.AreEqual(mockResult.Data, listResponse?.Data); - this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + this.mockTransactionBalanceServiceService.Verify(x => x.CreateTransactionAsync(body), Times.Once); } [Test] @@ -47,8 +47,8 @@ public async Task CreateTransaction_Invalid_ReturnsBadRequest() var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - this.mockService - .Setup(x => x.CreateAsync(body)) + this.mockTransactionBalanceServiceService + .Setup(x => x.CreateTransactionAsync(body)) .ReturnsAsync(mockResult) .Verifiable(); @@ -63,7 +63,7 @@ public async Task CreateTransaction_Invalid_ReturnsBadRequest() Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); - this.mockService.Verify(x => x.CreateAsync(body), Times.Once); + this.mockTransactionBalanceServiceService.Verify(x => x.CreateTransactionAsync(body), Times.Once); } } } diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs similarity index 76% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs index c87c134..c8e8ffc 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs +++ b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs @@ -14,6 +14,7 @@ public partial class TransactionsControllerTests private TransactionsController controller; private Mock mockService; + private Mock mockTransactionBalanceServiceService; [SetUp] public void Setup() @@ -22,7 +23,8 @@ public void Setup() this.transactionModelBuilder = new TransactionModelBuilder(); this.mockService = new Mock(); - this.controller = new TransactionsController(this.mockService.Object); + this.mockTransactionBalanceServiceService = new Mock(); + this.controller = new TransactionsController(this.mockService.Object, this.mockTransactionBalanceServiceService.Object); } } } \ No newline at end of file diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs b/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs rename to src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs b/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs rename to src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs b/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs rename to src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs b/src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs rename to src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs b/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs rename to src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs b/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs similarity index 91% rename from api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs rename to src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs index d3956db..761ae71 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs +++ b/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs @@ -15,10 +15,12 @@ namespace FinancialHub.WebApi.Controllers public class TransactionsController : Controller { private readonly ITransactionsService service; + private readonly ITransactionBalanceService transactionBalanceService; - public TransactionsController(ITransactionsService service) + public TransactionsController(ITransactionsService service, ITransactionBalanceService transactionBalanceService) { this.service = service; + this.transactionBalanceService = transactionBalanceService; } [HttpGet] @@ -41,7 +43,7 @@ public async Task GetMyTransactions([FromQuery] TransactionFilter /// Transaction to be created public async Task CreateTransaction([FromBody] TransactionModel transaction) { - var result = await this.service.CreateAsync(transaction); + var result = await this.transactionBalanceService.CreateTransactionAsync(transaction); if (result.HasError) { @@ -75,7 +77,6 @@ public async Task UpdateTransaction([FromRoute] Guid id, [FromBod } return Ok(new SaveResponse(result.Data)); - } [HttpDelete("{id}")] diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs similarity index 96% rename from api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs rename to src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs index 907ad07..4b54624 100644 --- a/api/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -50,6 +50,7 @@ public static IServiceCollection AddServices(this IServiceCollection services) services.AddScoped(); services.AddScoped(); + services.AddScoped(); return services; } diff --git a/api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj rename to src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Program.cs b/src/FinancialHub/FinancialHub.WebApi/Program.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Program.cs rename to src/FinancialHub/FinancialHub.WebApi/Program.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json b/src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json rename to src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs b/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs rename to src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx b/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx rename to src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Startup.cs b/src/FinancialHub/FinancialHub.WebApi/Startup.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Startup.cs rename to src/FinancialHub/FinancialHub.WebApi/Startup.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs b/src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs rename to src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs b/src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs rename to src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs b/src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs rename to src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs b/src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs rename to src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs diff --git a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json b/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json rename to src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json diff --git a/api/src/FinancialHub/FinancialHub.WebApi/appsettings.json b/src/FinancialHub/FinancialHub.WebApi/appsettings.json similarity index 100% rename from api/src/FinancialHub/FinancialHub.WebApi/appsettings.json rename to src/FinancialHub/FinancialHub.WebApi/appsettings.json diff --git a/api/src/FinancialHub/FinancialHub.sln b/src/FinancialHub/FinancialHub.sln similarity index 100% rename from api/src/FinancialHub/FinancialHub.sln rename to src/FinancialHub/FinancialHub.sln diff --git a/api/src/FinancialHub/docker-compose.yml b/src/FinancialHub/docker-compose.yml similarity index 100% rename from api/src/FinancialHub/docker-compose.yml rename to src/FinancialHub/docker-compose.yml From c33b152c02e48fe74b3111bafe4bb58fc8f765a5 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Fri, 17 Mar 2023 12:56:34 -0300 Subject: [PATCH 11/30] Release v0.3.2 (#127) * Adds : TransactionBalanceService DeleteTransaction * Fix : BalanceRepository ChangeTracker * Remove : delete Balances & Accounts endpoints * Remove : Accounts delete endpoint * Remove : Balances delete endpoint --- .../Services/ITransactionBalanceService.cs | 1 + .../Repositories/BalancesRepository.cs | 7 +- .../Controllers/AccountsControllerTests.cs | 2 + .../Controllers/BalancesControllerTests.cs | 2 + .../TransactionBalanceTests.delete.cs | 158 ++++++++++++++++++ .../Services/TransactionBalanceService.cs | 29 +++- .../Controllers/AccountsController.cs | 1 + .../Controllers/BalancesController.cs | 1 + .../Controllers/TransactionsController.cs | 22 +-- 9 files changed, 205 insertions(+), 18 deletions(-) create mode 100644 src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs index 5f2854d..0e36821 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs +++ b/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs @@ -10,5 +10,6 @@ public interface ITransactionBalanceService Task> CreateTransactionAsync(TransactionModel transaction); Task> UpdateTransactionAsync(Guid id,TransactionModel transaction); Task UpdateAmountAsync(TransactionModel oldTransaction, TransactionModel newTransaction); + Task> DeleteTransactionAsync(Guid id); } } diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs index 8492daf..c397a27 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs +++ b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs @@ -57,12 +57,9 @@ public async Task ChangeAmountAsync(Guid balanceId, decimal value public async Task ChangeAmountAsync(Guid balanceId, decimal value) { var balance = await this.GetByIdAsync(balanceId); + context.ChangeTracker.Clear(); balance.Amount = value; - balance.UpdateTime = DateTimeOffset.Now; - - context.Update(balance); - await context.SaveChangesAsync(); - return balance; + return await this.UpdateAsync(balance); } } } diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs index ffbc35d..f8dd816 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs +++ b/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs @@ -154,6 +154,7 @@ public async Task Put_NonExistingAccount_ReturnNotFoundError() } [Test] + [Ignore("Endpoint disabled")] public async Task Delete_ReturnNoContent() { var id = Guid.NewGuid(); @@ -166,6 +167,7 @@ public async Task Delete_ReturnNoContent() } [Test] + [Ignore("Endpoint disabled")] public async Task Delete_RemovesAccountFromDatabase() { var id = Guid.NewGuid(); diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs b/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs index 12f7522..719b7d0 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs +++ b/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs @@ -192,6 +192,7 @@ public async Task Put_NotExistingBalance_ReturnsNotFound() } [Test] + [Ignore("Endpoint disabled")] public async Task Delete_ReturnsNoContent() { var id = Guid.NewGuid(); @@ -204,6 +205,7 @@ public async Task Delete_ReturnsNoContent() } [Test] + [Ignore("Endpoint disabled")] public async Task Delete_RemovesBalanceFromDatabase() { var id = Guid.NewGuid(); diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs new file mode 100644 index 0000000..4088df6 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs @@ -0,0 +1,158 @@ +using System; +using System.Threading.Tasks; +using Moq; +using NUnit.Framework; +using FinancialHub.Domain.Enums; +using FinancialHub.Domain.Results.Errors; + +namespace FinancialHub.Services.NUnitTests.Services +{ + public partial class TransactionBalanceTests + { + [Test] + public async Task DeleteTransactionAsync_ValidTransactionId_ReturnsTrue() + { + var id = Guid.NewGuid(); + var transaction = this.transactionModelBuilder.WithId(id).Generate(); + this.transactionsService + .Setup(x => x.DeleteAsync(id)) + .ReturnsAsync(1); + this.transactionsService + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(transaction); + this.balancesService + .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny())); + + var result = await this.service.DeleteTransactionAsync(id); + + Assert.IsFalse(result.HasError); + Assert.IsTrue(result.Data); + } + + [Test] + public async Task DeleteTransactionAsync_NoDeletion_ReturnsFalse() + { + var id = Guid.NewGuid(); + this.transactionsService + .Setup(x => x.DeleteAsync(id)) + .ReturnsAsync(0); + + var result = await this.service.DeleteTransactionAsync(id); + Assert.IsFalse(result.Data); + } + + [Test] + public async Task DeleteTransactionAsync_TransactionDeleteError_ReturnsError() + { + var id = Guid.NewGuid(); + var error = new ServiceError(1, "error message"); + this.transactionsService + .Setup(x => x.DeleteAsync(id)) + .ReturnsAsync(error); + var result = await this.service.DeleteTransactionAsync(id); + + Assert.IsTrue(result.HasError); + Assert.AreEqual(error.Message ,result.Error.Message); + } + + [Test] + public async Task DeleteTransactionAsync_PaidTransaction_UpdatesAmount() + { + var id = Guid.NewGuid(); + var transaction = this.transactionModelBuilder + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .WithId(id) + .Generate(); + + this.transactionsService + .Setup(x => x.DeleteAsync(id)) + .ReturnsAsync(1); + this.transactionsService + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(transaction); + this.balancesService + .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny())) + .Verifiable(); + await this.service.DeleteTransactionAsync(id); + + this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny()), Times.Once); + } + + [Test] + public async Task DeleteTransactionAsync_NotPaidTransaction_DoNotUpdateAmount() + { + var id = Guid.NewGuid(); + var transaction = this.transactionModelBuilder + .WithStatus(TransactionStatus.NotCommitted) + .WithId(id) + .Generate(); + + this.transactionsService + .Setup(x => x.DeleteAsync(id)) + .ReturnsAsync(1); + this.transactionsService + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(transaction); + await this.service.DeleteTransactionAsync(id); + + this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny()), Times.Never); + } + + [Test] + public async Task DeleteTransactionAsync_EarnTransction_RemovesAmount() + { + var balance = this.balanceModelBuilder.Generate(); + var id = Guid.NewGuid(); + var transaction = this.transactionModelBuilder + .WithBalance(balance) + .WithType(TransactionType.Earn) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .WithId(id) + .Generate(); + var expectedAmount = balance.Amount - transaction.Amount; + + this.transactionsService + .Setup(x => x.DeleteAsync(id)) + .ReturnsAsync(1); + this.transactionsService + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(transaction); + this.balancesService + .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, expectedAmount)) + .Verifiable(); + await this.service.DeleteTransactionAsync(id); + + this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, expectedAmount), Times.Once); + } + + [Test] + public async Task DeleteTransactionAsync_ExpenseTransction_AddsAmount() + { + var balance = this.balanceModelBuilder.Generate(); + var id = Guid.NewGuid(); + var transaction = this.transactionModelBuilder + .WithBalance(balance) + .WithType(TransactionType.Expense) + .WithStatus(TransactionStatus.Committed) + .WithActiveStatus(true) + .WithId(id) + .Generate(); + var expectedAmount = balance.Amount + transaction.Amount; + + this.transactionsService + .Setup(x => x.DeleteAsync(id)) + .ReturnsAsync(1); + this.transactionsService + .Setup(x => x.GetByIdAsync(id)) + .ReturnsAsync(transaction); + this.balancesService + .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, expectedAmount)) + .Verifiable(); + await this.service.DeleteTransactionAsync(id); + + this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, expectedAmount), Times.Once); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs b/src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs index 5c43cfa..aed6d4b 100644 --- a/src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs +++ b/src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs @@ -1,6 +1,6 @@ -using FinancialHub.Domain.Models; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Models; using FinancialHub.Domain.Results; -using FinancialHub.Domain.Interfaces.Services; using FinancialHub.Domain.Enums; namespace FinancialHub.Services.Services @@ -181,5 +181,30 @@ public async Task> UpdateTransactionAsync(Guid i return transactionResult; } + + public async Task> DeleteTransactionAsync(Guid id) + { + var oldTransaction = await this.transactionsService.GetByIdAsync(id); + + var deleted = await this.transactionsService.DeleteAsync(id); + + if (deleted.HasError) + return deleted.Error; + if (deleted.Data == 0) + return false; + + var transaction = oldTransaction.Data; + if (transaction.IsPaid) + { + var amount = transaction.Balance.Amount; + amount = transaction.Type == TransactionType.Earn? + amount - transaction.Amount: + amount + transaction.Amount; + + await this.balancesService.UpdateAmountAsync(transaction.BalanceId, amount); + } + + return true; + } } } diff --git a/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs b/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs index 253219b..36c50af 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs +++ b/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs @@ -94,6 +94,7 @@ public async Task UpdateAccount([FromRoute] Guid id, [FromBody] A /// Deletes an existing account on database /// /// id of the account + [NonAction] [HttpDelete("{id}")] public async Task DeleteAccount([FromRoute] Guid id) { diff --git a/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs b/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs index dbdc668..ad14152 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs +++ b/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs @@ -58,6 +58,7 @@ public async Task UpdateBalance([FromRoute] Guid id, [FromBody] B return Ok(new SaveResponse(response.Data)); } + [NonAction] [HttpDelete("{id}")] public async Task DeleteBalance([FromRoute] Guid id) { diff --git a/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs b/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs index 761ae71..761dcfc 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs +++ b/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs @@ -23,24 +23,24 @@ public TransactionsController(ITransactionsService service, ITransactionBalanceS this.transactionBalanceService = transactionBalanceService; } - [HttpGet] - [ProducesResponseType(typeof(ListResponse), 200)] /// /// Get all transaction of the system (will be changed to only one user and added filters) /// + [HttpGet] + [ProducesResponseType(typeof(ListResponse), 200)] public async Task GetMyTransactions([FromQuery] TransactionFilter filter) { var response = await service.GetAllByUserAsync("mock", filter); return Ok(new ListResponse(response.Data)); } - [HttpPost] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] /// /// Creates an transaction on database (will be changed to only one user) /// /// Transaction to be created + [HttpPost] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] public async Task CreateTransaction([FromBody] TransactionModel transaction) { var result = await this.transactionBalanceService.CreateTransactionAsync(transaction); @@ -56,14 +56,14 @@ public async Task CreateTransaction([FromBody] TransactionModel t return Ok(new SaveResponse(result.Data)); } - [HttpPut("{id}")] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] /// /// Updates an existing transaction on database /// /// id of the transaction /// transaction changes + [HttpPut("{id}")] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] public async Task UpdateTransaction([FromRoute] Guid id, [FromBody] TransactionModel transaction) { var result = await this.service.UpdateAsync(id, transaction); @@ -79,15 +79,15 @@ public async Task UpdateTransaction([FromRoute] Guid id, [FromBod return Ok(new SaveResponse(result.Data)); } - [HttpDelete("{id}")] - [ProducesResponseType(204)] /// /// Deletes an existing transaction on database /// /// id of the transaction + [HttpDelete("{id}")] + [ProducesResponseType(204)] public async Task DeleteTransaction([FromRoute] Guid id) { - await service.DeleteAsync(id); + await transactionBalanceService.DeleteTransactionAsync(id); return NoContent(); } } From 07252cd1f998f92bb9f2f96f651f4cac875f5349 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Wed, 29 Mar 2023 22:12:13 -0300 Subject: [PATCH 12/30] Release v0.3.3 (#134) * Adds : CategoryEntityMapping, AccountEntityMapping, TransactionEntityMapping e BalanceEntityMapping * Changes Configuration for Infra.Data and Services project * Changes : IServiceCollectionExtensions for Infra and Services project * Removes : Action body for coverage --- .../Entities/AccountEntity.cs | 5 -- .../Entities/BalanceEntity.cs | 8 --- .../Entities/CategoryEntity.cs | 5 -- .../Entities/TransactionEntity.cs | 14 ----- .../Contexts/FinancialHubContext.cs | 35 +---------- .../IServiceCollectionExtensions.cs | 31 ++++++++++ .../FinancialHub.Infra.Data.csproj | 2 + .../Mappings/AccountEntityMapping.cs | 27 +++++++++ .../Mappings/BalanceEntityMapping.cs | 40 +++++++++++++ .../Mappings/CategoryEntityMapping.cs | 27 +++++++++ .../Mappings/TransactionEntityMapping.cs | 59 +++++++++++++++++++ .../Repositories/AccountsRepository.cs | 2 - .../IServiceCollectionExtensions.cs | 27 +++++++++ .../FinancialHub.Services.csproj | 2 + .../IServiceCollectionExtensions.cs | 41 +++---------- .../FinancialHub.WebApi.csproj | 11 ---- .../FinancialHub.WebApi/Startup.cs | 32 ++-------- 17 files changed, 230 insertions(+), 138 deletions(-) create mode 100644 src/FinancialHub/FinancialHub.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Infra.Data/Mappings/AccountEntityMapping.cs create mode 100644 src/FinancialHub/FinancialHub.Infra.Data/Mappings/BalanceEntityMapping.cs create mode 100644 src/FinancialHub/FinancialHub.Infra.Data/Mappings/CategoryEntityMapping.cs create mode 100644 src/FinancialHub/FinancialHub.Infra.Data/Mappings/TransactionEntityMapping.cs create mode 100644 src/FinancialHub/FinancialHub.Services/Extensions/Configurations/IServiceCollectionExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs b/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs index f8b5727..04d2a52 100644 --- a/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs +++ b/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs @@ -1,16 +1,11 @@ using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; namespace FinancialHub.Domain.Entities { - [Table("accounts")] public class AccountEntity : BaseEntity { - [Column("name",TypeName = "varchar(200)")] public string Name { get; set; } - [Column("description", TypeName = "varchar(500)")] public string Description { get; set; } - [Column("active")] public bool IsActive { get; set; } public ICollection Balances { get; set; } diff --git a/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs b/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs index c46abe4..6281e30 100644 --- a/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs +++ b/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs @@ -1,26 +1,18 @@ using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; namespace FinancialHub.Domain.Entities { - [Table("balances")] public class BalanceEntity : BaseEntity { - [Column("name",TypeName = "varchar(200)")] public string Name { get; set; } - [Column("currency",TypeName = "varchar(50)")] public string Currency { get; set; } - [Column("amount", TypeName = "money")] public decimal Amount { get; set; } - [Column("active")] public bool IsActive { get; set; } - [Column("account_id")] public Guid AccountId { get; set; } public AccountEntity Account { get; set; } - public ICollection Transactions { get; set; } } } diff --git a/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs b/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs index 9a62ac0..9d85a11 100644 --- a/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs +++ b/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs @@ -1,16 +1,11 @@ using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; namespace FinancialHub.Domain.Entities { - [Table("categories")] public class CategoryEntity : BaseEntity { - [Column("name", TypeName = "varchar(200)")] public string Name { get; set; } - [Column("description", TypeName = "varchar(500)")] public string Description { get; set; } - [Column("active")] public bool IsActive { get; set; } public ICollection Transactions { get; set; } diff --git a/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs b/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs index d7bf237..cfb4573 100644 --- a/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs +++ b/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs @@ -1,38 +1,24 @@ using System; using FinancialHub.Domain.Enums; -using System.ComponentModel.DataAnnotations.Schema; namespace FinancialHub.Domain.Entities { - [Table("transactions")] public class TransactionEntity : BaseEntity { - [Column("description", TypeName = "varchar(500)")] public string Description { get; set; } - - [Column("amount",TypeName = "money")] public decimal Amount { get; set; } - [Column("target_date")] public DateTimeOffset TargetDate { get; set; } - [Column("finish_date")] public DateTimeOffset FinishDate { get; set; } - [Column("balance_id")] public Guid BalanceId { get; set; } public BalanceEntity Balance { get; set; } - [Column("category_id")] - [ForeignKey("category_id")] public Guid CategoryId { get; set; } public CategoryEntity Category { get; set; } - [Column("active")] public bool IsActive { get; set; } - - [Column("status")] public TransactionStatus Status { get; set; } - [Column("type")] public TransactionType Type { get; set; } } } \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs b/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs index a2896fc..7519d0f 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs +++ b/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs @@ -1,4 +1,5 @@ using FinancialHub.Domain.Entities; +using FinancialHub.Infra.Data.Mappings; using Microsoft.EntityFrameworkCore; using System.Diagnostics.CodeAnalysis; @@ -12,39 +13,7 @@ public FinancialHubContext([NotNull] DbContextOptions options) : base(options) protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity(table => - { - table.HasKey(t => t.Id); - table.HasIndex(t => t.Id).IsUnique(true); - - table.HasOne(x => x.Balance) - .WithMany(x => x.Transactions) - .HasForeignKey(x => x.BalanceId) - .HasPrincipalKey(x => x.Id) - .IsRequired(true); - table.Navigation(t => t.Balance).AutoInclude(); - - table.HasOne(x => x.Category) - .WithMany(x => x.Transactions) - .HasForeignKey(x => x.CategoryId) - .HasPrincipalKey(x => x.Id) - .IsRequired(true); - table.Navigation(t => t.Category).AutoInclude(); - }); - - modelBuilder.Entity(table => - { - table.HasKey(t => t.Id); - table.HasIndex(t => t.Id).IsUnique(true); - - table.HasOne(x => x.Account) - .WithMany(x => x.Balances) - .HasForeignKey(x => x.AccountId) - .HasPrincipalKey(x => x.Id) - .IsRequired(true); - table.Navigation(t => t.Account).AutoInclude(); - }); - + modelBuilder.ApplyConfigurationsFromAssembly(typeof(FinancialHubContext).Assembly); base.OnModelCreating(modelBuilder); } diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..55d6790 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -0,0 +1,31 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.EntityFrameworkCore; +using FinancialHub.Domain.Interfaces.Repositories; +using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Infra.Data.Repositories; + +namespace FinancialHub.Infra.Data.Extensions.Configurations +{ + public static class IServiceCollectionExtensions + { + public static IServiceCollection AddRepositories(this IServiceCollection services, IConfiguration configuration) + { + services.AddDbContext( + provider => + provider.UseSqlServer( + configuration.GetConnectionString("default"), + x => x + .MigrationsAssembly("FinancialHub.Infra.Migrations") + .MigrationsHistoryTable("migrations") + ) + ); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj b/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj index b84f938..660d3df 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj +++ b/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/AccountEntityMapping.cs b/src/FinancialHub/FinancialHub.Infra.Data/Mappings/AccountEntityMapping.cs new file mode 100644 index 0000000..2eed4e9 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Infra.Data/Mappings/AccountEntityMapping.cs @@ -0,0 +1,27 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace FinancialHub.Infra.Data.Mappings +{ + internal class AccountEntityMapping : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.Property(t => t.Name) + .HasColumnName("name") + .HasMaxLength(200) + .IsRequired(); + + builder.Property(t => t.Description) + .HasColumnName("description") + .HasMaxLength(500) + .IsRequired(); + + builder.Property(t => t.IsActive) + .HasColumnName("active"); + + builder.ToTable("accounts"); + } + } +} \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/BalanceEntityMapping.cs b/src/FinancialHub/FinancialHub.Infra.Data/Mappings/BalanceEntityMapping.cs new file mode 100644 index 0000000..3d0e927 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Infra.Data/Mappings/BalanceEntityMapping.cs @@ -0,0 +1,40 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace FinancialHub.Infra.Data.Mappings +{ + internal class BalanceEntityMapping : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(t => t.Id); + builder.HasIndex(t => t.Id).IsUnique(true); + + builder.Property(t => t.Name) + .HasColumnName("name") + .HasMaxLength(200); + builder.Property(t => t.Currency) + .HasColumnName("currency") + .HasMaxLength(50); + builder.Property(t => t.Amount) + .HasColumnType("money") + .IsRequired(); + builder.Property(t => t.IsActive) + .HasColumnName("active") + .IsRequired(); + + builder.Property(t => t.AccountId) + .HasColumnName("account_id") + .IsRequired(); + builder.HasOne(x => x.Account) + .WithMany(x => x.Balances) + .HasForeignKey(x => x.AccountId) + .HasPrincipalKey(x => x.Id) + .IsRequired(); + builder.Navigation(t => t.Account).AutoInclude(); + + builder.ToTable("balances"); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/CategoryEntityMapping.cs b/src/FinancialHub/FinancialHub.Infra.Data/Mappings/CategoryEntityMapping.cs new file mode 100644 index 0000000..b83679f --- /dev/null +++ b/src/FinancialHub/FinancialHub.Infra.Data/Mappings/CategoryEntityMapping.cs @@ -0,0 +1,27 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace FinancialHub.Infra.Data.Mappings +{ + internal class CategoryEntityMapping : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.Property(t => t.Name) + .HasColumnName("name") + .HasMaxLength(200) + .IsRequired(); + + builder.Property(t => t.Description) + .HasColumnName("description") + .HasMaxLength(500) + .IsRequired(); + + builder.Property(t => t.IsActive) + .HasColumnName("active"); + + builder.ToTable("categories"); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/TransactionEntityMapping.cs b/src/FinancialHub/FinancialHub.Infra.Data/Mappings/TransactionEntityMapping.cs new file mode 100644 index 0000000..3566a2b --- /dev/null +++ b/src/FinancialHub/FinancialHub.Infra.Data/Mappings/TransactionEntityMapping.cs @@ -0,0 +1,59 @@ +using FinancialHub.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace FinancialHub.Infra.Data.Mappings +{ + internal class TransactionEntityMapping : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(t => t.Id); + builder.HasIndex(t => t.Id).IsUnique(true); + + builder.Property(t => t.Description) + .HasColumnName("description") + .HasMaxLength(500); + builder.Property(t => t.Amount) + .HasColumnType("money") + .IsRequired(); + builder.Property(t => t.TargetDate) + .HasColumnName("target_date") + .IsRequired(); + builder.Property(t => t.FinishDate) + .HasColumnName("finish_date"); + + builder.Property(t => t.BalanceId) + .HasColumnName("balance_id") + .IsRequired(); + builder.HasOne(x => x.Balance) + .WithMany(x => x.Transactions) + .HasForeignKey(x => x.BalanceId) + .HasPrincipalKey(x => x.Id) + .IsRequired(); + builder.Navigation(t => t.Balance).AutoInclude(); + + builder.Property(t => t.CategoryId) + .HasColumnName("category_id") + .IsRequired(); + builder.HasOne(x => x.Category) + .WithMany(x => x.Transactions) + .HasForeignKey(x => x.CategoryId) + .HasPrincipalKey(x => x.Id) + .IsRequired(); + builder.Navigation(t => t.Category).AutoInclude(); + + builder.Property(t => t.IsActive) + .HasColumnName("active") + .IsRequired(); + builder.Property(t => t.Status) + .HasColumnName("status") + .IsRequired(); + builder.Property(t => t.Type) + .HasColumnName("type") + .IsRequired(); + + builder.ToTable("transactions"); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs index 64fdba3..cce4c66 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs +++ b/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs @@ -1,11 +1,9 @@ using FinancialHub.Domain.Entities; using FinancialHub.Domain.Interfaces.Repositories; using FinancialHub.Infra.Data.Contexts; -using System.ComponentModel; namespace FinancialHub.Infra.Data.Repositories { - [Category("Repositories")] public class AccountsRepository : BaseRepository, IAccountsRepository { public AccountsRepository(FinancialHubContext context) : base(context) diff --git a/src/FinancialHub/FinancialHub.Services/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Services/Extensions/Configurations/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..184ac18 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Services/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -0,0 +1,27 @@ +using Microsoft.Extensions.DependencyInjection; +using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Domain.Mappers; +using FinancialHub.Services.Mappers; +using FinancialHub.Services.Services; + +namespace FinancialHub.Services.Extensions.Configurations +{ + public static class IServiceCollectionExtensions + { + public static IServiceCollection AddServices(this IServiceCollection services) + { + services.AddAutoMapper(typeof(FinancialHubAutoMapperProfile)); + services.AddScoped(); + + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + + services.AddScoped(); + services.AddScoped(); + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj b/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj index 815baab..f7d331a 100644 --- a/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj +++ b/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj @@ -8,6 +8,8 @@ + + diff --git a/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs index 4b54624..3108109 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -1,17 +1,10 @@ -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Services.Services; -using FinancialHub.Infra.Data.Repositories; - -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Services.Mappers; using FluentValidation; -using FinancialHub.Domain.Mappers; +using FluentValidation.AspNetCore; +using Microsoft.OpenApi.Models; using FinancialHub.Domain.Models; using FinancialHub.WebApi.Validators; -using FluentValidation.AspNetCore; namespace FinancialHub.WebApi.Extensions.Configurations { @@ -26,31 +19,11 @@ public static IServiceCollection AddApiConfigurations(this IServiceCollection se config.AssumeDefaultVersionWhenUnspecified = true; config.ReportApiVersions = true; }); - return services; - } - //TODO: find a better method organization - public static IServiceCollection AddRepositories(this IServiceCollection services) - { - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - - services.AddScoped(); - return services; - } - - public static IServiceCollection AddServices(this IServiceCollection services) - { - services.AddAutoMapper(typeof(FinancialHubAutoMapperProfile)); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - - services.AddScoped(); - services.AddScoped(); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Financial Hub WebApi", Version = "v1" }); + }); return services; } diff --git a/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj index 90afc92..8694c6d 100644 --- a/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -9,21 +9,10 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/FinancialHub/FinancialHub.WebApi/Startup.cs b/src/FinancialHub/FinancialHub.WebApi/Startup.cs index ccf5bd4..f91fdc5 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Startup.cs +++ b/src/FinancialHub/FinancialHub.WebApi/Startup.cs @@ -1,12 +1,12 @@ -using FinancialHub.Infra.Data.Contexts; -using FinancialHub.WebApi.Extensions.Configurations; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models; +using FinancialHub.WebApi.Extensions.Configurations; +using FinancialHub.Infra.Data.Extensions.Configurations; +using FinancialHub.Services.Extensions.Configurations; namespace FinancialHub.WebApi { @@ -21,29 +21,11 @@ public Startup(IConfiguration configuration) public void ConfigureServices(IServiceCollection services) { - services.AddDbContext( - provider =>{ - provider.UseSqlServer( - Configuration.GetConnectionString("default"), - x => x - .MigrationsAssembly("FinancialHub.Infra.Migrations") - .MigrationsHistoryTable("migrations") - ); - } - ); - - //services.AddLogging(); - - services.AddRepositories(); - services.AddServices(); - services.AddValidators(); services.AddApiConfigurations(); - //services.AddHealthCheck(); - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "Financial Hub WebApi", Version = "v1" }); - }); + services.AddValidators(); + services.AddServices(); + services.AddRepositories(Configuration); services.AddMvc().AddNewtonsoftJson(); } @@ -59,8 +41,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseRouting(); - //app.UseAuthorization(); - app.UseEndpoints(endpoints => { endpoints.MapControllers(); From b4dad7e66192349ddc80f598c58b1943a849fe15 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Tue, 18 Jul 2023 23:40:50 -0300 Subject: [PATCH 13/30] Release v0.4.0 * Adds Auth/User project * Adds Basic Auth/User Project structure * Adds Auth/User features * Adds Auth/User tests * Adds EntityFramework Migration Tool * Adds Signup/Signin endpoint * Adds "Testing" environment appsettings to Auth project * Adds ValidatorRulesExtensions * Adds Token generation * Adds Token Authentication to User endpoints * Fix project references * Fix Sonar Code yaml --- .github/workflows/sonarcloud.yml | 2 +- README.md | 5 +- src/FinancialHub/.config/dotnet-tools.json | 12 + .../Asserts/ControllerResponseAssert.cs | 29 ++ .../Signin/SigninControllerTests.cs | 19 ++ .../Signin/SigninControllerTests.get.cs | 45 +++ .../Signup/SignupControllerTests.create.cs | 50 +++ .../Signup/SignupControllerTests.cs | 19 ++ .../Users/UsersControllerTests.create.cs | 60 ++++ .../Controllers/Users/UsersControllerTests.cs | 31 ++ .../Users/UsersControllerTests.get.cs | 57 ++++ .../Users/UsersControllerTests.update.cs | 84 +++++ ...FinancialHub.Auth.Application.Tests.csproj | 25 ++ .../Usings.cs | 19 ++ .../.editorconfig | 7 + .../Controllers/SigninController.cs | 45 +++ .../Controllers/SignupController.cs | 41 +++ .../Controllers/UsersController.cs | 106 +++++++ .../IServiceCollectionExtensions.cs | 23 ++ .../Extensions/SwaggerExtensions.cs | 48 +++ .../FinancialHub.Auth.Application.csproj | 24 ++ .../FinancialHub.Auth.Application/Usings.cs | 8 + .../Entities/CredentialEntity.cs | 10 + .../Entities/UserEntity.cs | 12 + .../FinancialHub.Auth.Domain.csproj | 13 + .../Interfaces/Helpers/IPasswordHelper.cs | 9 + .../Providers/ICredentialProvider.cs | 11 + .../Interfaces/Providers/ISigninProvider.cs | 9 + .../Interfaces/Providers/ISignupProvider.cs | 9 + .../Interfaces/Providers/IUserProvider.cs | 11 + .../Repositories/ICredentialRepository.cs | 12 + .../Repositories/IUserRepository.cs | 11 + .../Resources/IErrorMessageProvider.cs | 11 + .../Interfaces/Services/ISigninService.cs | 9 + .../Interfaces/Services/ISignupService.cs | 9 + .../Interfaces/Services/ITokenService.cs | 9 + .../Interfaces/Services/IUserService.cs | 11 + .../Models/CredentialModel.cs | 9 + .../Models/SigninModel.cs | 8 + .../Models/SignupModel.cs | 12 + .../Models/TokenModel.cs | 14 + .../Models/UserModel.cs | 10 + .../FinancialHub.Auth.Domain/Usings.cs | 3 + .../Assertions/DbContextAssert.cs | 19 ++ .../FinancialHub.Auth.Infra.Data.Tests.csproj | 27 ++ .../Fixtures/DatabaseFixture.cs | 70 ++++ .../CredentialRepositoryTests.create.cs | 50 +++ .../Credentials/CredentialRepositoryTests.cs | 31 ++ .../CredentialRepositoryTests.get.cs | 88 ++++++ .../Users/UserRepositoryTests.create.cs | 37 +++ .../Repositories/Users/UserRepositoryTests.cs | 29 ++ .../Users/UserRepositoryTests.get.cs | 26 ++ .../Users/UserRepositoryTests.update.cs | 46 +++ .../Usings.cs | 13 + .../Contexts/FinancialHubAuthContext.cs | 16 + .../IServiceCollectionExtensions.cs | 34 ++ .../FinancialHub.Auth.Infra.Data.csproj | 23 ++ .../Mapping/UserCredentialEntityMapping.cs | 27 ++ .../Mapping/UserEntityMapping.cs | 29 ++ ...20230503220050_Adds_User_Table.Designer.cs | 73 +++++ .../20230503220050_Adds_User_Table.cs | 36 +++ ...615215715_Add_Credential_Table.Designer.cs | 122 +++++++ .../20230615215715_Add_Credential_Table.cs | 46 +++ .../FinancialHubAuthContextModelSnapshot.cs | 120 +++++++ .../Repositories/CredentialRepository.cs | 39 +++ .../Repositories/UserRepository.cs | 43 +++ .../FinancialHub.Auth.Infra.Data/Usings.cs | 4 + .../FinancialHub.Auth.Infra.Migrations.csproj | 17 + .../FinancialHub.Auth.Infra.Tests.csproj | 25 ++ .../CredentialProviderTests.create.cs | 34 ++ .../Credentials/CredentialProviderTests.cs | 29 ++ .../CredentialProviderTests.get.cs | 71 +++++ .../Providers/Signin/SigninProviderTests.cs | 41 +++ .../SigninProviderTests.get_accounts.cs | 45 +++ .../SignupProviderTests.create_account.cs | 53 ++++ .../Providers/Signup/SignupProviderTests.cs | 32 ++ .../Users/UserProviderTests.create.cs | 34 ++ .../Providers/Users/UserProviderTests.cs | 25 ++ .../Providers/Users/UserProviderTests.get.cs | 35 ++ .../Users/UserProviderTests.update.cs | 33 ++ .../FinancialHub.Auth.Infra.Tests/Usings.cs | 16 + .../IServiceCollectionExtensions.cs | 33 ++ .../FinancialHub.Auth.Infra.csproj | 19 ++ .../Helpers/PasswordHelper.cs | 26 ++ .../FinancialHubAuthCredentialProfile.cs | 21 ++ .../Mappers/FinancialHubAuthProfile.cs | 10 + .../Providers/CredentialProvider.cs | 45 +++ .../Providers/SigninProvider.cs | 29 ++ .../Providers/SignupProvider.cs | 38 +++ .../Providers/UserProvider.cs | 43 +++ .../FinancialHub.Auth.Infra/Usings.cs | 5 + .../Base/BaseControllerTests.cs | 30 ++ .../Controllers/SigninControllerTests.cs | 162 ++++++++++ .../Controllers/SignupControllerTests.cs | 125 ++++++++ .../Controllers/UsersControllerTests.cs | 299 ++++++++++++++++++ .../Extensions/HttpClientExtensions.cs | 90 ++++++ .../Extensions/HttpContentExtensions.cs | 18 ++ .../HttpResponseMessageExtensions.cs | 27 ++ .../Utils/HttpClientExtensionsParameters.cs | 16 + .../FinancialHub.Auth.IntegrationTests.csproj | 27 ++ .../Setup/FinancialHubAuthApiFixture.auth.cs | 15 + .../Setup/FinancialHubAuthApiFixture.cs | 38 +++ .../FinancialHubAuthApiFixture.database.cs | 45 +++ .../Usings.cs | 17 + .../IServiceCollectionExtensions.cs | 18 ++ .../FinancialHub.Auth.Resources.csproj | 35 ++ .../Providers/ErrorMessageProvider.cs | 22 ++ .../Errors/ErrorMessages.Designer.cs | 108 +++++++ .../Resources/Errors/ErrorMessages.pt-BR.resx | 135 ++++++++ .../Resources/Errors/ErrorMessages.resx | 135 ++++++++ .../FinancialHub.Auth.Services.Tests.csproj | 28 ++ .../Services/Signin/SigninServiceTests.cs | 30 ++ .../Services/Signin/SigninServiceTests.get.cs | 70 ++++ .../Signup/SignupServiceTests.create.cs | 78 +++++ .../Services/Signup/SignupServiceTests.cs | 30 ++ .../Services/Token/TokenServiceTests.cs | 34 ++ .../Token/TokenServiceTests.generate.cs | 77 +++++ .../Services/Users/UserServiceTests.create.cs | 36 +++ .../Services/Users/UserServiceTests.cs | 22 ++ .../Services/Users/UserServiceTests.get.cs | 42 +++ .../Services/Users/UserServiceTests.update.cs | 46 +++ .../Usings.cs | 8 + .../Validators/SigninModelValidatorTests.cs | 125 ++++++++ .../Validators/SignupModelValidatorTests.cs | 232 ++++++++++++++ .../Validators/UserValidatorTests.cs | 175 ++++++++++ .../Configurations/TokenServiceSettings.cs | 10 + .../IServiceCollectionExtensions.Auth.cs | 75 +++++ .../IServiceCollectionExtensions.Docs.cs | 30 ++ .../IServiceCollectionExtensions.cs | 45 +++ .../FinancialHub.Auth.Services.csproj | 27 ++ .../Services/SigninService.cs | 24 ++ .../Services/SignupService.cs | 27 ++ .../Services/TokenService.cs | 57 ++++ .../Services/UserService.cs | 43 +++ .../FinancialHub.Auth.Services/Usings.cs | 5 + .../Rules/ValidatorRulesExtensions.cs | 46 +++ .../Validators/SigninModelValidator.cs | 18 ++ .../Validators/SignupModelValidator.cs | 32 ++ .../Validators/UserValidator.cs | 25 ++ .../Builders/Entities/UserEntityBuilder.cs | 47 +++ .../Builders/Models/UserModelBuilder.cs | 47 +++ .../FinancialHub.Auth.Tests.Commom.csproj | 17 + .../Assertions/EntityAssert.cs | 40 +++ .../Assertions/ModelAssert.cs | 49 +++ .../Assertions/ResponseAssert.cs | 27 ++ .../Entities/UserCredentialEntityBuilder.cs | 42 +++ .../Builders/Entities/UserEntityBuilder.cs | 37 +++ .../Builders/Models/SigninModelBuilder.cs | 23 ++ .../Builders/Models/SignupModelBuilder.cs | 58 ++++ .../Builders/Models/TokenModelBuilder.cs | 11 + .../Models/UserCredentialModelBuilder.cs | 29 ++ .../Builders/Models/UserModelBuilder.cs | 37 +++ .../FinancialHub.Auth.Tests.Common.csproj | 18 ++ .../FinancialHub.Auth.Tests.Common/Usings.cs | 9 + .../FinancialHub.Auth.WebApi.csproj | 34 ++ .../FinancialHub.Auth.WebApi/Program.cs | 41 +++ .../Properties/launchSettings.json | 31 ++ .../appsettings.Development.json | 17 + .../appsettings.Testing.json | 17 + .../FinancialHub.Auth.WebApi/appsettings.json | 12 + .../FinancialHub.Domain.Tests.csproj | 3 + .../Errors/ValidationsErrorResponse.cs | 15 + .../Responses/Success/ItemResponse.cs | 9 + .../FinancialHub.Infra.Data.NUnitTests.csproj | 3 - .../Contexts/FinancialHubContext.cs | 1 - .../FinancialHub.Infra.Migrations.csproj | 5 - .../FinancialHub.Services.csproj | 1 - .../FinancialHub.WebApi.csproj | 4 + src/FinancialHub/FinancialHub.sln | 167 ++++++++-- 169 files changed, 6449 insertions(+), 39 deletions(-) create mode 100644 src/FinancialHub/.config/dotnet-tools.json create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Asserts/ControllerResponseAssert.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.get.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.create.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.create.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.get.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.update.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application/.editorconfig create mode 100644 src/FinancialHub/FinancialHub.Auth.Application/Controllers/SigninController.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application/Controllers/SignupController.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application/Controllers/UsersController.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application/Extensions/SwaggerExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Application/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Entities/UserEntity.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Models/CredentialModel.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Models/SigninModel.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Models/SignupModel.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Models/TokenModel.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Models/UserModel.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Data/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra.Tests/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/Providers/SigninProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/Providers/SignupProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/Providers/UserProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Infra/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.IntegrationTests/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx create mode 100644 src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/FinancialHub.Auth.Services.Tests.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.get.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.create.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.generate.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.get.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.update.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SigninModelValidatorTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SignupModelValidatorTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/UserValidatorTests.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Configurations/TokenServiceSettings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Auth.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Docs.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/FinancialHub.Auth.Services.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Services/SigninService.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Services/SignupService.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Services/TokenService.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Services/UserService.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Validators/Rules/ValidatorRulesExtensions.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Validators/SigninModelValidator.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Validators/SignupModelValidator.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Validators/UserValidator.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Entities/UserEntityBuilder.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Models/UserModelBuilder.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Commom/FinancialHub.Auth.Tests.Commom.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Common/Usings.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs create mode 100644 src/FinancialHub/FinancialHub.Auth.WebApi/Properties/launchSettings.json create mode 100644 src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Development.json create mode 100644 src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Testing.json create mode 100644 src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.json create mode 100644 src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationsErrorResponse.cs create mode 100644 src/FinancialHub/FinancialHub.Domain/Responses/Success/ItemResponse.cs diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 2e22d03..9387f63 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -76,7 +76,7 @@ jobs: /o:"chingling-152" ` /d:sonar.login="${{ secrets.SONAR_TOKEN }}" ` /d:sonar.host.url="https://sonarcloud.io" ` - /d:sonar.coverage.exclusions=/FinancialHub.Infra.Migrations/** ` + /d:sonar.coverage.exclusions="**/Migrations/." ` /d:sonar.cs.opencover.reportsPaths="/TestResults/**/coverage.opencover.xml" echo "build project" diff --git a/README.md b/README.md index 9ccc0ec..f544a9e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,14 @@ # My Financial Hub +This is a completely experimental project, a lot of stuff here was not made with the purpose of being used in production environment. +Until v1 release, everything of this project could be changed. [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Chingling152_my-financial-hub&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Chingling152_my-financial-hub) ## What's planned for the future - **[Monthly Milestones](https://github.com/Chingling152/my-financial-hub/issues/9)** - **[Earns/Expenses Portion](https://github.com/Chingling152/my-financial-hub/issues/10)** -- **Transaction exports (xlsx, pdf)** +- **Transaction relatories** +- **Dashboards** - **Earns/Expenses average** - **Earns/Expenses predictions** diff --git a/src/FinancialHub/.config/dotnet-tools.json b/src/FinancialHub/.config/dotnet-tools.json new file mode 100644 index 0000000..0d1da73 --- /dev/null +++ b/src/FinancialHub/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "6.0.1", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Asserts/ControllerResponseAssert.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Asserts/ControllerResponseAssert.cs new file mode 100644 index 0000000..c7d453a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Asserts/ControllerResponseAssert.cs @@ -0,0 +1,29 @@ +namespace FinancialHub.Auth.Application.Tests.Asserts +{ + public static class ControllerResponseAssert + { + public static void IsValid(BaseResponse expectedResponse, ObjectResult result) + { + Assert.Multiple(() => + { + Assert.That(result.StatusCode, Is.EqualTo(200)); + Assert.That(result.Value, Is.TypeOf(expectedResponse.GetType())); + + var response = result.Value as BaseResponse; + ResponseAssert.IsValid(expectedResponse, response!); + }); + } + + public static void HasError(BaseErrorResponse expectedResponse, ObjectResult result, int expectedStatusCode = 400) + { + Assert.Multiple(() => + { + Assert.That(result.StatusCode, Is.EqualTo(expectedStatusCode)); + Assert.That(result.Value, Is.TypeOf(expectedResponse.GetType())); + + var response = result.Value as ValidationErrorResponse; + ResponseAssert.HasError(expectedResponse, response!); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.cs new file mode 100644 index 0000000..bf4df06 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.cs @@ -0,0 +1,19 @@ +namespace FinancialHub.Auth.Application.Tests.Controllers +{ + public partial class SigninControllerTests + { + private SigninController controller; + private Mock serviceMock; + private SigninModelBuilder builder; + private TokenModelBuilder tokenBuilder; + + [SetUp] + public void SetUp() + { + builder = new SigninModelBuilder(); + tokenBuilder = new TokenModelBuilder(); + serviceMock = new Mock(); + controller = new SigninController(serviceMock.Object); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.get.cs new file mode 100644 index 0000000..dc4b654 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.get.cs @@ -0,0 +1,45 @@ +using FinancialHub.Auth.Application.Tests.Asserts; + +namespace FinancialHub.Auth.Application.Tests.Controllers +{ + public partial class SigninControllerTests + { + [Test] + public async Task GetAsync_SuccessfulValidation_Returns200Ok() + { + var signin = this.builder.Generate(); + var token = this.tokenBuilder.Generate(); + var expectedResponse = new ItemResponse(token); + + serviceMock + .Setup(x => x.AuthenticateAsync(signin)) + .ReturnsAsync(token); + + var response = await this.controller.SigninAsync(signin); + + var result = response as ObjectResult; + + Assert.That(result, Is.Not.Null); + ControllerResponseAssert.IsValid(expectedResponse, result); + } + + [Test] + public async Task CreateAsync_ValidationFailed_Returns401Unauthorized() + { + var signin = this.builder.Generate(); + var error = new ServiceError(401, "Wrong e-mail or passsword"); + var expectedResponse = new ValidationErrorResponse(error.Message); + + serviceMock + .Setup(x => x.AuthenticateAsync(signin)) + .ReturnsAsync(error); + + var response = await this.controller.SigninAsync(signin); + + var result = response as ObjectResult; + + Assert.That(result, Is.Not.Null); + ControllerResponseAssert.HasError(expectedResponse, result, 401); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.create.cs new file mode 100644 index 0000000..e323a7e --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.create.cs @@ -0,0 +1,50 @@ +using FinancialHub.Auth.Application.Tests.Asserts; + +namespace FinancialHub.Auth.Application.Tests.Controllers +{ + public partial class SignupControllerTests + { + [Test] + public async Task CreateAsync_SuccessfulCreation_Returns200Ok() + { + var signup = this.builder.Generate(); + var user = this.userBuilder + .WithName(signup.FirstName) + .WithLastName(signup.FirstName) + .WithEmail(signup.Email) + .WithBirthDate(signup.BirthDate) + .Generate(); + var expectedResponse = new ItemResponse(user); + + serviceMock + .Setup(x => x.CreateAccountAsync(signup)) + .ReturnsAsync(user); + + var response = await this.controller.SignupAsync(signup); + + var result = response as ObjectResult; + + Assert.That(result, Is.Not.Null); + ControllerResponseAssert.IsValid(expectedResponse, result); + } + + [Test] + public async Task CreateAsync_FailedCreation_Returns400BadRequest() + { + var signup = this.builder.Generate(); + var error = new ServiceError(400, "User data invalid"); + var expectedResponse = new ValidationErrorResponse(error.Message); + + serviceMock + .Setup(x => x.CreateAccountAsync(signup)) + .ReturnsAsync(error); + + var response = await this.controller.SignupAsync(signup); + + var result = response as ObjectResult; + + Assert.That(result, Is.Not.Null); + ControllerResponseAssert.HasError(expectedResponse, result); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.cs new file mode 100644 index 0000000..1353b79 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.cs @@ -0,0 +1,19 @@ +namespace FinancialHub.Auth.Application.Tests.Controllers +{ + public partial class SignupControllerTests + { + private SignupController controller; + private Mock serviceMock; + private SignupModelBuilder builder; + private UserModelBuilder userBuilder; + + [SetUp] + public void SetUp() + { + builder = new SignupModelBuilder(); + userBuilder = new UserModelBuilder(); + serviceMock = new Mock(); + controller = new SignupController(serviceMock.Object); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.create.cs new file mode 100644 index 0000000..a6879e6 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.create.cs @@ -0,0 +1,60 @@ +using System.Diagnostics.CodeAnalysis; + +namespace FinancialHub.Auth.Application.Tests.Controllers +{ + public partial class UsersControllerTests + { + [Test] + [Obsolete("Obsolete while CreateUserAsync is Obsolete")] + [SuppressMessage("Info Code Smell", "S1133:Deprecated code should be removed", Justification = "Remove with CreateUserAsync")] + public async Task CreateAsync_SuccessfulCreation_Returns200Ok() + { + var user = this.builder.Generate(); + var expectedResponse = new SaveResponse(user); + + serviceMock + .Setup(x => x.CreateAsync(user)) + .ReturnsAsync(user); + + var response = await this.controller.CreateUserAsync(user); + + var result = response as ObjectResult; + Assert.Multiple(() => + { + Assert.That(result!.StatusCode, Is.EqualTo(200)); + Assert.That(result!.Value, Is.TypeOf(expectedResponse.GetType())); + + var response = result.Value as SaveResponse; + AssertValidResponse(expectedResponse, response!); + }); + } + + [Test] + [Obsolete("Obsolete while CreateUserAsync is Obsolete")] + [SuppressMessage("Info Code Smell", "S1133:Deprecated code should be removed", Justification = "Remove with CreateUserAsync")] + public async Task CreateAsync_FailedCreation_Returns400BadRequest() + { + var user = this.builder.Generate(); + var error = new ServiceError(400, "User data invalid"); + var serviceResult = new ServiceResult(error: error); + + serviceMock + .Setup(x => x.CreateAsync(user)) + .ReturnsAsync(serviceResult); + + var expectedResponse = new ValidationErrorResponse(error.Message); + + var response = await this.controller.CreateUserAsync(user); + + var result = response as ObjectResult; + Assert.Multiple(() => + { + Assert.That(result!.StatusCode, Is.EqualTo(400)); + Assert.That(result!.Value, Is.TypeOf(expectedResponse.GetType())); + + var response = result.Value as ValidationErrorResponse; + AssertErrorResponse(expectedResponse, response!); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.cs new file mode 100644 index 0000000..886b676 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.cs @@ -0,0 +1,31 @@ +namespace FinancialHub.Auth.Application.Tests.Controllers +{ + public partial class UsersControllerTests + { + private UsersController controller; + private Mock serviceMock; + private UserModelBuilder builder; + + [SetUp] + public void SetUp() + { + serviceMock = new Mock(); + controller = new UsersController(serviceMock.Object); + builder = new UserModelBuilder(); + } + + protected static void AssertValidResponse(BaseResponse expected, BaseResponse response) + { + Assert.That(response.Data, Is.EqualTo(expected.Data)); + } + + protected static void AssertErrorResponse(BaseErrorResponse expected, BaseErrorResponse response) + { + Assert.Multiple(() => + { + Assert.That(response.Message, Is.EqualTo(expected.Message)); + Assert.That(response.Code, Is.EqualTo(expected.Code)); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.get.cs new file mode 100644 index 0000000..f8effb6 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.get.cs @@ -0,0 +1,57 @@ +namespace FinancialHub.Auth.Application.Tests.Controllers +{ + public partial class UsersControllerTests + { + [Test] + public async Task GetUserAsync_FoundUser_Returns200Ok() + { + var id = Guid.NewGuid(); + var user = builder + .WithId(id) + .Generate(); + var serviceResult = new ServiceResult(user); + + serviceMock + .Setup(x => x.GetAsync(id)) + .ReturnsAsync(serviceResult); + + var expectedResponse = new ItemResponse(user); + + var response = await controller.GetUserAsync(id); + var result = response as ObjectResult; + Assert.Multiple(() => + { + Assert.That(result!.StatusCode, Is.EqualTo(200)); + Assert.That(result!.Value, Is.TypeOf(expectedResponse.GetType())); + + var response = result.Value as ItemResponse; + AssertValidResponse(expectedResponse, response!); + }); + } + + [Test] + public async Task GetUserAsync_NotFoundUser_Returns404NotFound() + { + var id = Guid.NewGuid(); + var error = new ServiceError(404, "User not found"); + var serviceResult = new ServiceResult(error: error); + + serviceMock + .Setup(x => x.GetAsync(id)) + .ReturnsAsync(serviceResult); + + var expectedResponse = new NotFoundErrorResponse(error.Message); + + var response = await controller.GetUserAsync(id); + var result = response as ObjectResult; + Assert.Multiple(() => + { + Assert.That(result!.StatusCode, Is.EqualTo(404)); + Assert.That(result!.Value, Is.TypeOf(expectedResponse.GetType())); + + var response = result.Value as NotFoundErrorResponse; + AssertErrorResponse(expectedResponse, response!); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.update.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.update.cs new file mode 100644 index 0000000..f07a00b --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.update.cs @@ -0,0 +1,84 @@ +namespace FinancialHub.Auth.Application.Tests.Controllers +{ + public partial class UsersControllerTests + { + [Test] + public async Task UpdateAsync_ExistingUser_Returns200Ok() + { + var id = Guid.NewGuid(); + var user = this.builder.WithId(id).Generate(); + var serviceResult = new ServiceResult(user); + var expectedResponse = new SaveResponse(user); + + serviceMock + .Setup(x => x.UpdateAsync(id, user)) + .ReturnsAsync(serviceResult); + + var response = await this.controller.UpdateUserAsync(id, user); + var result = response as ObjectResult; + + Assert.Multiple(() => + { + Assert.That(result!.StatusCode, Is.EqualTo(200)); + Assert.That(result!.Value, Is.TypeOf(expectedResponse.GetType())); + + var response = result.Value as SaveResponse; + AssertValidResponse(expectedResponse, response!); + }); + } + + [Test] + public async Task UpdateAsync_NonExistingUser_Returns404NotFound() + { + var id = Guid.NewGuid(); + var user = this.builder.WithId(id).Generate(); + + var error = new ServiceError(404, "User data invalid"); + var serviceResult = new ServiceResult(error: error); + var expectedResponse = new NotFoundErrorResponse(error.Message); + + serviceMock + .Setup(x => x.UpdateAsync(id, user)) + .ReturnsAsync(serviceResult); + + var response = await this.controller.UpdateUserAsync(id, user); + var result = response as ObjectResult; + + Assert.Multiple(() => + { + Assert.That(result!.StatusCode, Is.EqualTo(404)); + Assert.That(result!.Value, Is.TypeOf(expectedResponse.GetType())); + + var response = result.Value as NotFoundErrorResponse; + AssertErrorResponse(expectedResponse, response!); + }); + } + + [Test] + public async Task UpdateAsync_UpdateError_Returns400BadRequest() + { + var id = Guid.NewGuid(); + var user = this.builder.WithId(id).Generate(); + + var error = new ServiceError(400, "User data invalid"); + var serviceResult = new ServiceResult(error: error); + var expectedResponse = new ValidationErrorResponse(error.Message); + + serviceMock + .Setup(x => x.UpdateAsync(id, user)) + .ReturnsAsync(serviceResult); + + var response = await this.controller.UpdateUserAsync(id, user); + var result = response as ObjectResult; + + Assert.Multiple(() => + { + Assert.That(result!.StatusCode, Is.EqualTo(400)); + Assert.That(result!.Value, Is.TypeOf(expectedResponse.GetType())); + + var response = result.Value as ValidationErrorResponse; + AssertErrorResponse(expectedResponse, response!); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj b/src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj new file mode 100644 index 0000000..537f416 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj @@ -0,0 +1,25 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs new file mode 100644 index 0000000..f493291 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs @@ -0,0 +1,19 @@ +global using Microsoft.AspNetCore.Mvc; + +global using Moq; +global using NUnit.Framework; + +global using FinancialHub.Auth.Tests.Common.Assertions; +global using FinancialHub.Auth.Tests.Common.Builders.Models; + +global using FinancialHub.Auth.Domain.Models; + +global using FinancialHub.Auth.Domain.Interfaces.Services; + +global using FinancialHub.Domain.Results; +global using FinancialHub.Domain.Results.Errors; + +global using FinancialHub.Domain.Responses.Success; +global using FinancialHub.Domain.Responses.Errors; + +global using FinancialHub.Auth.Application.Controllers; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Application/.editorconfig b/src/FinancialHub/FinancialHub.Auth.Application/.editorconfig new file mode 100644 index 0000000..6377fa0 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application/.editorconfig @@ -0,0 +1,7 @@ +[*.cs] + +# CS8618: O campo não anulável precisa conter um valor não nulo ao sair do construtor. Considere declará-lo como anulável. +dotnet_diagnostic.CS8618.severity = none + +# CS1591: O comentário XML ausente não foi encontrado para o tipo ou membro visível publicamente +dotnet_diagnostic.CS1591.severity = none diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SigninController.cs b/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SigninController.cs new file mode 100644 index 0000000..025bf7f --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SigninController.cs @@ -0,0 +1,45 @@ +using Microsoft.AspNetCore.Authorization; + +namespace FinancialHub.Auth.Application.Controllers +{ + [AllowAnonymous] + [ApiController] + [Route("[controller]")] + [Produces("application/json")] + public class SigninController : ControllerBase + { + private readonly ISigninService signinService; + + public SigninController(ISigninService signinService) + { + this.signinService = signinService; + } + + /// + /// Makes an Attempt to login an user + /// + /// An user credential to login + /// User Token after a successful login + /// Login fields Invalids + /// Email or Password Invalid + [HttpPost] + [ProducesResponseType(typeof(ItemResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] + [ProducesResponseType(typeof(ValidationErrorResponse), 401)] + public async Task SigninAsync([FromBody]SigninModel login) + { + var tokenResult = await this.signinService.AuthenticateAsync(login); + + if (tokenResult.HasError) + { + return Unauthorized( + new ValidationErrorResponse(tokenResult.Error.Message) + ); + } + + return Ok( + new ItemResponse(tokenResult.Data) + ); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SignupController.cs b/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SignupController.cs new file mode 100644 index 0000000..88df22c --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SignupController.cs @@ -0,0 +1,41 @@ +using Microsoft.AspNetCore.Authorization; + +namespace FinancialHub.Auth.Application.Controllers +{ + [AllowAnonymous] + [ApiController] + [Route("[controller]")] + [Produces("application/json")] + public class SignupController : ControllerBase + { + private readonly ISignupService signupService; + + public SignupController(ISignupService signupService) + { + this.signupService = signupService; + } + + /// + /// Creates an User and a Credential + /// + /// User and Credential informations + /// User and Credential Successfully created + /// User or Credential Validation error + [HttpPost] + [ProducesResponseType(typeof(ItemResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] + public async Task SignupAsync([FromBody] SignupModel signup) + { + var result = await signupService.CreateAccountAsync(signup); + + if(result.HasError) + { + return BadRequest( + error: new ValidationErrorResponse(result.Error.Message) + ); + } + + return Ok(new ItemResponse(result.Data)); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Controllers/UsersController.cs b/src/FinancialHub/FinancialHub.Auth.Application/Controllers/UsersController.cs new file mode 100644 index 0000000..4b7f38b --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application/Controllers/UsersController.cs @@ -0,0 +1,106 @@ +using Microsoft.AspNetCore.Authorization; + +namespace FinancialHub.Auth.Application.Controllers +{ + [Authorize] + [ApiController] + [Route("[controller]")] + [Produces("application/json")] + public class UsersController : ControllerBase + { + private readonly IUserService service; + + public UsersController(IUserService service) + { + this.service = service; + } + + /// + /// Gets an user by id + /// + /// id of the User + /// Existing user response + /// Non-Existing user response + [HttpGet("{id}")] + [ProducesResponseType(typeof(ItemResponse), 200)] + [ProducesResponseType(typeof(NotFoundErrorResponse), 404)] + [ProducesResponseType(typeof(ValidationErrorResponse), 401)] + public async Task GetUserAsync([FromRoute]Guid id) + { + var userResult = await service.GetAsync(id); + + if(userResult.HasError) + { + return StatusCode( + userResult.Error.Code, + new NotFoundErrorResponse(userResult.Error.Message) + ); + } + + return Ok( + new ItemResponse(userResult.Data) + ); + } + + /// + /// Creates an user + /// + /// User data to be saved + /// Successful user creation + /// Failed user creation + [HttpPost] + [Obsolete("removed : use /sign-up")] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] + [ProducesResponseType(typeof(ValidationErrorResponse), 401)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Info Code Smell", "S1133:Deprecated code should be removed", Justification = "In Progress")] + public async Task CreateUserAsync([FromBody] UserModel user) + { + var userResult = await service.CreateAsync(user); + + if (userResult.HasError) + { + return StatusCode( + userResult.Error.Code, + new ValidationErrorResponse(userResult.Error.Message) + ); + } + + return Ok(new SaveResponse(userResult.Data)); + } + + /// + /// Updates an user + /// + /// id of the User + /// User data to be updated (id field is ignored) + /// Successful update + /// Fail update + /// User not found response + [HttpPatch("{id}")] + [ProducesResponseType(typeof(SaveResponse), 200)] + [ProducesResponseType(typeof(ValidationErrorResponse), 400)] + [ProducesResponseType(typeof(NotFoundErrorResponse), 404)] + [ProducesResponseType(typeof(ValidationErrorResponse), 401)] + public async Task UpdateUserAsync([FromRoute] Guid id, [FromBody]UserModel user) + { + var userResult = await service.UpdateAsync(id, user); + + if (userResult.HasError) + { + if(userResult.Error.Code == 404) + { + return NotFound( + new NotFoundErrorResponse(userResult.Error.Message) + ); + } + + return BadRequest( + new ValidationErrorResponse(userResult.Error.Message) + ); + } + + return Ok(new SaveResponse(userResult.Data)); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..c0606bf --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using FinancialHub.Auth.Services.Extensions; +using FinancialHub.Auth.Resources.Extensions; +using FinancialHub.Auth.Infra.Extensions; +using FinancialHub.Auth.Infra.Data.Extensions; + +namespace FinancialHub.Auth.Application.Extensions +{ + public static class IServiceCollectionExtensions + { + public static IServiceCollection AddAuthApplication(this IServiceCollection services, IConfiguration configuration) + { + services + .AddAuthServices(configuration) + .AddAuthResources() + .AddAuthProviders(configuration) + .AddAuthRepositories(configuration); + + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Extensions/SwaggerExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/SwaggerExtensions.cs new file mode 100644 index 0000000..0141f82 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/SwaggerExtensions.cs @@ -0,0 +1,48 @@ +using System.Diagnostics.CodeAnalysis; +using System.Reflection; +using FinancialHub.Auth.Services.Extensions; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; + +namespace FinancialHub.Auth.Application.Extensions +{ + [ExcludeFromCodeCoverage] + public static class SwaggerExtensions + { + public static IServiceCollection AddAuthDocs(this IServiceCollection services) + { + services.AddEndpointsApiExplorer(); + services.AddSwaggerGen(c => + { + c.IncludeXmlComments( + Path.Combine( + AppContext.BaseDirectory, + $"{Assembly.GetExecutingAssembly().GetName().Name}.xml" + ) + ); + c.SwaggerDoc( + "v1", + new OpenApiInfo + { + Title = "Financial Hub Auth Api", + Version = "v1" + } + ); + + var schemes = services.GetAuthSecuritySchemes(); + + var requeriments = new OpenApiSecurityRequirement(); + + foreach (var scheme in schemes) + { + c.AddSecurityDefinition(scheme.Reference.Id, scheme); + + requeriments.Add(scheme, Array.Empty()); + } + + c.AddSecurityRequirement(requeriments); + }); + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj b/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj new file mode 100644 index 0000000..5d06204 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj @@ -0,0 +1,24 @@ + + + + net6.0 + enable + enable + True + + + + + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs new file mode 100644 index 0000000..0b4932f --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs @@ -0,0 +1,8 @@ +global using Microsoft.AspNetCore.Mvc; + +global using FinancialHub.Auth.Domain.Interfaces.Services; + +global using FinancialHub.Auth.Domain.Models; + +global using FinancialHub.Domain.Responses.Errors; +global using FinancialHub.Domain.Responses.Success; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs new file mode 100644 index 0000000..5f3b7f8 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs @@ -0,0 +1,10 @@ +namespace FinancialHub.Auth.Domain.Entities +{ + public class CredentialEntity : BaseEntity + { + public string Login { get; set; } + public string Password { get; set; } + public Guid UserId { get; set; } + public UserEntity User { get; set; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Entities/UserEntity.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Entities/UserEntity.cs new file mode 100644 index 0000000..025babe --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Entities/UserEntity.cs @@ -0,0 +1,12 @@ +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Auth.Domain.Entities +{ + public class UserEntity : BaseEntity + { + public string FirstName { get; set; } + public string LastName { get; set; } + public DateTime? BirthDate { get; set; } + public string Email { get; set; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj b/src/FinancialHub/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj new file mode 100644 index 0000000..7247294 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs new file mode 100644 index 0000000..f8e9559 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs @@ -0,0 +1,9 @@ +namespace FinancialHub.Auth.Domain.Interfaces.Helpers +{ + //TODO: use IPasswordHasher and IPasswordValidator + public interface IPasswordHelper + { + string Encrypt(string value); + bool Verify(string password, string encryptedPassword); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs new file mode 100644 index 0000000..2af4218 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs @@ -0,0 +1,11 @@ +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Domain.Interfaces.Providers +{ + public interface ICredentialProvider + { + Task CreateAsync(CredentialModel signup); + Task GetAsync(string email); + Task GetAsync(CredentialModel signup); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs new file mode 100644 index 0000000..9085a26 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs @@ -0,0 +1,9 @@ +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Domain.Interfaces.Providers +{ + public interface ISigninProvider + { + Task GetAccountAsync(SigninModel signin); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs new file mode 100644 index 0000000..34f3438 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs @@ -0,0 +1,9 @@ +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Domain.Interfaces.Providers +{ + public interface ISignupProvider + { + Task CreateAccountAsync(SignupModel signup); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs new file mode 100644 index 0000000..69911ca --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs @@ -0,0 +1,11 @@ +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Domain.Interfaces.Providers +{ + public interface IUserProvider + { + Task GetAsync(Guid id); + Task CreateAsync(UserModel user); + Task UpdateAsync(UserModel user); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs new file mode 100644 index 0000000..e85d569 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs @@ -0,0 +1,12 @@ +using FinancialHub.Auth.Domain.Entities; + +namespace FinancialHub.Auth.Domain.Interfaces.Repositories +{ + public interface ICredentialRepository + { + Task GetAsync(string username); + Task GetAsync(string username, string password); + Task> GetAsync(Guid userId); + Task CreateAsync(CredentialEntity credential); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs new file mode 100644 index 0000000..384b173 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs @@ -0,0 +1,11 @@ +using FinancialHub.Auth.Domain.Entities; + +namespace FinancialHub.Auth.Domain.Interfaces.Repositories +{ + public interface IUserRepository + { + Task GetAsync(Guid id); + Task CreateAsync(UserEntity user); + Task UpdateAsync(UserEntity user); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs new file mode 100644 index 0000000..64e78f9 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs @@ -0,0 +1,11 @@ +namespace FinancialHub.Auth.Domain.Interfaces.Resources +{ + public interface IErrorMessageProvider + { + string? Required { get; } + string? Invalid { get; } + string? MinLength { get; } + string? ConfirmPassword { get; } + string? MaxLength { get; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs new file mode 100644 index 0000000..6df6fae --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs @@ -0,0 +1,9 @@ +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Domain.Interfaces.Services +{ + public interface ISigninService + { + Task> AuthenticateAsync(SigninModel login); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs new file mode 100644 index 0000000..62add36 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs @@ -0,0 +1,9 @@ +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Domain.Interfaces.Services +{ + public interface ISignupService + { + Task> CreateAccountAsync(SignupModel signup); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs new file mode 100644 index 0000000..658f0af --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs @@ -0,0 +1,9 @@ +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Domain.Interfaces.Services +{ + public interface ITokenService + { + TokenModel GenerateToken(UserModel user); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs new file mode 100644 index 0000000..6ad7d7a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs @@ -0,0 +1,11 @@ +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Domain.Interfaces.Services +{ + public interface IUserService + { + Task> GetAsync(Guid id); + Task> CreateAsync(UserModel user); + Task> UpdateAsync(Guid id, UserModel user); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/CredentialModel.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Models/CredentialModel.cs new file mode 100644 index 0000000..f67eafd --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Models/CredentialModel.cs @@ -0,0 +1,9 @@ +namespace FinancialHub.Auth.Domain.Models +{ + public class CredentialModel + { + public string Login { get; set; } + public string Password { get; set; } + public Guid UserId { get; set; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/SigninModel.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Models/SigninModel.cs new file mode 100644 index 0000000..6510a37 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Models/SigninModel.cs @@ -0,0 +1,8 @@ +namespace FinancialHub.Auth.Domain.Models +{ + public class SigninModel + { + public string Email { get; set; } + public string Password { get; set; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/SignupModel.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Models/SignupModel.cs new file mode 100644 index 0000000..d099aa0 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Models/SignupModel.cs @@ -0,0 +1,12 @@ +namespace FinancialHub.Auth.Domain.Models +{ + public class SignupModel + { + public string FirstName { get; set; } + public string LastName { get; set; } + public DateTime? BirthDate { get; set; } + public string Email { get; set; } + public string Password { get; set; } + public string ConfirmPassword { get; set; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/TokenModel.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Models/TokenModel.cs new file mode 100644 index 0000000..f31e40c --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Models/TokenModel.cs @@ -0,0 +1,14 @@ +namespace FinancialHub.Auth.Domain.Models +{ + public class TokenModel + { + public string Token { get; } + public DateTime ExpiresIn { get; } + + public TokenModel(string token, DateTime expiresIn) + { + Token = token; + ExpiresIn = expiresIn; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/UserModel.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Models/UserModel.cs new file mode 100644 index 0000000..5ebb9db --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Models/UserModel.cs @@ -0,0 +1,10 @@ +namespace FinancialHub.Auth.Domain.Models +{ + public class UserModel : BaseModel + { + public string FirstName { get; set; } + public string LastName { get; set; } + public DateTime? BirthDate { get; set; } + public string Email { get; set; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Usings.cs new file mode 100644 index 0000000..208bdef --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Domain/Usings.cs @@ -0,0 +1,3 @@ +global using FinancialHub.Domain.Model; +global using FinancialHub.Domain.Results; +global using FinancialHub.Domain.Entities; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs new file mode 100644 index 0000000..a70ca0e --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs @@ -0,0 +1,19 @@ +using FinancialHub.Domain.Entities; + +namespace FinancialHub.Auth.Infra.Data.Tests.Assertions +{ + internal static class DbContextAssert + { + internal static void AssertCreated(DbContext context,T createdItem) + where T : BaseEntity + { + Assert.Multiple(() => + { + Assert.That(context.Set().ToList(), Is.Not.Empty); + + var datebaseUser = context.Set().First(u => u.Id == createdItem.Id); + Assert.That(datebaseUser, Is.EqualTo(createdItem)); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj new file mode 100644 index 0000000..4baebae --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj @@ -0,0 +1,27 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs new file mode 100644 index 0000000..6eef1e7 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs @@ -0,0 +1,70 @@ +using FinancialHub.Auth.Infra.Data.Contexts; +using Microsoft.Data.Sqlite; +using FinancialHub.Domain.Entities; +using System.Collections; + +namespace FinancialHub.Auth.Infra.Data.Tests.Fixtures +{ + public class DatabaseFixture : IEnumerable, IDisposable + { + public void Dispose() + { + GC.SuppressFinalize(this); + } + + public IEnumerator GetEnumerator() + { + yield return this; + } + + protected FinancialHubAuthContext context; + public FinancialHubAuthContext Context => context; + + protected Random random; + public Random Random => random; + + protected static FinancialHubAuthContext GetContext() + { + var conn = new SqliteConnection("DataSource=:memory:"); + conn.Open(); + var cfg = new DbContextOptionsBuilder().UseSqlite(conn); + cfg.EnableSensitiveDataLogging(true); + + return new FinancialHubAuthContext( + cfg.Options + ); + } + + public async Task InsertData(T item) where T: BaseEntity + { + var res = await this.context.Set().AddAsync(item); + item.Id = res.Entity.Id; + await this.context.SaveChangesAsync(); + res.State = EntityState.Detached; + + return res.Entity; + } + + public async Task> InsertData(IEnumerable items) where T : BaseEntity + { + await this.context.Set().AddRangeAsync(items); + await this.context.SaveChangesAsync(); + + return items; + } + + public void SetUp() + { + this.context = GetContext(); + this.context.Database.EnsureCreated(); + this.random = new Random(); + } + + public void TearDown() + { + this.context.Database.EnsureDeleted(); + this.context.Database.CloseConnection(); + this.Dispose(); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs new file mode 100644 index 0000000..0ebccd1 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs @@ -0,0 +1,50 @@ +namespace FinancialHub.Auth.Infra.Data.Tests.Repositories.Credentials +{ + public partial class CredentialRepositoryTests + { + [Test] + public async Task CreateAsync_ValidCredeential_InsertsCredential() + { + var user = await this.fixture.InsertData(this.userBuilder.Generate()); + var credential = this.builder.WithUserId(user.Id).Generate(); + + await this.repository.CreateAsync(credential); + + DbContextAssert.AssertCreated(this.fixture.Context, credential); + } + + [Test] + public async Task CreateAsync_ValidCredential_ReturnsCreatedCredential() + { + var user = await this.fixture.InsertData(this.userBuilder.Generate()); + var credential = this.builder.WithUserId(user.Id).Generate(); + + var result = await this.repository.CreateAsync(credential); + + Assert.That(result, Is.Not.Null); + EntityAssert.Equal(credential, result); + } + + [Test] + public async Task CreateAsync_CredentialWithExistingId_InsertsIntoDatabaseWithDifferentId() + { + var user = await this.fixture.InsertData(this.userBuilder.Generate()); + var credential = this.builder.WithUserId(user.Id).Generate(); + + await this.repository.CreateAsync(credential); + await this.repository.CreateAsync(credential); + + DbContextAssert.AssertCreated(this.fixture.Context, credential); + } + + [Test] + public void CreateAsync_UserNotCreated_ShouldThrowDbUpdateException() + { + var credential = this.builder.Generate(); + + Assert.ThrowsAsync( + async () => await this.repository.CreateAsync(credential) + ); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs new file mode 100644 index 0000000..0e4026a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs @@ -0,0 +1,31 @@ +namespace FinancialHub.Auth.Infra.Data.Tests.Repositories.Credentials +{ + [TestFixtureSource(typeof(DatabaseFixture))] + public partial class CredentialRepositoryTests + { + private readonly DatabaseFixture fixture; + private ICredentialRepository repository; + private UserCredentialEntityBuilder builder; + private UserEntityBuilder userBuilder; + + public CredentialRepositoryTests(DatabaseFixture fixture) + { + this.fixture = fixture; + } + + [SetUp] + public void SetUp() + { + this.fixture.SetUp(); + this.builder = new UserCredentialEntityBuilder(); + this.userBuilder = new UserEntityBuilder(); + this.repository = new CredentialRepository(this.fixture.Context); + } + + [TearDown] + public void TearDown() + { + this.fixture.TearDown(); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs new file mode 100644 index 0000000..4d93b30 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs @@ -0,0 +1,88 @@ +namespace FinancialHub.Auth.Infra.Data.Tests.Repositories.Credentials +{ + public partial class CredentialRepositoryTests + { + [Test] + public async Task GetAsyncByLogin_ExistingCredential_ReturnsCredential() + { + var user = await this.fixture.InsertData(userBuilder.Generate()); + var credential = builder + .WithUserId(user.Id) + .Generate(); + await this.fixture.InsertData(credential); + + var result = await this.repository.GetAsync(credential.Login); + + Assert.That(result, Is.Not.Null); + EntityAssert.Equal(credential, result); + } + + [Test] + public async Task GetAsyncByLogin_NotExistingCredential_ReturnsNull() + { + var user = await this.fixture.InsertData(userBuilder.Generate()); + var credential = builder + .WithUserId(user.Id) + .Generate(); + + var result = await this.repository.GetAsync(credential.Login); + + Assert.That(result, Is.Null); + } + + [Test] + public async Task GetAsyncByLoginAndPassword_ExistingCredential_ReturnsCredential() + { + var user = await this.fixture.InsertData(userBuilder.Generate()); + var credential = builder + .WithUserId(user.Id) + .Generate(); + await this.fixture.InsertData(credential); + + var result = await this.repository.GetAsync(credential.Login, credential.Password); + + Assert.That(result, Is.Not.Null); + EntityAssert.Equal(credential, result); + } + + [Test] + public async Task GetAsyncByLoginAndPassword_NotExistingCredential_ReturnsNull() + { + var user = await this.fixture.InsertData(userBuilder.Generate()); + var credential = builder + .WithUserId(user.Id) + .Generate(); + + var result = await this.repository.GetAsync(credential.Login, credential.Password); + + Assert.That(result, Is.Null); + } + + [Test] + public async Task GetAsyncByUserId_ExistingCredential_ReturnsCredential() + { + var expectedCount = fixture.Random.Next(1,10); + var user = await this.fixture.InsertData(userBuilder.Generate()); + + var credentials = builder + .WithUserId(user.Id) + .Generate(expectedCount); + await this.fixture.InsertData(credentials); + + var result = await this.repository.GetAsync(user.Id.GetValueOrDefault()); + + Assert.That(result, Is.Not.Empty); + Assert.That(result.Count(), Is.EqualTo(expectedCount)); + } + + [Test] + public async Task GetAsyncByUserId_NotExistingCredential_ReturnsEmptyArray() + { + var user = await this.fixture.InsertData(userBuilder.Generate()); + + var result = await this.repository.GetAsync(user.Id.GetValueOrDefault()); + + Assert.That(result, Is.Empty); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs new file mode 100644 index 0000000..ae3298b --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs @@ -0,0 +1,37 @@ +namespace FinancialHub.Auth.Infra.Data.Tests.Repositories +{ + public partial class UserRepositoryTests + { + [Test] + public async Task CreateAsync_ValidUser_InsertsUser() + { + var user = this.builder.Generate(); + + await this.repository.CreateAsync(user); + + DbContextAssert.AssertCreated(fixture.Context, user); + } + + [Test] + public async Task CreateAsync_ValidUser_ReturnsCreatedUser() + { + var user = this.builder.Generate(); + + var result = await this.repository.CreateAsync(user); + + Assert.That(result, Is.Not.Null); + EntityAssert.Equal(user, result); + } + + [Test] + public async Task CreateAsync_UserWithExistingId_InsertsIntoDatabaseWithDifferentId() + { + var user = this.builder.Generate(); + + await this.repository.CreateAsync(user); + await this.repository.CreateAsync(user); + + DbContextAssert.AssertCreated(fixture.Context, user); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs new file mode 100644 index 0000000..e4714a2 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs @@ -0,0 +1,29 @@ +namespace FinancialHub.Auth.Infra.Data.Tests.Repositories +{ + [TestFixtureSource(typeof(DatabaseFixture))] + public partial class UserRepositoryTests + { + private readonly DatabaseFixture fixture; + private IUserRepository repository; + private UserEntityBuilder builder; + + public UserRepositoryTests(DatabaseFixture fixture) + { + this.fixture = fixture; + } + + [SetUp] + public void SetUp() + { + this.fixture.SetUp(); + this.builder = new UserEntityBuilder(); + this.repository = new UserRepository(this.fixture.Context); + } + + [TearDown] + public void TearDown() + { + this.fixture.TearDown(); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs new file mode 100644 index 0000000..c2145bc --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs @@ -0,0 +1,26 @@ +namespace FinancialHub.Auth.Infra.Data.Tests.Repositories +{ + public partial class UserRepositoryTests + { + #region GetById + [Test] + public async Task GetAsync_ExistingUser_ReturnsUser() + { + var expectedUser = fixture.Context.Users.Add(builder.Generate()).Entity; + fixture.Context.SaveChanges(); + + var user = await repository.GetAsync(expectedUser.Id.GetValueOrDefault()); + + EntityAssert.Equal(expectedUser, user!); + } + + [Test] + public async Task GetAsync_NotExistingUser_ReturnsNull() + { + var user = await repository.GetAsync(Guid.NewGuid()); + + Assert.That(user, Is.Null); + } + #endregion + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs new file mode 100644 index 0000000..17490aa --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs @@ -0,0 +1,46 @@ +namespace FinancialHub.Auth.Infra.Data.Tests.Repositories +{ + public partial class UserRepositoryTests + { + [Test] + public async Task UpdateAsync_ExistingUser_ReturnsUpdatedUser() + { + var item = await this.fixture.InsertData(builder.Generate()); + + var newUser = builder.WithId(item.Id.GetValueOrDefault()).Generate(); + var updated = await repository.UpdateAsync(newUser); + + EntityAssert.Equal(newUser, updated); + } + + [Test] + public async Task UpdateAsync_ExistingUser_UpdatesUser() + { + var oldUser = await this.fixture.InsertData(builder.Generate()); + + var newUser = builder.WithId(oldUser.Id.GetValueOrDefault()).Generate(); + await repository.UpdateAsync(newUser); + + var data = fixture.Context.Users.FirstOrDefault(x => x.Id == oldUser.Id.GetValueOrDefault()); + EntityAssert.Equal(newUser, data!); + } + + [Test] + public void UpdateAsync_NotExistingUser_DoesNotUpdatesUser() + { + var newUser = builder.Generate(); + + Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(newUser)); + + var databaseUser = fixture.Context.Users.FirstOrDefault(u => u.Id == newUser.Id); + Assert.That(databaseUser, Is.Null); + } + + [Test] + public void UpdateAsync_NotExistingUser_ThrowsDbUpdateConcurrencyException() + { + var newUser = builder.Generate(); + Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(newUser)); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Usings.cs new file mode 100644 index 0000000..1814656 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Usings.cs @@ -0,0 +1,13 @@ +global using NUnit.Framework; +global using Microsoft.EntityFrameworkCore; + +global using FinancialHub.Auth.Tests.Common.Assertions; +global using FinancialHub.Auth.Tests.Common.Builders.Entities; + +global using FinancialHub.Auth.Domain.Entities; +global using FinancialHub.Auth.Domain.Interfaces.Repositories; + +global using FinancialHub.Auth.Infra.Data.Repositories; + +global using FinancialHub.Auth.Infra.Data.Tests.Fixtures; +global using FinancialHub.Auth.Infra.Data.Tests.Assertions; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs new file mode 100644 index 0000000..7a0c3bb --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs @@ -0,0 +1,16 @@ +namespace FinancialHub.Auth.Infra.Data.Contexts +{ + public class FinancialHubAuthContext : DbContext + { + public FinancialHubAuthContext(DbContextOptions options) : base(options){} + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.ApplyConfigurationsFromAssembly(typeof(FinancialHubAuthContext).Assembly); + base.OnModelCreating(modelBuilder); + } + + public DbSet Users { get; set; } + public DbSet Credentials { get; set; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..c10349c --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,34 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using FinancialHub.Auth.Infra.Data.Repositories; +using System.Diagnostics.CodeAnalysis; + +namespace FinancialHub.Auth.Infra.Data.Extensions +{ + [ExcludeFromCodeCoverage] + public static class IServiceCollectionExtensions + { + private static IServiceCollection AddAuthDatabase(this IServiceCollection services, IConfiguration configuration) + { + services.AddDbContext( + provider => + provider.UseSqlServer( + configuration.GetConnectionString("auth"), + x => x.MigrationsHistoryTable("auth_migrations") + ) + ); + + return services; + } + + public static IServiceCollection AddAuthRepositories(this IServiceCollection services, IConfiguration configuration) + { + services.AddAuthDatabase(configuration); + + services.AddScoped(); + services.AddScoped(); + + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj b/src/FinancialHub/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj new file mode 100644 index 0000000..c53923b --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs new file mode 100644 index 0000000..8dec29d --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace FinancialHub.Auth.Infra.Data.Mapping +{ + internal class UserCredentialEntityMapping : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.Property(x => x.Login) + .HasColumnName("login") + .HasMaxLength(200) + .IsRequired(); + + builder.Property(x => x.Password) + .HasColumnName("password") + .HasMaxLength(300) + .IsRequired(); + + builder.Property(x => x.UserId) + .HasColumnName("user_id") + .IsRequired(); + builder.HasOne(x => x.User); + + builder.ToTable("user_credential"); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs new file mode 100644 index 0000000..9115841 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace FinancialHub.Auth.Infra.Data.Mapping +{ + internal class UserEntityMapping : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.Property(t => t.FirstName) + .HasColumnName("first_name") + .HasMaxLength(300) + .IsRequired(); + + builder.Property(t => t.LastName) + .HasColumnName("last_name") + .HasMaxLength(300); + + builder.Property(t => t.BirthDate) + .HasColumnName("birth_name"); + + builder.Property(t => t.Email) + .HasColumnName("email") + .HasMaxLength(300) + .IsRequired(); + + builder.ToTable("users"); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs new file mode 100644 index 0000000..4fde734 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs @@ -0,0 +1,73 @@ +// +using System; +using System.Diagnostics.CodeAnalysis; +using FinancialHub.Auth.Infra.Data.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FinancialHub.Auth.Infra.Data.Migrations +{ + [DbContext(typeof(FinancialHubAuthContext))] + [Migration("20230503220050_Adds_User_Table")] + [ExcludeFromCodeCoverage] + partial class Adds_User_Table + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("FinancialHub.Auth.Domain.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("BirthDate") + .HasColumnType("datetime2") + .HasColumnName("birth_name"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("email"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("first_name"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("last_name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("users", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs new file mode 100644 index 0000000..c157839 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs @@ -0,0 +1,36 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FinancialHub.Auth.Infra.Data.Migrations +{ + public partial class Adds_User_Table : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "users", + columns: table => new + { + id = table.Column(type: "uniqueidentifier", nullable: false), + first_name = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false), + last_name = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false), + birth_name = table.Column(type: "datetime2", nullable: true), + email = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false), + creation_time = table.Column(type: "datetimeoffset", nullable: true), + update_time = table.Column(type: "datetimeoffset", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_users", x => x.id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "users"); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs new file mode 100644 index 0000000..e729730 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs @@ -0,0 +1,122 @@ +// +using System; +using System.Diagnostics.CodeAnalysis; +using FinancialHub.Auth.Infra.Data.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FinancialHub.Auth.Infra.Data.Migrations +{ + [DbContext(typeof(FinancialHubAuthContext))] + [Migration("20230615215715_Add_Credential_Table")] + [ExcludeFromCodeCoverage] + partial class Add_Credential_Table + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("FinancialHub.Auth.Domain.Entities.CredentialEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Login") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)") + .HasColumnName("login"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("password"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("user_credential", (string)null); + }); + + modelBuilder.Entity("FinancialHub.Auth.Domain.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("BirthDate") + .HasColumnType("datetime2") + .HasColumnName("birth_name"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("email"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("first_name"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("last_name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("users", (string)null); + }); + + modelBuilder.Entity("FinancialHub.Auth.Domain.Entities.CredentialEntity", b => + { + b.HasOne("FinancialHub.Auth.Domain.Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs new file mode 100644 index 0000000..fd702aa --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs @@ -0,0 +1,46 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FinancialHub.Auth.Infra.Data.Migrations +{ + public partial class Add_Credential_Table : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "user_credential", + columns: table => new + { + id = table.Column(type: "uniqueidentifier", nullable: false), + login = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + password = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false), + user_id = table.Column(type: "uniqueidentifier", nullable: false), + creation_time = table.Column(type: "datetimeoffset", nullable: true), + update_time = table.Column(type: "datetimeoffset", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_user_credential", x => x.id); + table.ForeignKey( + name: "FK_user_credential_users_user_id", + column: x => x.user_id, + principalTable: "users", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_user_credential_user_id", + table: "user_credential", + column: "user_id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "user_credential"); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs new file mode 100644 index 0000000..beeda6a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs @@ -0,0 +1,120 @@ +// +using System; +using System.Diagnostics.CodeAnalysis; +using FinancialHub.Auth.Infra.Data.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FinancialHub.Auth.Infra.Data.Migrations +{ + [ExcludeFromCodeCoverage] + [DbContext(typeof(FinancialHubAuthContext))] + partial class FinancialHubAuthContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("FinancialHub.Auth.Domain.Entities.CredentialEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Login") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)") + .HasColumnName("login"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("password"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier") + .HasColumnName("user_id"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("user_credential", (string)null); + }); + + modelBuilder.Entity("FinancialHub.Auth.Domain.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("id"); + + b.Property("BirthDate") + .HasColumnType("datetime2") + .HasColumnName("birth_name"); + + b.Property("CreationTime") + .HasColumnType("datetimeoffset") + .HasColumnName("creation_time"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("email"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("first_name"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)") + .HasColumnName("last_name"); + + b.Property("UpdateTime") + .HasColumnType("datetimeoffset") + .HasColumnName("update_time"); + + b.HasKey("Id"); + + b.ToTable("users", (string)null); + }); + + modelBuilder.Entity("FinancialHub.Auth.Domain.Entities.CredentialEntity", b => + { + b.HasOne("FinancialHub.Auth.Domain.Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs new file mode 100644 index 0000000..9eebe9b --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs @@ -0,0 +1,39 @@ +namespace FinancialHub.Auth.Infra.Data.Repositories +{ + public class CredentialRepository : ICredentialRepository + { + private readonly FinancialHubAuthContext context; + + public CredentialRepository(FinancialHubAuthContext context) + { + this.context = context; + } + + public async Task CreateAsync(CredentialEntity credential) + { + credential.Id = null; + credential.CreationTime = DateTimeOffset.Now; + credential.UpdateTime = DateTimeOffset.Now; + credential.User = default!; + + var entry = await this.context.Credentials.AddAsync(credential); + await this.context.SaveChangesAsync(); + return entry.Entity; + } + + public async Task GetAsync(string username) + { + return await this.context.Credentials.FirstOrDefaultAsync(x => x.Login == username); + } + + public async Task GetAsync(string username, string password) + { + return await this.context.Credentials.FirstOrDefaultAsync(x => x.Login == username && x.Password == password); + } + + public async Task> GetAsync(Guid userId) + { + return await this.context.Credentials.Where(x => x.UserId == userId).ToArrayAsync(); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs new file mode 100644 index 0000000..321e756 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs @@ -0,0 +1,43 @@ +namespace FinancialHub.Auth.Infra.Data.Repositories +{ + public class UserRepository : IUserRepository + { + private readonly FinancialHubAuthContext context; + + public UserRepository(FinancialHubAuthContext context) + { + this.context = context; + } + + public async Task CreateAsync(UserEntity user) + { + user.Id = null; + user.CreationTime = DateTimeOffset.Now; + user.UpdateTime = DateTimeOffset.Now; + + var entry = this.context.Users.Add(user); + await this.context.SaveChangesAsync(); + + return entry.Entity; + } + + public async Task GetAsync(Guid id) + { + return await this.context.Users + .AsNoTracking() + .FirstOrDefaultAsync(x => x.Id == id); + } + + public async Task UpdateAsync(UserEntity user) + { + user.UpdateTime = DateTimeOffset.Now; + + var res = context.Users.Update(user); + this.context.Entry(res.Entity).Property(x => x.CreationTime).IsModified = false; + + await context.SaveChangesAsync(); + + return res.Entity; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Usings.cs new file mode 100644 index 0000000..cb594b8 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data/Usings.cs @@ -0,0 +1,4 @@ +global using Microsoft.EntityFrameworkCore; +global using FinancialHub.Auth.Domain.Entities; +global using FinancialHub.Auth.Domain.Interfaces.Repositories; +global using FinancialHub.Auth.Infra.Data.Contexts; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj b/src/FinancialHub/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj new file mode 100644 index 0000000..e8cc180 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj new file mode 100644 index 0000000..de2e2f0 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj @@ -0,0 +1,25 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs new file mode 100644 index 0000000..18e0c3f --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs @@ -0,0 +1,34 @@ +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class CredentialProviderTests + { + [Test] + public async Task CreateAsync_ValidUser_ReturnsCreatedUser() + { + var credential = this.builder.Generate(); + + var credentialEntity = this.mapper.Map(credential); + mockRepository + .Setup(x => x.CreateAsync(It.IsAny())) + .ReturnsAsync(credentialEntity); + + var createdUser = await this.provider.CreateAsync(credential); + + Assert.That(createdUser, Is.Not.Null); + ModelAssert.Equal(credential, createdUser); + } + + [Test] + public void CreateAsync_RepositoryException_ThrowsException() + { + var credential = this.builder.Generate(); + var exc = new Exception("Exception Message"); + + mockRepository + .Setup(x => x.CreateAsync(It.IsAny())) + .ThrowsAsync(exc); + + Assert.ThrowsAsync(async () => await this.provider.CreateAsync(credential)); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs new file mode 100644 index 0000000..716b163 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs @@ -0,0 +1,29 @@ +using FinancialHub.Auth.Domain.Interfaces.Helpers; + +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class CredentialProviderTests + { + private IMapper mapper; + private Mock mockRepository; + private Mock passwordHelperMock; + private ICredentialProvider provider; + + private UserCredentialModelBuilder builder; + + [SetUp] + public void SetUp() + { + this.builder = new UserCredentialModelBuilder(); + + this.passwordHelperMock = new Mock(); + this.mapper = new MapperConfiguration(mc => + { + mc.AddProfile(new FinancialHubAuthCredentialProfile(this.passwordHelperMock.Object)); + } + ).CreateMapper(); + this.mockRepository = new Mock(); + this.provider = new CredentialProvider(this.mockRepository.Object, this.mapper); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs new file mode 100644 index 0000000..0268e57 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs @@ -0,0 +1,71 @@ +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class CredentialProviderTests + { + [Test] + public async Task GetAsyncByLogin_ExistingCredential_ReturnsCredential() + { + var credentialModel = this.builder.Generate(); + var login = credentialModel.Login; + var credentialEntity = this.mapper.Map(credentialModel); + + mockRepository + .Setup(x => x.GetAsync(login)) + .ReturnsAsync(credentialEntity) + .Verifiable(); + + var resultUser = await this.provider.GetAsync(login); + + Assert.That(resultUser, Is.Not.Null); + ModelAssert.Equal(credentialModel, credentialEntity); + mockRepository.Verify(x => x.GetAsync(login), Times.Once); + } + + [Test] + public async Task GetAsyncByLogin_NotExistingCredential_ReturnsNull() + { + var credentialModel = this.builder.Generate(); + var login = credentialModel.Login; + + mockRepository + .Setup(x => x.GetAsync(login)) + .ReturnsAsync((CredentialEntity?)default); + + var credential = await this.provider.GetAsync(login); + + Assert.That(credential, Is.Null); + mockRepository.Verify(x => x.GetAsync(login), Times.Once); + } + + [Test] + public async Task GetByCredentialAsync_ValidEmailAndPassword_ReturnsFullCredential() + { + var credentialModel = this.builder.Generate(); + var credentialEntity = this.mapper.Map(credentialModel); + + mockRepository + .Setup(x => x.GetAsync(credentialModel.Login, credentialModel.Password)) + .ReturnsAsync(credentialEntity) + .Verifiable(); + var resultUser = await this.provider.GetAsync(credentialModel); + + Assert.That(resultUser, Is.Not.Null); + ModelAssert.Equal(credentialModel, resultUser); + mockRepository.Verify(x => x.GetAsync(credentialModel.Login, credentialModel.Password), Times.Once); + } + + [Test] + public async Task GetByCredentialAsync_NotExistingCredential_ReturnsFullCredential() + { + var credentialModel = this.builder.Generate(); + + mockRepository + .Setup(x => x.GetAsync(credentialModel.Login, credentialModel.Password)) + .ReturnsAsync((CredentialEntity?)default); + + var credential = await this.provider.GetAsync(credentialModel); + + Assert.That(credential, Is.Null); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs new file mode 100644 index 0000000..bfc2ad1 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs @@ -0,0 +1,41 @@ +using FinancialHub.Auth.Domain.Interfaces.Helpers; +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class SigninProviderTests + { + private IMapper mapper; + + private Mock credentialProvider; + private Mock userProvider; + private Mock passwordHelper; + private ISigninProvider provider; + + private SigninModelBuilder builder; + private UserCredentialModelBuilder credentialBuilder; + private UserModelBuilder userBuilder; + + [SetUp] + public void SetUp() + { + this.builder = new SigninModelBuilder(); + this.credentialBuilder = new UserCredentialModelBuilder(); + this.userBuilder = new UserModelBuilder(); + + this.passwordHelper = new Mock(); + this.passwordHelper + .Setup(x => x.Encrypt(It.IsAny())) + .Returns(x => x); + + this.mapper = new MapperConfiguration(mc => + { + mc.AddProfile(new FinancialHubAuthCredentialProfile(this.passwordHelper.Object)); + }).CreateMapper(); + + this.userProvider = new Mock(); + this.credentialProvider = new Mock(); + this.provider = new SigninProvider(this.credentialProvider.Object, this.userProvider.Object, this.mapper); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs new file mode 100644 index 0000000..67b6b55 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs @@ -0,0 +1,45 @@ +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class SigninProviderTests + { + [Test] + public async Task GetAccountAsync_ExistingCredential_ReturnsExistingUser() + { + var signin = builder.Generate(); + var existingUser = userBuilder + .WithEmail(signin.Email) + .Generate(); + var credential = credentialBuilder + .WithLogin(signin.Email) + .WithPassword(signin.Password) + .WithUserId(existingUser.Id) + .Generate(); + + credentialProvider + .Setup(x => x.GetAsync(It.Is(x => x.Login == signin.Email))) + .ReturnsAsync(credential); + userProvider + .Setup(x => x.GetAsync(existingUser.Id.GetValueOrDefault())) + .ReturnsAsync(existingUser); + + var result = await provider.GetAccountAsync(signin); + + Assert.That(result, Is.Not.Null); + ModelAssert.Equal(existingUser, result); + } + + [Test] + public async Task GetAccountAsync_NotExistingCredential_ReturnsNull() + { + var signin = builder.Generate(); + credentialProvider + .Setup(x => x.GetAsync(It.Is(x => x.Login == signin.Email))) + .ReturnsAsync(default(CredentialModel?)) + .Verifiable(); + var result = await provider.GetAccountAsync(signin); + + Assert.That(result, Is.Null); + credentialProvider.Verify(x => x.GetAsync(It.Is(x => x.Login == signin.Email)), Times.Once); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs new file mode 100644 index 0000000..76fceb4 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs @@ -0,0 +1,53 @@ +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class SignupProviderTests + { + [Test] + public async Task CreateAccountAsync_ValidUser_ReturnsCreatedUser() + { + var signupModel = builder.Generate(); + + var user = mapper.Map(signupModel); + userProvider + .Setup(x => x.CreateAsync(It.IsAny())) + .ReturnsAsync(user); + + var credential = mapper.Map(signupModel); + credentialProvider + .Setup(x => x.CreateAsync(It.IsAny())) + .ReturnsAsync(credential); + + var createdAccount = await provider.CreateAccountAsync(signupModel); + + Assert.That(createdAccount, Is.Not.Null); + ModelAssert.Equal(user, createdAccount); + } + + [Test] + public async Task CreateAccountAsync_ValidUser_CallsCreateCredentialWithUserId() + { + var signupModel = builder.Generate(); + var guid = Guid.NewGuid(); + + var user = mapper.Map(signupModel); + user.Id = guid; + userProvider + .Setup(x => x.CreateAsync(It.IsAny())) + .ReturnsAsync(user); + + passwordHelper + .Setup(x => x.Encrypt(signupModel.Password)) + .Returns(signupModel.Password); + + var credential = mapper.Map(signupModel); + credentialProvider + .Setup(x => x.CreateAsync(It.IsAny())) + .ReturnsAsync(credential) + .Verifiable(); + + await provider.CreateAccountAsync(signupModel); + + credentialProvider.Verify(x => x.CreateAsync(It.Is(c => c.UserId == guid)), Times.Once); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs new file mode 100644 index 0000000..5e3ae5a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs @@ -0,0 +1,32 @@ +using FinancialHub.Auth.Domain.Interfaces.Helpers; + +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class SignupProviderTests + { + private IMapper mapper; + + private Mock credentialProvider; + private Mock userProvider; + private Mock passwordHelper; + private ISignupProvider provider; + + private SignupModelBuilder builder; + + [SetUp] + public void SetUp() + { + this.builder = new SignupModelBuilder(); + + this.passwordHelper = new Mock(); + this.mapper = new MapperConfiguration(mc => + { + mc.AddProfile(new FinancialHubAuthCredentialProfile(this.passwordHelper.Object)); + }).CreateMapper(); + + this.userProvider = new Mock(); + this.credentialProvider = new Mock(); + this.provider = new SignupProvider(this.credentialProvider.Object, this.userProvider.Object, this.mapper); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs new file mode 100644 index 0000000..b537199 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs @@ -0,0 +1,34 @@ +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class UserProviderTests + { + [Test] + public async Task CreateAsync_ValidUser_ReturnsCreatedUser() + { + var user = this.builder.Generate(); + + var userEntity = this.mapper.Map(user); + mockRepository + .Setup(x => x.CreateAsync(It.IsAny())) + .ReturnsAsync(userEntity); + + var createdUser = await this.provider.CreateAsync(user); + + Assert.That(createdUser, Is.Not.Null); + ModelAssert.Equal(user, createdUser); + } + + [Test] + public void CreateAsync_RepositoryException_ThrowsException() + { + var user = this.builder.Generate(); + var exc = new Exception("Exception Message"); + + mockRepository + .Setup(x => x.CreateAsync(It.IsAny())) + .ThrowsAsync(exc); + + Assert.ThrowsAsync(async () => await this.provider.CreateAsync(user)); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs new file mode 100644 index 0000000..58ead0c --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs @@ -0,0 +1,25 @@ +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class UserProviderTests + { + private IMapper mapper; + private Mock mockRepository; + private IUserProvider provider; + + private UserModelBuilder builder; + + [SetUp] + public void SetUp() + { + this.builder = new UserModelBuilder(); + + this.mapper = new MapperConfiguration(mc => + { + mc.AddProfile(new FinancialHubAuthProviderProfile()); + } + ).CreateMapper(); + this.mockRepository = new Mock(); + this.provider = new UserProvider(this.mockRepository.Object, this.mapper); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs new file mode 100644 index 0000000..5c509bc --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs @@ -0,0 +1,35 @@ +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class UserProviderTests + { + [Test] + public async Task GetByIdAsync_ExistingUser_ReturnsUser() + { + var id = Guid.NewGuid(); + var userModel = this.builder.WithId(id).Generate(); + + var userEntity = this.mapper.Map(userModel); + mockRepository + .Setup(x => x.GetAsync(id)) + .ReturnsAsync(userEntity); + var resultUser = await this.provider.GetAsync(id); + + Assert.That(resultUser, Is.Not.Null); + ModelAssert.Equal(userModel, resultUser); + } + + [Test] + public async Task GetByIdAsync_NotExistingUser_ReturnsNull() + { + var id = Guid.NewGuid(); + var userModel = this.builder.WithId(id).Generate(); + + mockRepository + .Setup(x => x.GetAsync(id)) + .ReturnsAsync((UserEntity?)default); + var user = await this.provider.GetAsync(id); + + Assert.That(user, Is.Null); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs new file mode 100644 index 0000000..7ad26ad --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs @@ -0,0 +1,33 @@ +namespace FinancialHub.Auth.Infra.Tests.Providers +{ + public partial class UserProviderTests + { + [Test] + public async Task UpdateAsync_ValidUser_ReturnsUpdatedUser() + { + var user = this.builder.Generate(); + + var userEntity = this.mapper.Map(user); + mockRepository + .Setup(x => x.UpdateAsync(It.IsAny())) + .ReturnsAsync(userEntity); + + var updatedUser = await this.provider.UpdateAsync(user); + + ModelAssert.Equal(user, updatedUser); + } + + [Test] + public void UpdateAsync_RepositoryException_ThrowsException() + { + var user = this.builder.Generate(); + var exc = new Exception("Exception Message"); + + mockRepository + .Setup(x => x.UpdateAsync(It.IsAny())) + .ThrowsAsync(exc); + + Assert.ThrowsAsync(async () => await this.provider.UpdateAsync(user)); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Usings.cs new file mode 100644 index 0000000..e7a0dd6 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Usings.cs @@ -0,0 +1,16 @@ +global using AutoMapper; + +global using Moq; +global using NUnit.Framework; + +global using FinancialHub.Auth.Tests.Common.Assertions; +global using FinancialHub.Auth.Tests.Common.Builders.Models; + +global using FinancialHub.Auth.Domain.Models; +global using FinancialHub.Auth.Domain.Entities; + +global using FinancialHub.Auth.Domain.Interfaces.Providers; +global using FinancialHub.Auth.Domain.Interfaces.Repositories; + +global using FinancialHub.Auth.Infra.Mappers; +global using FinancialHub.Auth.Infra.Providers; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..3e5b504 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using FinancialHub.Auth.Domain.Interfaces.Helpers; +using FinancialHub.Auth.Infra.Mappers; +using FinancialHub.Auth.Infra.Providers; +using FinancialHub.Auth.Infra.Helpers; + +namespace FinancialHub.Auth.Infra.Extensions +{ + public static class IServiceCollectionExtensions + { + public static IServiceCollection AddAuthProviders(this IServiceCollection services, IConfiguration configuration) + { + services.AddScoped(); + + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + + services.AddSingleton(provider => + new MapperConfiguration(cfg => + { + cfg.AddProfile(new FinancialHubAuthProviderProfile()); + using var scope = provider.CreateScope(); + cfg.AddProfile(new FinancialHubAuthCredentialProfile(scope.ServiceProvider.GetService()!)); + } + ).CreateMapper()); + + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj b/src/FinancialHub/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj new file mode 100644 index 0000000..0b99a09 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs b/src/FinancialHub/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs new file mode 100644 index 0000000..0db4253 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs @@ -0,0 +1,26 @@ +using System.Text; +using System.Security.Cryptography; +using FinancialHub.Auth.Domain.Interfaces.Helpers; + +namespace FinancialHub.Auth.Infra.Helpers +{ + public class PasswordHelper : IPasswordHelper + { + public string Encrypt(string value) + { + var dataArray = Encoding.UTF8.GetBytes(value); + + var bytes = SHA256.Create().ComputeHash(dataArray); + + return new string( + Convert.ToBase64String(bytes).Reverse().ToArray() + ); + } + + public bool Verify(string password, string encryptedPassword) + { + var encrypted = Encrypt(password); + return encrypted == password; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs b/src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs new file mode 100644 index 0000000..9844e44 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs @@ -0,0 +1,21 @@ +using FinancialHub.Auth.Domain.Interfaces.Helpers; + +namespace FinancialHub.Auth.Infra.Mappers +{ + public class FinancialHubAuthCredentialProfile : Profile + { + public FinancialHubAuthCredentialProfile(IPasswordHelper helper) : base() + { + this.CreateMap().ReverseMap(); + + this.CreateMap(); + this.CreateMap() + .ForMember(x => x.Login, y => y.MapFrom(z => z.Email)) + .ForMember(x => x.Password, y => y.MapFrom(z => helper.Encrypt(z.Password))); + + this.CreateMap() + .ForMember(x => x.Login, y => y.MapFrom(z => z.Email)) + .ForMember(x => x.Password, y => y.MapFrom(z => helper.Encrypt(z.Password))); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs b/src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs new file mode 100644 index 0000000..cbb28f4 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs @@ -0,0 +1,10 @@ +namespace FinancialHub.Auth.Infra.Mappers +{ + public class FinancialHubAuthProviderProfile : Profile + { + public FinancialHubAuthProviderProfile() : base() + { + this.CreateMap().ReverseMap(); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs b/src/FinancialHub/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs new file mode 100644 index 0000000..b48070f --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs @@ -0,0 +1,45 @@ +namespace FinancialHub.Auth.Infra.Providers +{ + public class CredentialProvider : ICredentialProvider + { + private readonly IMapper mapper; + private readonly ICredentialRepository credentialRepository; + + public CredentialProvider(ICredentialRepository credentialRepository, IMapper mapper) + { + this.credentialRepository = credentialRepository; + this.mapper = mapper; + } + + public async Task CreateAsync(CredentialModel signup) + { + var entity = this.mapper.Map(signup); + + var result = await this.credentialRepository.CreateAsync(entity); + + return this.mapper.Map(result); + } + + public async Task GetAsync(string email) + { + var result = await this.credentialRepository.GetAsync(email); + if (result == null) + { + return null; + } + + return this.mapper.Map(result); + } + + public async Task GetAsync(CredentialModel signup) + { + var result = await this.credentialRepository.GetAsync(signup.Login, signup.Password); + if (result == null) + { + return null; + } + + return this.mapper.Map(result); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Providers/SigninProvider.cs b/src/FinancialHub/FinancialHub.Auth.Infra/Providers/SigninProvider.cs new file mode 100644 index 0000000..8f26a42 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/Providers/SigninProvider.cs @@ -0,0 +1,29 @@ +namespace FinancialHub.Auth.Infra.Providers +{ + public class SigninProvider : ISigninProvider + { + private readonly IUserProvider userProvider; + private readonly ICredentialProvider credentialProvider; + private readonly IMapper mapper; + + public SigninProvider(ICredentialProvider credentialProvider, IUserProvider userProvider, IMapper mapper) + { + this.credentialProvider = credentialProvider; + this.userProvider = userProvider; + this.mapper = mapper; + } + + public async Task GetAccountAsync(SigninModel signin) + { + var credential = mapper.Map(signin); + var existingCredential = await credentialProvider.GetAsync(credential); + + if(existingCredential == null) + { + return null; + } + + return await userProvider.GetAsync(existingCredential.UserId); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Providers/SignupProvider.cs b/src/FinancialHub/FinancialHub.Auth.Infra/Providers/SignupProvider.cs new file mode 100644 index 0000000..82ebeb7 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/Providers/SignupProvider.cs @@ -0,0 +1,38 @@ +namespace FinancialHub.Auth.Infra.Providers +{ + public class SignupProvider : ISignupProvider + { + private readonly ICredentialProvider credentialProvider; + private readonly IUserProvider userProvider; + private readonly IMapper mapper; + + public SignupProvider( + ICredentialProvider credentialProvider, + IUserProvider userProvider, + IMapper mapper + ) + { + this.credentialProvider = credentialProvider; + this.userProvider = userProvider; + this.mapper = mapper; + } + + public async Task CreateAccountAsync(SignupModel signup) + { + var createdUser = await userProvider.CreateAsync( + mapper.Map(signup) + ); + if(createdUser == null) + return null; + + var userCredential = mapper.Map(signup); + userCredential.UserId = createdUser.Id.GetValueOrDefault(); + + var createdCredential = await credentialProvider.CreateAsync(userCredential); + if (createdCredential == null) + return null; + + return createdUser; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Providers/UserProvider.cs b/src/FinancialHub/FinancialHub.Auth.Infra/Providers/UserProvider.cs new file mode 100644 index 0000000..1793487 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/Providers/UserProvider.cs @@ -0,0 +1,43 @@ +namespace FinancialHub.Auth.Infra.Providers +{ + public class UserProvider : IUserProvider + { + private readonly IUserRepository repository; + private readonly IMapper mapper; + + public UserProvider(IUserRepository repository, IMapper mapper) + { + this.repository = repository; + this.mapper = mapper; + } + + public async Task CreateAsync(UserModel user) + { + var entity = this.mapper.Map(user); + + var createdEntity = await this.repository.CreateAsync(entity); + + return this.mapper.Map(createdEntity); + } + + public async Task GetAsync(Guid id) + { + var user = await this.repository.GetAsync(id); + if(user == null) + { + return null; + } + + return this.mapper.Map(user); + } + + public async Task UpdateAsync(UserModel user) + { + var entity = this.mapper.Map(user); + + var updatedEntity = await this.repository.UpdateAsync(entity); + + return this.mapper.Map(updatedEntity); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Infra/Usings.cs new file mode 100644 index 0000000..e7a288c --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Infra/Usings.cs @@ -0,0 +1,5 @@ +global using AutoMapper; +global using FinancialHub.Auth.Domain.Models; +global using FinancialHub.Auth.Domain.Entities; +global using FinancialHub.Auth.Domain.Interfaces.Providers; +global using FinancialHub.Auth.Domain.Interfaces.Repositories; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs new file mode 100644 index 0000000..8bb07ac --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs @@ -0,0 +1,30 @@ +namespace FinancialHub.Auth.IntegrationTests.Base +{ + [TestFixtureSource(typeof(FinancialHubAuthApiFixture))] + public abstract class BaseControllerTests + { + protected readonly FinancialHubAuthApiFixture fixture; + protected HttpClient Client => fixture.Client; + + protected readonly string baseEndpoint; + protected readonly Random random; + + protected BaseControllerTests(FinancialHubAuthApiFixture fixture, string endpoint) + { + this.fixture = fixture; + this.baseEndpoint = endpoint; + } + + [SetUp] + public virtual void SetUp() + { + this.fixture.CreateDatabase(); + } + + [TearDown] + public virtual void TearDown() + { + this.fixture.ClearData(); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs new file mode 100644 index 0000000..ba72b48 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs @@ -0,0 +1,162 @@ +using FinancialHub.Auth.Domain.Interfaces.Helpers; +using Microsoft.Extensions.DependencyInjection; +using System.IdentityModel.Tokens.Jwt; + +namespace FinancialHub.Auth.IntegrationTests.Controllers +{ + public class SigninControllerTests : BaseControllerTests + { + protected UserCredentialEntityBuilder credentialEntityBuilder; + protected UserEntityBuilder userEntityBuilder; + + protected SigninModelBuilder signinModelBuilder; + + public SigninControllerTests(FinancialHubAuthApiFixture fixture,string endpoint) + : base(fixture, "/signin" + endpoint) + { + } + + [SetUp] + public override void SetUp() + { + credentialEntityBuilder = new UserCredentialEntityBuilder(); + userEntityBuilder = new UserEntityBuilder(); + + signinModelBuilder = new SigninModelBuilder(); + + base.SetUp(); + } + public class Signin : SigninControllerTests + { + public Signin(FinancialHubAuthApiFixture fixture) : base(fixture, string.Empty){ } + + [Test] + public async Task Signin_ValidData_ReturnsValidToken() + { + var now = DateTime.UtcNow; + using var scope = this.fixture.Api.Services.CreateScope(); + + var id = Guid.NewGuid(); + var user = userEntityBuilder.WithId(id).Generate(); + fixture.AddData(user); + + var passwordHelper = scope.ServiceProvider.GetRequiredService(); + + var password = Guid.NewGuid().ToString(); + var encryptedPassword = passwordHelper.Encrypt(password); + var credential = credentialEntityBuilder + .WithUserId(id) + .WithLogin(user.Email) + .WithPassword(encryptedPassword) + .Generate(); + fixture.AddData(credential); + + var signin = signinModelBuilder + .WithEmail(user.Email) + .WithPassword(password) + .Generate(); + + var response = await Client.PostAsync(baseEndpoint, signin.ToHttpContent()); + + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var jsonResponse = await response.ReadContentAsync>(); + Assert.Multiple(() => + { + Assert.That(jsonResponse?.Data.ExpiresIn, Is.InRange(now.AddMinutes(55), now.AddMinutes(65))); + + var jwt = new JwtSecurityTokenHandler().ReadJwtToken(jsonResponse?.Data.Token); + Assert.That(jwt.Payload.Jti, Is.EqualTo(id.ToString())); + Assert.That(jwt.Payload.FirstOrDefault(x => x.Key == "email").Value , Is.EqualTo(user.Email)); + }); + } + + [Test] + public async Task Signin_ValidationError_ReturnsError() + { + var signin = signinModelBuilder + .WithEmail(string.Empty) + .WithPassword(string.Empty) + .Generate(); + + var response = await Client.PostAsync(baseEndpoint, signin.ToHttpContent()); + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + + var jsonResponse = await response.ReadContentAsync(); + Assert.Multiple(() => + { + Assert.That(jsonResponse, Is.Not.Null); + Assert.That(jsonResponse?.Errors.Count, Is.EqualTo(2)); + }); + } + + [Test] + public async Task Signin_NotExitingCredential_DoesNotReturnToken() + { + using(var scope = this.fixture.Api.Services.CreateScope()) + { + var id = Guid.NewGuid(); + var user = userEntityBuilder.WithId(id).Generate(); + fixture.AddData(user); + + var passwordHelper = scope.ServiceProvider.GetRequiredService(); + + var password = Guid.NewGuid().ToString(); + var encryptedPassword = passwordHelper.Encrypt(password); + var credential = credentialEntityBuilder + .WithUserId(id) + .WithLogin(user.Email) + .WithPassword(encryptedPassword) + .Generate(); + fixture.AddData(credential); + } + + var signin = signinModelBuilder.Generate(); + + var response = await Client.PostAsync(baseEndpoint, signin.ToHttpContent()); + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized)); + + var jsonResponse = await response.ReadContentAsync(); + Assert.Multiple(() => + { + Assert.That(jsonResponse, Is.Not.Null); + Assert.That(jsonResponse?.Message, Is.EqualTo("Wrong e-mail or password")); + }); + } + + [Test] + public async Task Signin_InvalidCredential_DoesNotReturnToken() + { + using var scope = this.fixture.Api.Services.CreateScope(); + var id = Guid.NewGuid(); + var user = userEntityBuilder.WithId(id).Generate(); + fixture.AddData(user); + + var passwordHelper = scope.ServiceProvider.GetRequiredService(); + + var password = Guid.NewGuid().ToString(); + var encryptedPassword = passwordHelper.Encrypt(password); + var credential = credentialEntityBuilder + .WithUserId(id) + .WithLogin(user.Email) + .WithPassword(encryptedPassword) + .Generate(); + fixture.AddData(credential); + + var signin = signinModelBuilder + .WithEmail(user.Email) + .Generate(); + + var response = await Client.PostAsync(baseEndpoint, signin.ToHttpContent()); + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized)); + + var jsonResponse = await response.ReadContentAsync(); + Assert.Multiple(() => + { + Assert.That(jsonResponse, Is.Not.Null); + Assert.That(jsonResponse?.Message, Is.EqualTo("Wrong e-mail or password")); + }); + } + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs new file mode 100644 index 0000000..f673cd8 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs @@ -0,0 +1,125 @@ +namespace FinancialHub.Auth.IntegrationTests.Controllers +{ + public class SignupControllerTests : BaseControllerTests + { + protected SignupModelBuilder signupModelBuilder; + + protected UserCredentialModelBuilder credentialModelBuilder; + protected UserCredentialEntityBuilder credentialEntityBuilder; + + protected UserModelBuilder userModelBuilder; + protected UserEntityBuilder userEntityBuilder; + + public SignupControllerTests(FinancialHubAuthApiFixture fixture, string endpoint) + : base(fixture, "/signup" + endpoint) { } + + [SetUp] + public override void SetUp() + { + signupModelBuilder = new SignupModelBuilder(); + + credentialModelBuilder = new UserCredentialModelBuilder(); + credentialEntityBuilder = new UserCredentialEntityBuilder(); + + userModelBuilder = new UserModelBuilder(); + userEntityBuilder = new UserEntityBuilder(); + + base.SetUp(); + } + + public class Signup : SignupControllerTests + { + public Signup(FinancialHubAuthApiFixture fixture) : base(fixture, string.Empty) { } + + [Test] + public async Task Signup_ValidData_ReturnsCreatedUser() + { + var signup = signupModelBuilder.Generate(); + var user = userModelBuilder + .WithName(signup.FirstName) + .WithLastName(signup.LastName) + .WithEmail(signup.Email) + .WithBirthDate(signup.BirthDate) + .Generate(); + + var response = await Client.PostAsync(baseEndpoint, signup.ToHttpContent()); + var jsonResponse = await response.ReadContentAsync>(); + + Assert.Multiple(() => + { + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + Assert.That(jsonResponse, Is.Not.Null); + user.Id = jsonResponse!.Data.Id; + ModelAssert.Equal(user, jsonResponse.Data); + }); + } + + [Test] + public async Task Signup_ValidData_AddsUser() + { + var signup = signupModelBuilder.Generate(); + var response = await Client.PostAsync(baseEndpoint, signup.ToHttpContent()); + var jsonResponse = await response.ReadContentAsync>(); + + Assert.Multiple(() => + { + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + Assert.That(jsonResponse, Is.Not.Null); + + var user = fixture.GetData().FirstOrDefault(x => x.Id == jsonResponse!.Data.Id); + Assert.That(user, Is.Not.Null); + }); + } + + [Test] + public async Task Signup_ValidationError_ReturnsError() + { + var signup = signupModelBuilder + .WithEmail(string.Empty) + .WithPassword(string.Empty) + .WithConfirmPassword("A") + .WithFirstName(string.Empty) + .WithLastName(string.Empty) + .Generate(); + + var response = await Client.PostAsync(baseEndpoint, signup.ToHttpContent()); + var jsonResponse = await response.ReadContentAsync(); + + Assert.Multiple(() => + { + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + Assert.That(jsonResponse, Is.Not.Null); + Assert.That(jsonResponse?.Errors.Count, Is.EqualTo(5)); + }); + } + + [Test] + public async Task Signup_ExistingCredential_ReturnsError() + { + var signup = signupModelBuilder.Generate(); + + var userEntity = userEntityBuilder + .WithEmail(signup.Email) + .Generate(); + fixture.AddData(userEntity); + + var credentialEntity = credentialEntityBuilder + .WithLogin(signup.Email) + .WithPassword(signup.Password) + .WithUserId(userEntity.Id) + .Generate(); + fixture.AddData(credentialEntity); + + var response = await Client.PostAsync(baseEndpoint, signup.ToHttpContent()); + var jsonResponse = await response.ReadContentAsync(); + + Assert.Multiple(() => + { + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + Assert.That(jsonResponse, Is.Not.Null); + Assert.That(jsonResponse!.Message, Is.EqualTo("Credential already exists")); + }); + } + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs new file mode 100644 index 0000000..d2a8871 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs @@ -0,0 +1,299 @@ +namespace FinancialHub.Auth.IntegrationTests.Controllers +{ + public class UsersControllerTests : BaseControllerTests + { + protected UserModelBuilder modelBuilder; + protected UserEntityBuilder entityBuilder; + + public UsersControllerTests(FinancialHubAuthApiFixture fixture, string? endpoint = null) : + base(fixture, "/users" + endpoint) + { + } + + [SetUp] + public override void SetUp() + { + modelBuilder = new UserModelBuilder(); + entityBuilder = new UserEntityBuilder(); + base.SetUp(); + } + + public class CreateUser : UsersControllerTests + { + public CreateUser(FinancialHubAuthApiFixture fixture) : + base(fixture) + { + } + + [Test] + public async Task CreateUser_InvalidToken_Returns401Unauthorized() + { + var data = modelBuilder.Generate(); + + var response = await Client.PostAsync(baseEndpoint, data, "token"); + + Assert.Multiple(() => + { + Assert.That(response.IsSuccessStatusCode, Is.False); + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized)); + }); + } + + [Test] + public async Task CreateUser_ValidUser_ReturnsCreatedUser() + { + var data = modelBuilder.Generate(); + var token = this.fixture.GetAuthToken(data); + + var response = await Client.PostAsync(baseEndpoint, data, token); + var jsonResponse = await response.ReadContentAsync>(); + + Assert.Multiple(() => + { + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + Assert.That(jsonResponse, Is.Not.Null); + data.Id = jsonResponse!.Data.Id; + ModelAssert.Equal(data, jsonResponse.Data); + }); + } + + [Test] + public async Task CreateUser_ValidUser_CreatesUser() + { + var data = modelBuilder.Generate(); + var token = this.fixture.GetAuthToken(data); + + var response = await Client.PostAsync(baseEndpoint, data, token); + var jsonResponse = await response.ReadContentAsync>(); + + var id = jsonResponse!.Data.Id; + var user = fixture.GetData().FirstOrDefault(x => x.Id == id); + Assert.That(user, Is.Not.Null); + } + + [Test] + public async Task CreateUser_InvalidUser_ReturnsValidationError() + { + var data = modelBuilder + .WithName(string.Empty) + .WithLastName(string.Empty) + .WithEmail(string.Empty) + .WithBirthDate(default) + .Generate(); + var token = this.fixture.GetAuthToken(data); + + var response = await Client.PostAsync(baseEndpoint, data, token); + var jsonResponse = await response.ReadContentAsync(); + + Assert.That(jsonResponse?.Errors.Count, Is.EqualTo(4)); + } + + [Test] + public async Task CreateUser_InvalidUser_DoestNotCreateUser() + { + var data = modelBuilder + .WithName(string.Empty) + .WithLastName(string.Empty) + .WithEmail(string.Empty) + .WithBirthDate(default) + .Generate(); + var token = this.fixture.GetAuthToken(data); + + await Client.PostAsync(baseEndpoint, data, token); + + var user = fixture.GetData().FirstOrDefault(); + Assert.That(user, Is.Null); + } + } + + public class GetUser : UsersControllerTests + { + public GetUser(FinancialHubAuthApiFixture fixture) : base(fixture) + { + } + + [Test] + public async Task CreateUser_InvalidToken_Returns401Unauthorized() + { + var response = await Client.GetAsync(baseEndpoint + $"/{Guid.NewGuid()}", "token"); + + Assert.Multiple(() => + { + Assert.That(response.IsSuccessStatusCode, Is.False); + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized)); + }); + } + + [Test] + public async Task GetUser_NotExistingUser_ReturnsNotFound() + { + var token = this.fixture.GetAuthToken(modelBuilder.Generate()); + + var id = Guid.NewGuid().ToString(); + var response = await Client.GetAsync(baseEndpoint + $"/{id}", token); + + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); + } + + [Test] + public async Task GetUser_ExistingUser_ReturnsUser() + { + var id = Guid.NewGuid(); + var entity = entityBuilder.WithId(id).Generate(); + fixture.AddData(entity); + + var token = this.fixture.GetAuthToken(modelBuilder.Generate()); + + var response = await Client.GetAsync(baseEndpoint + $"/{id}", token); + var jsonResponse = await response.ReadContentAsync>(); + + Assert.Multiple(() => + { + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + Assert.That(jsonResponse, Is.Not.Null); + Assert.That(jsonResponse!.Data.Id, Is.EqualTo(id)); + }); + } + } + + public class UpdateUser : UsersControllerTests + { + public UpdateUser(FinancialHubAuthApiFixture fixture) : base(fixture) + { + } + + [Test] + public async Task CreateUser_InvalidToken_Returns401Unauthorized() + { + var id = Guid.NewGuid(); + var entity = entityBuilder.WithId(id).Generate(); + fixture.AddData(entity); + + var data = modelBuilder.WithId(id).Generate(); + + var response = await Client.PatchAsync(baseEndpoint + $"/{id}", data, "token"); + + Assert.Multiple(() => + { + Assert.That(response.IsSuccessStatusCode, Is.False); + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized)); + }); + } + + [Test] + public async Task UpdateUser_ExistingUser_UpdatesUser() + { + var id = Guid.NewGuid(); + var entity = entityBuilder.WithId(id).Generate(); + fixture.AddData(entity); + + var data = modelBuilder.WithId(id).Generate(); + var token = this.fixture.GetAuthToken(data); + + await Client.PatchAsync(baseEndpoint + $"/{id}", data, token); + + var databaseUsers = fixture.GetData(); + var databaseUser = databaseUsers.FirstOrDefault(x => x.Id == id); + Assert.Multiple(() => + { + Assert.That(databaseUsers.Count(), Is.EqualTo(1)); + Assert.That(databaseUser, Is.Not.Null); + EntityAssert.Equal(databaseUser!, data); + }); + } + + [Test] + public async Task UpdateUser_ExistingUser_ReturnsUpdatedValues() + { + var id = Guid.NewGuid(); + var entity = entityBuilder.WithId(id).Generate(); + fixture.AddData(entity); + + var data = modelBuilder.WithId(id).Generate(); + var token = this.fixture.GetAuthToken(data); + + var response = await Client.PatchAsync(baseEndpoint + $"/{id}", data, token); + var jsonResponse = await response.ReadContentAsync>(); + + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + ModelAssert.Equal(data, jsonResponse!.Data); + } + + [Test] + public async Task UpdateUser_InvalidUser_ReturnsValidationError() + { + var id = Guid.NewGuid(); + var entity = entityBuilder.WithId(id).Generate(); + fixture.AddData(entity); + + var data = modelBuilder + .WithName(string.Empty) + .WithLastName(string.Empty) + .WithEmail(string.Empty) + .WithBirthDate(default) + .WithId(id) + .Generate(); + var token = this.fixture.GetAuthToken(data); + + var response = await Client.PatchAsync(baseEndpoint + $"/{id}", data, token); + var jsonResponse = await response.ReadContentAsync(); + + Assert.That(jsonResponse?.Errors.Count, Is.EqualTo(4)); + } + + [Test] + public async Task UpdateUser_InvalidUser_DoesNotUpdate() + { + var id = Guid.NewGuid(); + var data = modelBuilder + .WithName(string.Empty) + .WithLastName(string.Empty) + .WithEmail(string.Empty) + .WithBirthDate(default) + .WithId(id) + .Generate(); + var token = this.fixture.GetAuthToken(data); + + await Client.PatchAsync(baseEndpoint + $"/{id}", data, token); + + var databaseUsers = fixture.GetData(); + var databaseUser = databaseUsers.FirstOrDefault(x => x.Id == id); + Assert.Multiple(() => + { + Assert.That(databaseUsers.Count(), Is.EqualTo(0)); + Assert.That(databaseUser, Is.Null); + }); + } + + [Test] + public async Task UpdateUser_NotExistingUser_ReturnsNotFound() + { + var id = Guid.NewGuid(); + var data = modelBuilder.WithId(id).Generate(); + var token = this.fixture.GetAuthToken(data); + + var response = await Client.PatchAsync(baseEndpoint + $"/{id}", data, token); + + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); + } + + [Test] + public async Task UpdateUser_NotExistingUser_DoesNotUpdate() + { + var id = Guid.NewGuid(); + var data = modelBuilder.WithId(id).Generate(); + var token = this.fixture.GetAuthToken(data); + + await Client.PatchAsync(baseEndpoint + $"/{id}", data, token); + + var databaseUsers = fixture.GetData(); + var databaseUser = databaseUsers.FirstOrDefault(x => x.Id == id); + Assert.Multiple(() => + { + Assert.That(databaseUsers.Count(), Is.EqualTo(0)); + Assert.That(databaseUser, Is.Null); + }); + } + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs new file mode 100644 index 0000000..0b80553 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs @@ -0,0 +1,90 @@ +using FinancialHub.Auth.IntegrationTests.Extensions.Utils; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using System.Net.Http.Headers; + +namespace FinancialHub.Auth.IntegrationTests.Extensions +{ + public static class HttpClientExtensions + { + private static void AddHeaders(this HttpRequestHeaders headers, Dictionary headerData) + { + foreach (var header in headerData) + { + if (!headers.TryGetValues(header.Key, out _)) + { + headers.Add(header.Key, header.Value); + } + } + } + + private static async Task SendAsync(this HttpClient httpClient, HttpClientExtensionsParameters parameters) + { + var message = new HttpRequestMessage(parameters.Method, parameters.Url); + + message.Headers.AddHeaders(parameters.Headers); + + return await httpClient.SendAsync(message); + } + + private static async Task SendAsync(this HttpClient httpClient, HttpClientExtensionsParameters parameters) + { + var message = new HttpRequestMessage(parameters.Method, parameters.Url); + + if(parameters.Body != null) + { + message.Content = parameters.Body.ToHttpContent(); + } + + message.Headers.AddHeaders(parameters.Headers); + + return await httpClient.SendAsync(message); + } + + public static async Task GetAsync(this HttpClient httpClient, string url, string token) + { + var message = new HttpClientExtensionsParameters() + { + Url = url, + Method = HttpMethod.Get, + Headers = new Dictionary() + { + { "Authorization", $"Bearer {token}" } + } + }; + + return await httpClient.SendAsync(message); + } + + public static async Task PostAsync(this HttpClient httpClient, string url, T body, string token) + { + var message = new HttpClientExtensionsParameters() + { + Url = url, + Method = HttpMethod.Post, + Headers = new Dictionary() + { + { "Authorization", $"Bearer {token}" } + }, + Body = body, + }; + + return await httpClient.SendAsync(message); + } + + public static async Task PatchAsync(this HttpClient httpClient, string url, T body, string token) + { + var message = new HttpClientExtensionsParameters() + { + Url = url, + Method = HttpMethod.Patch, + Headers = new Dictionary() + { + { "Authorization", $"Bearer {token}" } + }, + Body = body, + }; + + return await httpClient.SendAsync(message); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs new file mode 100644 index 0000000..e2a524c --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs @@ -0,0 +1,18 @@ +using System.Net.Mime; +using System.Text; +using System.Text.Json; + +namespace FinancialHub.Auth.IntegrationTests.Extensions +{ + public static class HttpContentExtensions + { + public static HttpContent ToHttpContent(this T content) + { + return new StringContent( + content: JsonSerializer.Serialize(content), + encoding: Encoding.UTF8, + mediaType: MediaTypeNames.Application.Json + ); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs new file mode 100644 index 0000000..7ea9971 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs @@ -0,0 +1,27 @@ +using System.Text.Json; + +namespace FinancialHub.Auth.IntegrationTests.Extensions +{ + public static class HttpResponseMessageExtensions + { + public static async Task ReadContentAsync(this HttpResponseMessage response) + { + try + { + var stream = await response.Content.ReadAsStreamAsync(); + + return await JsonSerializer.DeserializeAsync(stream, + new JsonSerializerOptions() + { + PropertyNameCaseInsensitive = true + } + ); + } + catch (Exception e) + { + var json = await response.Content.ReadAsStringAsync(); + throw new Exception($"Not able to Read the content:\n{json}", e); + } + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs new file mode 100644 index 0000000..4b77737 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs @@ -0,0 +1,16 @@ +using System.Net.Http.Headers; + +namespace FinancialHub.Auth.IntegrationTests.Extensions.Utils +{ + public class HttpClientExtensionsParameters : HttpClientExtensionsParameters + { + public T Body { init; get; } + } + + public class HttpClientExtensionsParameters + { + public string Url { init; get; } + public HttpMethod Method { init; get; } + public Dictionary Headers { init; get; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj new file mode 100644 index 0000000..7fb5a09 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj @@ -0,0 +1,27 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs new file mode 100644 index 0000000..0f18afc --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs @@ -0,0 +1,15 @@ +using FinancialHub.Auth.Domain.Interfaces.Services; +using Microsoft.Extensions.DependencyInjection; + +namespace FinancialHub.Auth.IntegrationTests.Setup +{ + public partial class FinancialHubAuthApiFixture + { + public string GetAuthToken(UserModel userModel) + { + using var scope = this.Api.Server.Services.CreateScope(); + var tokenService = scope.ServiceProvider.GetRequiredService(); + return tokenService.GenerateToken(userModel).Token; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs new file mode 100644 index 0000000..c87e3fd --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs @@ -0,0 +1,38 @@ +using System.Collections; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc.Testing; +using FinancialHub.Auth.WebApi; + +namespace FinancialHub.Auth.IntegrationTests.Setup +{ + public partial class FinancialHubAuthApiFixture : IEnumerable, IDisposable + { + public HttpClient Client { get; protected set; } + public WebApplicationFactory Api { get; protected set; } + + public FinancialHubAuthApiFixture() + { + this.Api = new WebApplicationFactory() + .WithWebHostBuilder( + builder => + { + builder.UseEnvironment("Testing"); + } + ); + + this.Client = this.Api.CreateClient(); + } + + public void Dispose() + { + this.Api.Dispose(); + this.Client.Dispose(); + GC.SuppressFinalize(this); + } + + public IEnumerator GetEnumerator() + { + yield return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs new file mode 100644 index 0000000..5da8aaf --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs @@ -0,0 +1,45 @@ +using FinancialHub.Auth.Infra.Data.Contexts; +using FinancialHub.Domain.Entities; +using Microsoft.Extensions.DependencyInjection; + +namespace FinancialHub.Auth.IntegrationTests.Setup +{ + public partial class FinancialHubAuthApiFixture + { + public T[] AddData(params T[] data) + where T : BaseEntity + { + using var scope = this.Api.Server.Services.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + context.Set().AddRange(data); + context.SaveChanges(); + + context.ChangeTracker.Clear(); + + var res = context.Set().ToArray(); + return res.Where(x => data.Any(y => y.Id == x.Id)).ToArray(); + } + + public IEnumerable GetData() + where T : BaseEntity + { + using var scope = this.Api.Server.Services.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + return context.Set().ToArray(); + } + + public void CreateDatabase() + { + using var scope = this.Api.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); + } + + public void ClearData() + { + using var scope = this.Api.Server.Services.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + context.Database.EnsureDeleted(); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Usings.cs b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Usings.cs new file mode 100644 index 0000000..107b7c0 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Usings.cs @@ -0,0 +1,17 @@ +global using System.Net; + +global using NUnit.Framework; + +global using FinancialHub.Auth.IntegrationTests.Base; +global using FinancialHub.Auth.IntegrationTests.Setup; +global using FinancialHub.Auth.IntegrationTests.Extensions; + +global using FinancialHub.Domain.Responses.Errors; +global using FinancialHub.Domain.Responses.Success; + +global using FinancialHub.Auth.Domain.Entities; +global using FinancialHub.Auth.Domain.Models; + +global using FinancialHub.Auth.Tests.Common.Assertions; +global using FinancialHub.Auth.Tests.Common.Builders.Entities; +global using FinancialHub.Auth.Tests.Common.Builders.Models; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..2aeba1f --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,18 @@ +using FinancialHub.Auth.Domain.Interfaces.Resources; +using FinancialHub.Auth.Resources.Providers; +using Microsoft.Extensions.DependencyInjection; +using System.Globalization; + +namespace FinancialHub.Auth.Resources.Extensions +{ + public static class IServiceCollectionExtensions + { + public static IServiceCollection AddAuthResources(this IServiceCollection services) + { + services.AddSingleton( + new ErrorMessageProvider(CultureInfo.CurrentCulture) + ); + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj b/src/FinancialHub/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj new file mode 100644 index 0000000..6e5b45b --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj @@ -0,0 +1,35 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + True + True + ErrorMessages.resx + + + + + + ResXFileCodeGenerator + + + ResXFileCodeGenerator + ErrorMessages.Designer.cs + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs b/src/FinancialHub/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs new file mode 100644 index 0000000..c72a3d5 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs @@ -0,0 +1,22 @@ +using FinancialHub.Auth.Domain.Interfaces.Resources; +using FinancialHub.Auth.Resources.Resources.Errors; +using System.Globalization; + +namespace FinancialHub.Auth.Resources.Providers +{ + public class ErrorMessageProvider : IErrorMessageProvider + { + private readonly CultureInfo cultureInfo; + + public ErrorMessageProvider(CultureInfo cultureInfo) + { + this.cultureInfo = cultureInfo; + } + + public string? Required => ErrorMessages.ResourceManager.GetString("Required", this.cultureInfo); + public string? MinLength => ErrorMessages.ResourceManager.GetString("MinLength", this.cultureInfo); + public string? MaxLength => ErrorMessages.ResourceManager.GetString("MaxLength", this.cultureInfo); + public string? ConfirmPassword => ErrorMessages.ResourceManager.GetString("ConfirmPassword", this.cultureInfo); + public string? Invalid => ErrorMessages.ResourceManager.GetString("Invalid", this.cultureInfo); + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs b/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs new file mode 100644 index 0000000..ee3a74e --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs @@ -0,0 +1,108 @@ +//------------------------------------------------------------------------------ +// +// O código foi gerado por uma ferramenta. +// Versão de Tempo de Execução:4.0.30319.42000 +// +// As alterações ao arquivo poderão causar comportamento incorreto e serão perdidas se +// o código for gerado novamente. +// +//------------------------------------------------------------------------------ + +namespace FinancialHub.Auth.Resources.Resources.Errors { + using System; + + + /// + /// Uma classe de recurso de tipo de alta segurança, para pesquisar cadeias de caracteres localizadas etc. + /// + // Essa classe foi gerada automaticamente pela classe StronglyTypedResourceBuilder + // através de uma ferramenta como ResGen ou Visual Studio. + // Para adicionar ou remover um associado, edite o arquivo .ResX e execute ResGen novamente + // com a opção /str, ou recrie o projeto do VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class ErrorMessages { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ErrorMessages() { + } + + /// + /// Retorna a instância de ResourceManager armazenada em cache usada por essa classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.Auth.Resources.Resources.Errors.ErrorMessages", typeof(ErrorMessages).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Substitui a propriedade CurrentUICulture do thread atual para todas as + /// pesquisas de recursos que usam essa classe de recurso de tipo de alta segurança. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} needs to be equal to Password. + /// + internal static string ConfirmPassword { + get { + return ResourceManager.GetString("ConfirmPassword", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} is invalid. + /// + internal static string Invalid { + get { + return ResourceManager.GetString("Invalid", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} exceeds the max length of {MaxLength}. + /// + internal static string MaxLength { + get { + return ResourceManager.GetString("MaxLength", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} needs to have at least the lenght of {MinLength}. + /// + internal static string MinLength { + get { + return ResourceManager.GetString("MinLength", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} is required. + /// + internal static string Required { + get { + return ResourceManager.GetString("Required", resourceCulture); + } + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx b/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx new file mode 100644 index 0000000..e02b94a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + {PropertyName} precisa ser igual ao valor do campo Password + + + {PropertyName} é invalido + + + {PropertyName} excede o limite de {MaxLength} caracteres + + + {PropertyName} precisa ter o tamanho minimo de {MinLength} + + + {PropertyName} é obrigatório + + \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx b/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx new file mode 100644 index 0000000..5e62d10 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + {PropertyName} needs to be equal to Password + + + {PropertyName} is invalid + + + {PropertyName} exceeds the max length of {MaxLength} + + + {PropertyName} needs to have at least the lenght of {MinLength} + + + {PropertyName} is required + + \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/FinancialHub.Auth.Services.Tests.csproj b/src/FinancialHub/FinancialHub.Auth.Services.Tests/FinancialHub.Auth.Services.Tests.csproj new file mode 100644 index 0000000..6385f4a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/FinancialHub.Auth.Services.Tests.csproj @@ -0,0 +1,28 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.cs new file mode 100644 index 0000000..2587d96 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.cs @@ -0,0 +1,30 @@ +using FinancialHub.Auth.Domain.Interfaces.Providers; +using FinancialHub.Auth.Domain.Interfaces.Services; +using FinancialHub.Auth.Services.Services; + +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class SigninServiceTests + { + private ISigninService service; + private Mock mockTokenProvider; + private Mock mockSigninProvider; + + private UserModelBuilder userBuilder; + private SigninModelBuilder signinModelBuilder; + private TokenModelBuilder tokenModelBuilder; + + [SetUp] + public void SetUp() + { + this.userBuilder = new UserModelBuilder(); + this.signinModelBuilder = new SigninModelBuilder(); + this.tokenModelBuilder = new TokenModelBuilder(); + + this.mockTokenProvider = new Mock(); + this.mockSigninProvider = new Mock(); + + this.service = new SigninService(mockTokenProvider.Object, mockSigninProvider.Object); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.get.cs new file mode 100644 index 0000000..d5323c0 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.get.cs @@ -0,0 +1,70 @@ +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class SigninServiceTests + { + [Test] + public async Task AuthenticateAsync_ExistingUser_ReturnsToken() + { + var login = signinModelBuilder.Generate(); + var user = userBuilder + .WithEmail(login.Email) + .Generate(); + var tokenModel = tokenModelBuilder.Generate(); + + mockSigninProvider + .Setup(x => x.GetAccountAsync(login)) + .ReturnsAsync(user); + mockTokenProvider + .Setup(x => x.GenerateToken(user)) + .Returns(tokenModel); + + var tokenResult = await this.service.AuthenticateAsync(login); + + Assert.Multiple(() => + { + Assert.That(tokenResult.HasError, Is.False); + Assert.That(tokenResult.Data, Is.EqualTo(tokenModel)); + }); + } + + [Test] + public async Task AuthenticateAsync_CallsGetAccountAsync() + { + var login = signinModelBuilder.Generate(); + var user = userBuilder + .WithEmail(login.Email) + .Generate(); + var tokenModel = tokenModelBuilder.Generate(); + + mockSigninProvider + .Setup(x => x.GetAccountAsync(login)) + .ReturnsAsync(user) + .Verifiable(); + mockTokenProvider + .Setup(x => x.GenerateToken(user)) + .Returns(tokenModel) + .Verifiable(); + + await this.service.AuthenticateAsync(login); + + mockSigninProvider.Verify(x => x.GetAccountAsync(login), Times.Once); + } + + [Test] + public async Task AuthenticateAsync_NotExistingUser_ReturnsNull() + { + var login = signinModelBuilder.Generate(); + + mockSigninProvider + .Setup(x => x.GetAccountAsync(login)) + .ReturnsAsync(default(UserModel?)); + var tokenResult = await this.service.AuthenticateAsync(login); + + Assert.Multiple(() => + { + Assert.That(tokenResult.HasError, Is.True); + Assert.That(tokenResult.Error.Message, Is.EqualTo("Wrong e-mail or password")); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.create.cs new file mode 100644 index 0000000..466cbae --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.create.cs @@ -0,0 +1,78 @@ +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class SignupServiceTests + { + [Test] + public async Task CreateAccountAsync_ValidSignup_ReturnsCreatedUser() + { + var signup = signupBuilder.Generate(); + var user = userBuilder + .WithEmail(signup.Email) + .WithName(signup.FirstName) + .WithLastName(signup.LastName) + .WithBirthDate(signup.BirthDate) + .Generate(); + + this.mockCredentialProvider + .Setup(x => x.GetAsync(signup.Email)) + .ReturnsAsync((CredentialModel?)default); + this.mockSignupProvider + .Setup(x => x.CreateAccountAsync(signup)) + .ReturnsAsync(user); + + var result = await this.service.CreateAccountAsync(signup); + + Assert.That(result, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(result.HasError, Is.False); + Assert.That(result.Data, Is.EqualTo(user)); + }); + } + + [Test] + public async Task CreateAccountAsync_ExistingCredential_ReturnsErrror() + { + var signup = signupBuilder.Generate(); + var credential = userCredentialBuilder + .WithLogin(signup.Email) + .WithPassword(signup.Password) + .Generate(); + + this.mockCredentialProvider + .Setup(x => x.GetAsync(signup.Email)) + .ReturnsAsync(credential); + + var result = await this.service.CreateAccountAsync(signup); + + Assert.That(result, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(result.HasError, Is.True); + Assert.That(result.Error.Message, Is.EqualTo("Credential already exists")); + }); + } + + [Test] + public async Task CreateAccountAsync_FailedToCreateUser_ReturnsError() + { + var signup = signupBuilder.Generate(); + + this.mockCredentialProvider + .Setup(x => x.GetAsync(signup.Email)) + .ReturnsAsync((CredentialModel?)default); + this.mockSignupProvider + .Setup(x => x.CreateAccountAsync(signup)) + .ReturnsAsync((UserModel?)default); + + var result = await this.service.CreateAccountAsync(signup); + + Assert.That(result, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(result.HasError, Is.True); + Assert.That(result.Error.Message, Is.EqualTo("Failed to create user")); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.cs new file mode 100644 index 0000000..9cfdc34 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.cs @@ -0,0 +1,30 @@ +using FinancialHub.Auth.Domain.Interfaces.Providers; +using FinancialHub.Auth.Domain.Interfaces.Services; +using FinancialHub.Auth.Services.Services; + +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class SignupServiceTests + { + private ISignupService service; + private Mock mockCredentialProvider; + private Mock mockSignupProvider; + + private UserModelBuilder userBuilder; + private UserCredentialModelBuilder userCredentialBuilder; + private SignupModelBuilder signupBuilder; + + [SetUp] + public void SetUp() + { + this.userBuilder = new UserModelBuilder(); + this.signupBuilder = new SignupModelBuilder(); + this.userCredentialBuilder = new UserCredentialModelBuilder(); + + this.mockCredentialProvider = new Mock(); + this.mockSignupProvider = new Mock(); + + this.service = new SignupService(mockSignupProvider.Object, mockCredentialProvider.Object); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.cs new file mode 100644 index 0000000..dc2f24f --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.cs @@ -0,0 +1,34 @@ +using FinancialHub.Auth.Domain.Interfaces.Services; +using FinancialHub.Auth.Services.Configurations; +using FinancialHub.Auth.Services.Services; +using Microsoft.Extensions.Options; + +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class TokenServiceTests + { + private ITokenService service; + private UserModelBuilder userModelBuilder; + + [SetUp] + public void SetUp() + { + this.userModelBuilder = new UserModelBuilder(); + this.service = new TokenService(Options.Create(DefaultOption)); + } + + private static TokenServiceSettings DefaultOption + { + get + { + return new TokenServiceSettings() + { + Audience = "https://localhost:5000", + Issuer = "https://localhost:5000", + SecurityKey = "SecurityKeyVeryBigAndComplexNoOneWouldGuess", + Expires = 30 + }; + } + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.generate.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.generate.cs new file mode 100644 index 0000000..bc4a40e --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.generate.cs @@ -0,0 +1,77 @@ +using Microsoft.IdentityModel.Tokens; +using System.IdentityModel.Tokens.Jwt; +using System.Text; + +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class TokenServiceTests + { + [Test] + public void GenerateToken_ValidUser_ReturnsValidToken() + { + var userModel = userModelBuilder.Generate(); + + var tokenModel = service.GenerateToken(userModel); + + Assert.That(new JwtSecurityTokenHandler().CanReadToken(tokenModel.Token), Is.True); + } + + [Test] + public void GenerateToken_ValidUser_ReturnsTokenWithValidExpirationDate() + { + var expectedExpirationDate = DefaultOption.Expires; + var minimumExpected = DateTime.UtcNow.AddMinutes(expectedExpirationDate - 1); + var maximumExpected = DateTime.UtcNow.AddMinutes(expectedExpirationDate + 1); + var userModel = userModelBuilder.Generate(); + + var tokenModel = service.GenerateToken(userModel); + + var token = new JwtSecurityTokenHandler().ReadJwtToken(tokenModel.Token); + Assert.That(token.ValidTo, Is.InRange(minimumExpected, maximumExpected)); + } + + [Test] + public void GenerateToken_ValidUser_ReturnsTokenWithUserData() + { + var userModel = userModelBuilder.Generate(); + + var tokenModel = service.GenerateToken(userModel); + + var token = new JwtSecurityTokenHandler().ReadJwtToken(tokenModel.Token); + Assert.Multiple(() => + { + Assert.That(token.Payload.Jti, Is.EqualTo(userModel.Id.ToString())); + Assert.That(token.Payload["email"], Is.EqualTo(userModel.Email)); + Assert.That(token.Payload["name"], Is.EqualTo(userModel.FirstName)); + }); + } + + [Test] + public void GenerateToken_ValidUser_ReturnsTokenWithValidSignature() + { + var userModel = userModelBuilder.Generate(); + + var tokenModel = service.GenerateToken(userModel); + + var key = Encoding.ASCII.GetBytes(DefaultOption.SecurityKey); + var handler = new JwtSecurityTokenHandler(); + handler.ValidateToken( + tokenModel.Token, + new TokenValidationParameters() + { + IssuerSigningKey = new SymmetricSecurityKey(key), + ValidateIssuer = false, + ValidateAudience = false, + }, + out var token + ); + + Assert.Multiple(() => + { + var signinKey = (SymmetricSecurityKey)token.SigningKey; + Assert.That(signinKey.IsSupportedAlgorithm(SecurityAlgorithms.HmacSha256Signature)); + Assert.That(signinKey.Key, Is.EqualTo(key)); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs new file mode 100644 index 0000000..7ce6528 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs @@ -0,0 +1,36 @@ +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class UserServiceTests + { + [Test] + public async Task CreateAsync_ValidUser_ReturnsCreatedUser() + { + var user = this.builder.Generate(); + + mockProvider + .Setup(x => x.CreateAsync(user)) + .ReturnsAsync(user) + .Verifiable(); + var createdUserResult = await this.service.CreateAsync(user); + + Assert.That(createdUserResult.HasError, Is.False); + ModelAssert.Equal(user, createdUserResult.Data); + mockProvider.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); + } + + [Test] + public void CreateAsync_Exception_ThrowsException() + { + var user = this.builder.Generate(); + var exc = new Exception("Exception Message"); + + mockProvider + .Setup(x => x.CreateAsync(It.IsAny())) + .ThrowsAsync(exc) + .Verifiable(); + + Assert.ThrowsAsync(async () => await this.service.CreateAsync(user)); + mockProvider.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.cs new file mode 100644 index 0000000..a6a3105 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.cs @@ -0,0 +1,22 @@ +using FinancialHub.Auth.Domain.Interfaces.Providers; +using FinancialHub.Auth.Domain.Interfaces.Services; +using FinancialHub.Auth.Services.Services; + +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class UserServiceTests + { + private IUserService service; + private Mock mockProvider; + private UserModelBuilder builder; + + [SetUp] + public void SetUp() + { + this.builder = new UserModelBuilder(); + + this.mockProvider = new Mock(); + this.service = new UserService(this.mockProvider.Object); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.get.cs new file mode 100644 index 0000000..f0010f9 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.get.cs @@ -0,0 +1,42 @@ +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class UserServiceTests + { + [Test] + public async Task GetAsync_ExistingUser_ReturnsUser() + { + var id = Guid.NewGuid(); + var user = this.builder.Generate(); + + mockProvider + .Setup(x => x.GetAsync(id)) + .ReturnsAsync(user) + .Verifiable(); + + var userResult = await this.service.GetAsync(id); + + Assert.That(userResult.HasError, Is.False); + ModelAssert.Equal(user, userResult.Data); + } + + [Test] + public async Task GetAsync_NotExistingUser_ReturnsNotFoundUser() + { + var id = Guid.NewGuid(); + var user = this.builder.Generate(); + + mockProvider + .Setup(x => x.GetAsync(id)) + .ReturnsAsync(default(UserModel)) + .Verifiable(); + + var userResult = await this.service.GetAsync(id); + Assert.Multiple(() => + { + Assert.That(userResult.HasError, Is.True); + Assert.That(userResult.Error.Message, Is.EqualTo("User not found")); + }); + } + + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.update.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.update.cs new file mode 100644 index 0000000..c639cf1 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.update.cs @@ -0,0 +1,46 @@ +namespace FinancialHub.Auth.Services.Tests.Services +{ + public partial class UserServiceTests + { + [Test] + public async Task UpdateAsync_ExistingUser_ReturnsUpdatedUser() + { + var id = Guid.NewGuid(); + var user = this.builder + .WithId(id) + .Generate(); + + mockProvider + .Setup(x => x.GetAsync(id)) + .ReturnsAsync(user); + mockProvider + .Setup(x => x.UpdateAsync(user)) + .ReturnsAsync(user); + + var updatedUserResult = await this.service.UpdateAsync(id, user); + + Assert.That(updatedUserResult.HasError, Is.False); + ModelAssert.Equal(user, updatedUserResult.Data); + } + + [Test] + public async Task UpdateAsync_NonExistingUser_ReturnsNotFoundServiceError() + { + var id = Guid.NewGuid(); + var user = this.builder + .WithId(id) + .Generate(); + + mockProvider + .Setup(x => x.UpdateAsync(user)) + .ReturnsAsync(user); + + var updatedUserResult = await this.service.UpdateAsync(id, user); + Assert.Multiple(() => + { + Assert.That(updatedUserResult.HasError, Is.True); + Assert.That(updatedUserResult.Error.Message, Is.EqualTo("User not found")); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Usings.cs new file mode 100644 index 0000000..3701c6a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Usings.cs @@ -0,0 +1,8 @@ +global using NUnit.Framework; +global using Moq; + +global using FinancialHub.Auth.Domain.Models; + +global using FinancialHub.Auth.Tests.Common.Assertions; + +global using FinancialHub.Auth.Tests.Common.Builders.Models; diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SigninModelValidatorTests.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SigninModelValidatorTests.cs new file mode 100644 index 0000000..6fbf8b2 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SigninModelValidatorTests.cs @@ -0,0 +1,125 @@ +using FinancialHub.Auth.Domain.Interfaces.Resources; +using FinancialHub.Auth.Resources.Providers; +using FinancialHub.Auth.Services.Validators; +using System.Globalization; + +namespace FinancialHub.Auth.Services.Tests.Validators +{ + public class SigninModelValidatorTests + { + private IErrorMessageProvider errorMessageProvider; + private SigninModelValidator validator; + private SigninModelBuilder builder; + + [SetUp] + public void SetUp() + { + errorMessageProvider = new ErrorMessageProvider(CultureInfo.InvariantCulture); + validator = new SigninModelValidator(errorMessageProvider); + builder = new SigninModelBuilder(); + } + + [Test] + public void Validate_ValidSignupModel_ReturnsTrue() + { + var signup = builder.Generate(); + + var result = validator.Validate(signup); + + Assert.That(result.IsValid, Is.True); + } + + [Test] + public void Validate_EmailEmpty_ReturnsFalse() + { + var user = builder + .WithEmail(string.Empty) + .Generate(); + + var expectedMessage = "Email is required"; + + var result = validator.Validate(user); + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_InvalidEmail_ReturnsFalse() + { + var user = builder + .WithEmail(new string('a', 3)) + .Generate(); + + var expectedMessage = "Email is invalid"; + + var result = validator.Validate(user); + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + + [TestCase(1)] + [TestCase(2)] + [TestCase(4)] + [TestCase(7)] + public void Validate_PasswordLessThan_ReturnsFalse(int size) + { + var user = builder + .WithPassword(new string('a', size)) + .Generate(); + + var expectedMessage = "Password needs to have at least the lenght of 8"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_PasswordOverMaxLength_ReturnsFalse() + { + var user = builder + .WithPassword(new string('a', 301)) + .Generate(); + + var expectedMessage = "Password exceeds the max length of 80"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [TestCase(8)] + [TestCase(10)] + [TestCase(50)] + [TestCase(80)] + public void Validate_ValidPassword_ReturnsTrue(int size) + { + var user = builder + .WithPassword(new string('a', size)) + .Generate(); + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.True); + Assert.That(result.Errors, Is.Empty); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SignupModelValidatorTests.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SignupModelValidatorTests.cs new file mode 100644 index 0000000..cd106f6 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SignupModelValidatorTests.cs @@ -0,0 +1,232 @@ +using FinancialHub.Auth.Domain.Interfaces.Resources; +using FinancialHub.Auth.Resources.Providers; +using FinancialHub.Auth.Services.Validators; +using System.Globalization; + +namespace FinancialHub.Auth.Services.Tests.Validators +{ + public class SignupModelValidatorTests + { + private IErrorMessageProvider errorMessageProvider; + private SignupModelValidator validator; + private SignupModelBuilder builder; + + [SetUp] + public void SetUp() + { + errorMessageProvider = new ErrorMessageProvider(CultureInfo.InvariantCulture); + validator = new SignupModelValidator(errorMessageProvider); + builder = new SignupModelBuilder(); + } + + [Test] + public void Validate_ValidSignupModel_ReturnsTrue() + { + var signup = builder.Generate(); + + var result = validator.Validate(signup); + + Assert.That(result.IsValid, Is.True); + } + + [Test] + public void Validate_EmailEmpty_ReturnsFalse() + { + var user = builder + .WithEmail(string.Empty) + .Generate(); + + var expectedMessage = "Email is required"; + + var result = validator.Validate(user); + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_InvalidEmail_ReturnsFalse() + { + var user = builder + .WithEmail(new string('a', 3)) + .Generate(); + + var expectedMessage = "Email is invalid"; + + var result = validator.Validate(user); + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_EmailOverMaxLength_ReturnsFalse() + { + var user = builder + .WithEmail(new string('a', 301) + "@test.com") + .Generate(); + + var expectedMessage = "Email exceeds the max length of 300"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_FirstNameEmpty_ReturnsFalse() + { + var user = builder + .WithFirstName(string.Empty) + .Generate(); + + var expectedMessage = "First Name is required"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_FirstNameOverMaxLength_ReturnsFalse() + { + var user = builder + .WithFirstName(new string('a', 301)) + .Generate(); + + var expectedMessage = "First Name exceeds the max length of 300"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_LastNameEmpty_ReturnsFalse() + { + var user = builder + .WithLastName(string.Empty) + .Generate(); + + var expectedMessage = "Last Name is required"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_LastNameOverMaxLength_ReturnsFalse() + { + var user = builder + .WithLastName(new string('a', 301)) + .Generate(); + + var expectedMessage = "Last Name exceeds the max length of 300"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [TestCase(1)] + [TestCase(2)] + [TestCase(4)] + [TestCase(7)] + public void Validate_PasswordLessThan_ReturnsFalse(int size) + { + var user = builder + .WithValidPassword(new string('a', size)) + .Generate(); + + var expectedMessage = "Password needs to have at least the lenght of 8"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_PasswordOverMaxLength_ReturnsFalse() + { + var user = builder + .WithValidPassword(new string('a', 301)) + .Generate(); + + var expectedMessage = "Password exceeds the max length of 80"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [TestCase(8)] + [TestCase(10)] + [TestCase(50)] + [TestCase(80)] + public void Validate_ValidPassword_ReturnsTrue(int size) + { + var user = builder + .WithValidPassword(new string('a', size)) + .Generate(); + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.True); + Assert.That(result.Errors, Is.Empty); + }); + } + + [Test] + public void Validate_ConfirmPasswordNotEqual_ReturnsFalse() + { + var user = builder + .WithConfirmPassword(new string('a', 30)) + .Generate(); + + var expectedMessage = "Confirm Password needs to be equal to Password"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/UserValidatorTests.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/UserValidatorTests.cs new file mode 100644 index 0000000..609dc30 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/UserValidatorTests.cs @@ -0,0 +1,175 @@ +using FinancialHub.Auth.Domain.Interfaces.Resources; +using FinancialHub.Auth.Resources.Providers; +using FinancialHub.Auth.Services.Validators; +using System.Globalization; + +namespace FinancialHub.Auth.Services.Tests.Validators +{ + public class UserValidatorTests + { + private IErrorMessageProvider errorMessageProvider; + + private UserValidator validator; + private UserModelBuilder builder; + + [SetUp] + public void SetUp() + { + errorMessageProvider = new ErrorMessageProvider(CultureInfo.InvariantCulture); + validator = new UserValidator(errorMessageProvider); + builder = new UserModelBuilder(); + } + + [Test] + public void Validate_ValidUser_ReturnsTrue() + { + var user = builder.Generate(); + + var result = validator.Validate(user); + + Assert.That(result.IsValid, Is.True); + } + + [Test] + public void Validate_EmailEmpty_ReturnsFalse() + { + var user = builder + .WithEmail(string.Empty) + .Generate(); + + var expectedMessage = "Email is required"; + + var result = validator.Validate(user); + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_InvalidEmail_ReturnsFalse() + { + var user = builder + .WithEmail(new string('a', 3)) + .Generate(); + + var expectedMessage = "Email is invalid"; + + var result = validator.Validate(user); + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_EmailOverMaxLength_ReturnsFalse() + { + var user = builder + .WithEmail(new string('a', 301) + "@test.com") + .Generate(); + + var expectedMessage = "Email exceeds the max length of 300"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_FirstNameEmpty_ReturnsFalse() + { + var user = builder + .WithName(string.Empty) + .Generate(); + + var expectedMessage = "First Name is required"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_FirstNameOverMaxLength_ReturnsFalse() + { + var user = builder + .WithName(new string('a', 301)) + .Generate(); + + var expectedMessage = "First Name exceeds the max length of 300"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_LastNameEmpty_ReturnsFalse() + { + var user = builder + .WithLastName(string.Empty) + .Generate(); + + var expectedMessage = "Last Name is required"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_LastNameOverMaxLength_ReturnsFalse() + { + var user = builder + .WithLastName(new string('a', 301)) + .Generate(); + + var expectedMessage = "Last Name exceeds the max length of 300"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + + [Test] + public void Validate_BirthDateEmpty_ReturnsFalse() + { + var user = builder + .WithBirthDate(default) + .Generate(); + + var expectedMessage = "Birth Date is required"; + + var result = validator.Validate(user); + + Assert.Multiple(() => + { + Assert.That(result.IsValid, Is.False); + Assert.That(result.Errors[0].ErrorMessage, Is.EqualTo(expectedMessage)); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Configurations/TokenServiceSettings.cs b/src/FinancialHub/FinancialHub.Auth.Services/Configurations/TokenServiceSettings.cs new file mode 100644 index 0000000..80b9d5e --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Configurations/TokenServiceSettings.cs @@ -0,0 +1,10 @@ +namespace FinancialHub.Auth.Services.Configurations +{ + public class TokenServiceSettings + { + public string Audience { get; set ; } + public string Issuer { get; set ; } + public string SecurityKey { get; set; } + public int Expires { get; set; } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Auth.cs b/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Auth.cs new file mode 100644 index 0000000..1eaccb7 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Auth.cs @@ -0,0 +1,75 @@ +using FinancialHub.Auth.Services.Configurations; +using FinancialHub.Auth.Services.Services; +using FinancialHub.Auth.Services.Validators; +using FluentValidation; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; +using System.Text; + +namespace FinancialHub.Auth.Services.Extensions +{ + public static partial class IServiceCollectionExtensions + { + public static IServiceCollection AddAuthentication(this IServiceCollection services, IConfiguration configuration) + { + services.AddSettings(configuration); + + services.AddScoped(); + + services.AddScoped, SigninModelValidator>(); + services.AddScoped, SignupModelValidator>(); + + services.AddScoped(); + services.AddScoped(); + + services.AddAuthConfiguration(configuration); + + return services; + } + + private static IServiceCollection AddAuthConfiguration(this IServiceCollection services, IConfiguration configuration) + { + var settings = configuration.GetRequiredSection("TokenServiceSettings").Get(); + services + .AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + }) + .AddJwtBearer( + options => + { + var key = Encoding.ASCII.GetBytes(settings.SecurityKey); + + options.RequireHttpsMetadata = false; + options.SaveToken = true; + options.TokenValidationParameters = new() + { + //ValidAudience = settings.Audience, + ValidateAudience = false, + + //ValidAlgorithms = new[] { SecurityAlgorithms.HmacSha256Signature }, + IssuerSigningKey = new SymmetricSecurityKey(key), + ValidateIssuerSigningKey = true, + + //ValidIssuer = settings.Issuer, + ValidateIssuer = false, + + ValidateLifetime = true, + RequireExpirationTime = true, + ClockSkew = TimeSpan.FromMinutes(settings.Expires), + }; + } + ); + return services; + } + + private static IServiceCollection AddSettings(this IServiceCollection services, IConfiguration configuration) + { + services.Configure(configuration.GetSection("TokenServiceSettings")); + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Docs.cs b/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Docs.cs new file mode 100644 index 0000000..8d73c06 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Docs.cs @@ -0,0 +1,30 @@ +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; + +namespace FinancialHub.Auth.Services.Extensions +{ + public static partial class IServiceCollectionExtensions + { + public static IEnumerable GetAuthSecuritySchemes(this IServiceCollection _) + { + return new[] + { + new OpenApiSecurityScheme + { + BearerFormat = "JWT", + Name = "JWT Authentication", + In = ParameterLocation.Header, + Type = SecuritySchemeType.Http, + Scheme = JwtBearerDefaults.AuthenticationScheme, + + Reference = new OpenApiReference + { + Id = JwtBearerDefaults.AuthenticationScheme, + Type = ReferenceType.SecurityScheme + } + } + }; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..ebf0d7a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,45 @@ +using FinancialHub.Auth.Services.Services; +using FinancialHub.Auth.Services.Validators; +using FluentValidation; +using FluentValidation.AspNetCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System.Diagnostics.CodeAnalysis; + +namespace FinancialHub.Auth.Services.Extensions +{ + [ExcludeFromCodeCoverage] + public static partial class IServiceCollectionExtensions + { + public static IServiceCollection AddAuthServices(this IServiceCollection services, IConfiguration configuration) + { + services.AddAuthServices(); + + services.AddAuthentication(configuration); + + services.AddAuthValidators(); + + return services; + } + + private static IServiceCollection AddAuthServices(this IServiceCollection services) + { + services.AddScoped(); + + return services; + } + + private static IServiceCollection AddAuthValidators(this IServiceCollection services) + { + services.AddFluentValidation(x => + { + x.AutomaticValidationEnabled = true; + x.DisableDataAnnotationsValidation = true; + x.ValidatorOptions.DefaultRuleLevelCascadeMode = CascadeMode.Stop; + }); + services.AddScoped, UserValidator>(); + + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/FinancialHub.Auth.Services.csproj b/src/FinancialHub/FinancialHub.Auth.Services/FinancialHub.Auth.Services.csproj new file mode 100644 index 0000000..05fa4af --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/FinancialHub.Auth.Services.csproj @@ -0,0 +1,27 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Services/SigninService.cs b/src/FinancialHub/FinancialHub.Auth.Services/Services/SigninService.cs new file mode 100644 index 0000000..9e984b5 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Services/SigninService.cs @@ -0,0 +1,24 @@ +namespace FinancialHub.Auth.Services.Services +{ + public class SigninService : ISigninService + { + private readonly ITokenService tokenService; + private readonly ISigninProvider signinProvider; + + public SigninService(ITokenService tokenService, ISigninProvider signinProvider) + { + this.tokenService = tokenService; + this.signinProvider = signinProvider; + } + + public async Task> AuthenticateAsync(SigninModel login) + { + var user = await this.signinProvider.GetAccountAsync(login); + + if (user == null) + return new ServiceError(401, "Wrong e-mail or password"); + + return this.tokenService.GenerateToken(user); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Services/SignupService.cs b/src/FinancialHub/FinancialHub.Auth.Services/Services/SignupService.cs new file mode 100644 index 0000000..f45e3be --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Services/SignupService.cs @@ -0,0 +1,27 @@ +namespace FinancialHub.Auth.Services.Services +{ + public class SignupService : ISignupService + { + private readonly ISignupProvider signupProvider; + private readonly ICredentialProvider credentialProvider; + + public SignupService(ISignupProvider signupProvider, ICredentialProvider credentialProvider) + { + this.signupProvider = signupProvider; + this.credentialProvider = credentialProvider; + } + + public async Task> CreateAccountAsync(SignupModel signup) + { + var credential = await credentialProvider.GetAsync(signup.Email); + if(credential != null) + return new ServiceError(400, "Credential already exists"); + + var createdUser = await signupProvider.CreateAccountAsync(signup); + if(createdUser == null) + return new ServiceError(400, "Failed to create user"); + + return createdUser; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Services/TokenService.cs b/src/FinancialHub/FinancialHub.Auth.Services/Services/TokenService.cs new file mode 100644 index 0000000..4d8e159 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Services/TokenService.cs @@ -0,0 +1,57 @@ +using System.Text; +using System.Security.Claims; +using System.IdentityModel.Tokens.Jwt; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Tokens; +using FinancialHub.Auth.Services.Configurations; + +namespace FinancialHub.Auth.Services.Services +{ + public class TokenService : ITokenService + { + private readonly TokenServiceSettings settings; + public TokenService(IOptions settings) + { + this.settings = settings.Value; + } + + private SigningCredentials Credentials + { + get + { + var key = Encoding.ASCII.GetBytes(this.settings.SecurityKey); + var securityKey = new SymmetricSecurityKey(key); + return new SigningCredentials( + key: securityKey, + algorithm: SecurityAlgorithms.HmacSha256Signature + ); + } + } + + public TokenModel GenerateToken(UserModel user) + { + var expires = DateTime.UtcNow.AddMinutes(this.settings.Expires); + var handler = new JwtSecurityTokenHandler(); + var tokenDescriptor = new SecurityTokenDescriptor() + { + Expires = expires, + Issuer = this.settings.Issuer, + Audience = this.settings.Audience, + SigningCredentials = this.Credentials, + Subject = new ClaimsIdentity( + new[] + { + new Claim(ClaimTypes.Email, user.Email), + new Claim(JwtRegisteredClaimNames.Jti, user.Id.ToString()!), + new Claim(JwtRegisteredClaimNames.Name, user.FirstName) + } + ), + }; + + var securityToken = handler.CreateToken(tokenDescriptor); + var token = handler.WriteToken(securityToken); + + return new TokenModel(token, expires); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Services/UserService.cs b/src/FinancialHub/FinancialHub.Auth.Services/Services/UserService.cs new file mode 100644 index 0000000..61244fe --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Services/UserService.cs @@ -0,0 +1,43 @@ +namespace FinancialHub.Auth.Services.Services +{ + public class UserService : IUserService + { + private readonly IUserProvider provider; + + public UserService(IUserProvider provider) + { + this.provider = provider; + } + + public async Task> CreateAsync(UserModel user) + { + return await provider.CreateAsync(user); + } + + public async Task> GetAsync(Guid id) + { + var user = await provider.GetAsync(id); + + if(user == null) + { + return new ServiceError(404, "User not found"); + } + + return user; + } + + public async Task> UpdateAsync(Guid id,UserModel user) + { + var getByIdResult = await GetAsync(id); + if (getByIdResult.HasError) + { + return getByIdResult; + } + + user.Id = id; + var updatedUser = await provider.UpdateAsync(user); + + return updatedUser; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Services/Usings.cs new file mode 100644 index 0000000..47dc281 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Usings.cs @@ -0,0 +1,5 @@ +global using FinancialHub.Domain.Results; +global using FinancialHub.Domain.Results.Errors; +global using FinancialHub.Auth.Domain.Models; +global using FinancialHub.Auth.Domain.Interfaces.Services; +global using FinancialHub.Auth.Domain.Interfaces.Providers; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Validators/Rules/ValidatorRulesExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Services/Validators/Rules/ValidatorRulesExtensions.cs new file mode 100644 index 0000000..39e9069 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Validators/Rules/ValidatorRulesExtensions.cs @@ -0,0 +1,46 @@ +using FinancialHub.Auth.Domain.Interfaces.Resources; +using FluentValidation; + +namespace FinancialHub.Auth.Services.Validators.Rules +{ + public static class ValidatorRulesExtensions + { + public static IRuleBuilderOptions ValidEmail( + this IRuleBuilderInitial builder, IErrorMessageProvider provider + ) + { + return builder + .NotEmpty() + .WithMessage(provider.Required) + .EmailAddress() + .WithMessage(provider.Invalid) + .MaximumLength(300) + .WithMessage(provider.MaxLength); + } + + public static IRuleBuilderOptions ValidName( + this IRuleBuilderInitial builder, IErrorMessageProvider provider + ) + { + return builder + .NotEmpty() + .WithMessage(provider.Required) + .MaximumLength(300) + .WithMessage(provider.MaxLength); + } + + public static IRuleBuilderOptions ValidPassword( + this IRuleBuilderInitial builder, IErrorMessageProvider provider + ) + { + return builder + .NotNull() + .NotEmpty() + .WithMessage(provider.Required) + .MinimumLength(8) + .WithMessage(provider.MinLength) + .MaximumLength(80) + .WithMessage(provider.MaxLength); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Validators/SigninModelValidator.cs b/src/FinancialHub/FinancialHub.Auth.Services/Validators/SigninModelValidator.cs new file mode 100644 index 0000000..abf6edc --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Validators/SigninModelValidator.cs @@ -0,0 +1,18 @@ +using FinancialHub.Auth.Domain.Interfaces.Resources; +using FinancialHub.Auth.Services.Validators.Rules; +using FluentValidation; + +namespace FinancialHub.Auth.Services.Validators +{ + public class SigninModelValidator : AbstractValidator + { + public SigninModelValidator(IErrorMessageProvider provider) + { + RuleFor(x => x.Email) + .ValidEmail(provider); + + RuleFor(x => x.Password) + .ValidPassword(provider); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Validators/SignupModelValidator.cs b/src/FinancialHub/FinancialHub.Auth.Services/Validators/SignupModelValidator.cs new file mode 100644 index 0000000..7c8a0d0 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Validators/SignupModelValidator.cs @@ -0,0 +1,32 @@ +using FluentValidation; +using FinancialHub.Auth.Domain.Interfaces.Resources; +using FinancialHub.Auth.Services.Validators.Rules; + +namespace FinancialHub.Auth.Services.Validators +{ + public class SignupModelValidator : AbstractValidator + { + public SignupModelValidator(IErrorMessageProvider provider) + { + RuleFor(x => x.Email) + .ValidEmail(provider); + + RuleFor(x => x.FirstName) + .ValidName(provider); + + RuleFor(x => x.LastName) + .ValidName(provider); + + RuleFor(x => x.BirthDate) + .NotNull() + .WithMessage(provider.Required); + + RuleFor(x => x.Password) + .ValidPassword(provider); + + RuleFor(x => x.ConfirmPassword) + .Equal(x => x.Password) + .WithMessage(provider.ConfirmPassword); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Validators/UserValidator.cs b/src/FinancialHub/FinancialHub.Auth.Services/Validators/UserValidator.cs new file mode 100644 index 0000000..55c1f7d --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Services/Validators/UserValidator.cs @@ -0,0 +1,25 @@ +using FluentValidation; +using FinancialHub.Auth.Domain.Interfaces.Resources; +using FinancialHub.Auth.Services.Validators.Rules; + +namespace FinancialHub.Auth.Services.Validators +{ + public class UserValidator : AbstractValidator + { + public UserValidator(IErrorMessageProvider provider) + { + RuleFor(x => x.Email) + .ValidEmail(provider); + + RuleFor(x => x.FirstName) + .ValidName(provider); + + RuleFor(x => x.LastName) + .ValidName(provider); + + RuleFor(x => x.BirthDate) + .NotEmpty() + .WithMessage(provider.Required); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Entities/UserEntityBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Entities/UserEntityBuilder.cs new file mode 100644 index 0000000..8270af1 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Entities/UserEntityBuilder.cs @@ -0,0 +1,47 @@ +using Bogus; +using FinancialHub.Auth.Domain.Entities; + +namespace FinancialHub.Auth.Tests.Commom.Builders.Entities +{ + public class UserEntityBuilder : Faker + { + public UserEntityBuilder() + { + this.RuleFor(x => x.FirstName, x => x.Person.FirstName); + this.RuleFor(x => x.LastName, x => x.Person.LastName); + this.RuleFor(x => x.BirthDate, x => x.Person.DateOfBirth); + this.RuleFor(x => x.Email, x => x.Person.Email); + this.RuleFor(x => x.Password, x => x.Random.AlphaNumeric(12)); + } + + public UserEntityBuilder WithName(string name) + { + this.RuleFor(x => x.FirstName, name); + return this; + } + + public UserEntityBuilder WithLastName(string name) + { + this.RuleFor(x => x.LastName, name); + return this; + } + + public UserEntityBuilder WithBirthDate(DateTime date) + { + this.RuleFor(x => x.BirthDate, date); + return this; + } + + public UserEntityBuilder WithEmail(string email) + { + this.RuleFor(x => x.Email, email); + return this; + } + + public UserEntityBuilder WithPassword(string password) + { + this.RuleFor(x => x.Password, password); + return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Models/UserModelBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Models/UserModelBuilder.cs new file mode 100644 index 0000000..3ab4c5c --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Models/UserModelBuilder.cs @@ -0,0 +1,47 @@ +using Bogus; +using FinancialHub.Auth.Domain.Models; + +namespace FinancialHub.Auth.Tests.Commom.Builders.Entities +{ + public class UserModelBuilder : Faker + { + public UserModelBuilder() + { + this.RuleFor(x => x.FirstName, x => x.Person.FirstName); + this.RuleFor(x => x.LastName, x => x.Person.LastName); + this.RuleFor(x => x.BirthDate, x => x.Person.DateOfBirth); + this.RuleFor(x => x.Email, x => x.Person.Email); + this.RuleFor(x => x.Password, x => x.Random.AlphaNumeric(12)); + } + + public UserModelBuilder WithName(string name) + { + this.RuleFor(x => x.FirstName, name); + return this; + } + + public UserModelBuilder WithLastName(string name) + { + this.RuleFor(x => x.LastName, name); + return this; + } + + public UserModelBuilder WithBirthDate(DateTime date) + { + this.RuleFor(x => x.BirthDate, date); + return this; + } + + public UserModelBuilder WithEmail(string email) + { + this.RuleFor(x => x.Email, email); + return this; + } + + public UserModelBuilder WithPassword(string password) + { + this.RuleFor(x => x.Password, password); + return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Commom/FinancialHub.Auth.Tests.Commom.csproj b/src/FinancialHub/FinancialHub.Auth.Tests.Commom/FinancialHub.Auth.Tests.Commom.csproj new file mode 100644 index 0000000..1ffdcda --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Commom/FinancialHub.Auth.Tests.Commom.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs new file mode 100644 index 0000000..87d1493 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs @@ -0,0 +1,40 @@ +namespace FinancialHub.Auth.Tests.Common.Assertions +{ + public static class EntityAssert + { + public static void Equal(UserEntity expected, UserEntity result) + { + Assert.Multiple(() => + { + Assert.That(result.Id, Is.EqualTo(expected.Id)); + Assert.That(result.FirstName, Is.EqualTo(expected.FirstName)); + Assert.That(result.LastName, Is.EqualTo(expected.LastName)); + Assert.That(result.Email, Is.EqualTo(expected.Email)); + Assert.That(result.BirthDate, Is.EqualTo(expected.BirthDate)); + }); + } + + public static void Equal(UserEntity expected, UserModel result) + { + Assert.Multiple(() => + { + Assert.That(result.Id, Is.EqualTo(expected.Id)); + Assert.That(result.FirstName, Is.EqualTo(expected.FirstName)); + Assert.That(result.LastName, Is.EqualTo(expected.LastName)); + Assert.That(result.Email, Is.EqualTo(expected.Email)); + Assert.That(result.BirthDate, Is.EqualTo(expected.BirthDate)); + }); + } + + public static void Equal(CredentialEntity expected, CredentialEntity result) + { + Assert.Multiple(() => + { + Assert.That(result.Id, Is.EqualTo(expected.Id)); + Assert.That(result.Password, Is.EqualTo(expected.Password)); + Assert.That(result.Login, Is.EqualTo(expected.Login)); + Assert.That(result.UserId, Is.EqualTo(expected.UserId)); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs new file mode 100644 index 0000000..93e6ffa --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs @@ -0,0 +1,49 @@ +namespace FinancialHub.Auth.Tests.Common.Assertions +{ + public static class ModelAssert + { + public static void Equal(UserModel expected, UserModel actual) + { + Assert.Multiple(() => + { + Assert.That(actual.Id, Is.EqualTo(expected.Id)); + Assert.That(actual.FirstName, Is.EqualTo(expected.FirstName)); + Assert.That(actual.LastName, Is.EqualTo(expected.LastName)); + Assert.That(actual.Email, Is.EqualTo(expected.Email)); + Assert.That(actual.BirthDate, Is.EqualTo(expected.BirthDate)); + }); + } + + public static void Equal(UserEntity expected, UserModel actual) + { + Assert.Multiple(() => + { + Assert.That(actual.Id, Is.EqualTo(expected.Id)); + Assert.That(actual.FirstName, Is.EqualTo(expected.FirstName)); + Assert.That(actual.LastName, Is.EqualTo(expected.LastName)); + Assert.That(actual.Email, Is.EqualTo(expected.Email)); + Assert.That(actual.BirthDate, Is.EqualTo(expected.BirthDate)); + }); + } + + public static void Equal(CredentialModel expected, CredentialModel result) + { + Assert.Multiple(() => + { + Assert.That(result.Password, Is.EqualTo(expected.Password)); + Assert.That(result.Login, Is.EqualTo(expected.Login)); + Assert.That(result.UserId, Is.EqualTo(expected.UserId)); + }); + } + + public static void Equal(CredentialModel expected, CredentialEntity result) + { + Assert.Multiple(() => + { + Assert.That(result.Password, Is.EqualTo(expected.Password)); + Assert.That(result.Login, Is.EqualTo(expected.Login)); + Assert.That(result.UserId, Is.EqualTo(expected.UserId)); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs new file mode 100644 index 0000000..fb4f26f --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs @@ -0,0 +1,27 @@ +using FinancialHub.Domain.Responses.Errors; +using FinancialHub.Domain.Responses.Success; + +namespace FinancialHub.Auth.Tests.Common.Assertions +{ + public static class ResponseAssert + { + public static void IsValid(T expected, BaseResponse response) + { + Assert.That(expected, Is.EqualTo(response.Data)); + } + + public static void IsValid(BaseResponse expected, BaseResponse response) + { + Assert.That(response.Data, Is.EqualTo(expected.Data)); + } + + public static void HasError(BaseErrorResponse expected, BaseErrorResponse response) + { + Assert.Multiple(() => + { + Assert.That(response.Message, Is.EqualTo(expected.Message)); + Assert.That(response.Code, Is.EqualTo(expected.Code)); + }); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs new file mode 100644 index 0000000..df372a6 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs @@ -0,0 +1,42 @@ +namespace FinancialHub.Auth.Tests.Common.Builders.Entities +{ + public class UserCredentialEntityBuilder : BaseEntityBuilder + { + private readonly UserEntityBuilder userBuilder; + public UserCredentialEntityBuilder() + { + this.userBuilder = new UserEntityBuilder(); + + var user = userBuilder.Generate(); + RuleFor(x => x.Login, x => x.Person.Email); + RuleFor(x => x.Password, x => x.Hashids.Encode(x.Random.Digits(10))); + RuleFor(x => x.User, user); + RuleFor(x => x.UserId, user.Id); + } + + public UserCredentialEntityBuilder WithLogin(string? login) + { + RuleFor(x => x.Login, login); + return this; + } + + public UserCredentialEntityBuilder WithPassword(string? password) + { + RuleFor(x => x.Password, password); + return this; + } + + public UserCredentialEntityBuilder WithUserId(Guid? id) + { + RuleFor(x => x.UserId, id); + this.WithUser(default); + return this; + } + + public UserCredentialEntityBuilder WithUser(UserEntity? user) + { + RuleFor(x => x.User, user); + return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs new file mode 100644 index 0000000..d37d127 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs @@ -0,0 +1,37 @@ +namespace FinancialHub.Auth.Tests.Common.Builders.Entities +{ + public class UserEntityBuilder : BaseEntityBuilder + { + public UserEntityBuilder() + { + this.RuleFor(x => x.FirstName, x => x.Person.FirstName); + this.RuleFor(x => x.LastName, x => x.Person.LastName); + this.RuleFor(x => x.BirthDate, x => x.Person.DateOfBirth); + this.RuleFor(x => x.Email, x => x.Person.Email); + } + + public UserEntityBuilder WithName(string name) + { + this.RuleFor(x => x.FirstName, name); + return this; + } + + public UserEntityBuilder WithLastName(string name) + { + this.RuleFor(x => x.LastName, name); + return this; + } + + public UserEntityBuilder WithBirthDate(DateTime date) + { + this.RuleFor(x => x.BirthDate, date); + return this; + } + + public UserEntityBuilder WithEmail(string email) + { + this.RuleFor(x => x.Email, email); + return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs new file mode 100644 index 0000000..c6c9977 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs @@ -0,0 +1,23 @@ +namespace FinancialHub.Auth.Tests.Common.Builders.Models +{ + public class SigninModelBuilder : AutoFaker + { + public SigninModelBuilder() + { + RuleFor(x => x.Email, x => x.Person.Email); + RuleFor(x => x.Password, x=> x.Hashids.Encode(x.Random.Digits(10))); + } + + public SigninModelBuilder WithEmail(string email) + { + RuleFor(x => x.Email, email); + return this; + } + + public SigninModelBuilder WithPassword(string password) + { + RuleFor(x => x.Password, password); + return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs new file mode 100644 index 0000000..1e84360 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs @@ -0,0 +1,58 @@ +namespace FinancialHub.Auth.Tests.Common.Builders.Models +{ + public class SignupModelBuilder : AutoFaker + { + public SignupModelBuilder() + { + RuleFor(x => x.FirstName, x=> x.Person.FirstName); + RuleFor(x => x.LastName, x=> x.Person.LastName); + RuleFor(x => x.Email, x=> x.Person.Email); + RuleFor(x => x.Password, x=> x.Hashids.Encode(x.Random.Digits(10))); + RuleFor(x => x.ConfirmPassword, (x, sign)=> sign.Password); + RuleFor(x => x.BirthDate, x=> x.Person.DateOfBirth); + } + + public SignupModelBuilder WithFirstName(string firstName) + { + RuleFor(x => x.FirstName, firstName); + return this; + } + + public SignupModelBuilder WithLastName(string lastName) + { + RuleFor(x => x.LastName, lastName); + return this; + } + + public SignupModelBuilder WithEmail(string email) + { + RuleFor(x => x.Email, email); + return this; + } + + public SignupModelBuilder WithValidPassword(string password) + { + RuleFor(x => x.Password, password); + RuleFor(x => x.ConfirmPassword, password); + return this; + } + + public SignupModelBuilder WithPassword(string password) + { + RuleFor(x => x.Password, password); + return this; + } + + public SignupModelBuilder WithConfirmPassword(string password) + { + RuleFor(x => x.ConfirmPassword, password); + return this; + } + + public SignupModelBuilder WithBirthDate(DateTime birthDate) + { + RuleFor(x => x.BirthDate, birthDate); + return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs new file mode 100644 index 0000000..77cb39b --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs @@ -0,0 +1,11 @@ +namespace FinancialHub.Auth.Tests.Common.Builders.Models +{ + public class TokenModelBuilder : AutoFaker + { + public TokenModelBuilder() + { + RuleFor(x => x.ExpiresIn, x => x.Date.Soon()); + RuleFor(x => x.Token, x => x.Hashids.Encode(x.Random.Digits(10))); + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs new file mode 100644 index 0000000..fe52bcb --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs @@ -0,0 +1,29 @@ +namespace FinancialHub.Auth.Tests.Common.Builders.Models +{ + public class UserCredentialModelBuilder : AutoFaker + { + public UserCredentialModelBuilder() + { + RuleFor(x => x.Login, X => X.Person.Email); + RuleFor(x => x.Password, x => x.Hashids.Encode(x.Random.Digits(10))); + } + + public UserCredentialModelBuilder WithLogin(string? login) + { + RuleFor(x => x.Login, login); + return this; + } + + public UserCredentialModelBuilder WithPassword(string? password) + { + RuleFor(x => x.Password, password); + return this; + } + + public UserCredentialModelBuilder WithUserId(Guid? id) + { + RuleFor(x => x.UserId, id); + return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs new file mode 100644 index 0000000..8bc022b --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs @@ -0,0 +1,37 @@ +namespace FinancialHub.Auth.Tests.Common.Builders.Models +{ + public class UserModelBuilder : BaseModelBuilder + { + public UserModelBuilder() + { + this.RuleFor(x => x.FirstName, x => x.Person.FirstName); + this.RuleFor(x => x.LastName, x => x.Person.LastName); + this.RuleFor(x => x.BirthDate, x => x.Person.DateOfBirth); + this.RuleFor(x => x.Email, x => x.Person.Email); + } + + public UserModelBuilder WithName(string name) + { + this.RuleFor(x => x.FirstName, name); + return this; + } + + public UserModelBuilder WithLastName(string name) + { + this.RuleFor(x => x.LastName, name); + return this; + } + + public UserModelBuilder WithBirthDate(DateTime? date) + { + this.RuleFor(x => x.BirthDate, date); + return this; + } + + public UserModelBuilder WithEmail(string email) + { + this.RuleFor(x => x.Email, email); + return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj b/src/FinancialHub/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj new file mode 100644 index 0000000..f6ffc06 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Usings.cs new file mode 100644 index 0000000..53f3116 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Tests.Common/Usings.cs @@ -0,0 +1,9 @@ +global using NUnit.Framework; +global using AutoBogus; + + +global using FinancialHub.Auth.Domain.Entities; +global using FinancialHub.Domain.Tests.Builders.Entities; + +global using FinancialHub.Auth.Domain.Models; +global using FinancialHub.Domain.Tests.Builders.Models; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj b/src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj new file mode 100644 index 0000000..66fad12 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj @@ -0,0 +1,34 @@ + + + + net6.0 + enable + enable + aspnet-FinancialHub.Auth.WebApi-4a49b595-70f4-4997-b0b7-134dc53e490e + False + + + + 6 + + + + 6 + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs b/src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs new file mode 100644 index 0000000..c7a8265 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs @@ -0,0 +1,41 @@ +using FinancialHub.Auth.Application.Extensions; +using System.Diagnostics.CodeAnalysis; + +namespace FinancialHub.Auth.WebApi; + +[ExcludeFromCodeCoverage] +public partial class Program +{ + protected Program() + { + + } + + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add services to the container. + builder.Services.AddAuthApplication(builder.Configuration); + builder.Services.AddControllers(); + builder.Services.AddAuthDocs(); + + var app = builder.Build(); + + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + app.UseSwaggerUI(); + } + + app.UseHttpsRedirection(); + + app.UseAuthentication(); + app.UseAuthorization(); + + app.MapControllers(); + + app.Run(); + } +} \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/Properties/launchSettings.json b/src/FinancialHub/FinancialHub.Auth.WebApi/Properties/launchSettings.json new file mode 100644 index 0000000..a949367 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.WebApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:64755", + "sslPort": 44306 + } + }, + "profiles": { + "FinancialHub.Auth.WebApi": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7198;http://localhost:5072", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Development.json b/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Development.json new file mode 100644 index 0000000..8c49dfd --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Development.json @@ -0,0 +1,17 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "TokenServiceSettings": { + "Issuer": "https://localhost:7198", + "Audience": "https://localhost:7198", + "SecurityKey": "A_Big_And_Safe_Security-Key_Çç", + "Expires": 60 + }, + "ConnectionStrings": { + "auth": "Server=localhost,1450;Database=financial_hub;user=sa;pwd=P@ssw0rd!;" + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Testing.json b/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Testing.json new file mode 100644 index 0000000..a16aa05 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Testing.json @@ -0,0 +1,17 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "TokenServiceSettings": { + "Issuer": "https://localhost:7198", + "Audience": "https://localhost:7198", + "SecurityKey": "A_Big_And_Safe_Security-Key_Çç", + "Expires": 60 + }, + "ConnectionStrings": { + "auth": "Server=localhost,1450;Database=financial_hub_test;user=sa;pwd=P@ssw0rd!;" + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.json b/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.json new file mode 100644 index 0000000..6fe1d08 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.json @@ -0,0 +1,12 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "ConnectionStrings": { + "default": "" + }, + "AllowedHosts": "*" +} diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj b/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj index 7eeae5b..dd8a65f 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj +++ b/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj @@ -9,6 +9,9 @@ + + + diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationsErrorResponse.cs b/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationsErrorResponse.cs new file mode 100644 index 0000000..4e61533 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationsErrorResponse.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace FinancialHub.Domain.Responses.Errors +{ + public class ValidationsErrorResponse : BaseErrorResponse + { + public Dictionary Errors { get; set; } + + public ValidationsErrorResponse(string message, Dictionary errors = null) + : base(400, message) + { + this.Errors = errors; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Success/ItemResponse.cs b/src/FinancialHub/FinancialHub.Domain/Responses/Success/ItemResponse.cs new file mode 100644 index 0000000..263ec19 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Domain/Responses/Success/ItemResponse.cs @@ -0,0 +1,9 @@ +namespace FinancialHub.Domain.Responses.Success +{ + public class ItemResponse : BaseResponse + { + public ItemResponse(T data) : base(data) + { + } + } +} diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj index 07ee470..61b2a72 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj +++ b/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj @@ -7,10 +7,8 @@ - - @@ -21,7 +19,6 @@ - diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs b/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs index 7519d0f..859f5a9 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs +++ b/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs @@ -1,5 +1,4 @@ using FinancialHub.Domain.Entities; -using FinancialHub.Infra.Data.Mappings; using Microsoft.EntityFrameworkCore; using System.Diagnostics.CodeAnalysis; diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj b/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj index a1bcbd7..cb4c84f 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj +++ b/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj @@ -7,13 +7,8 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj b/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj index f7d331a..f3cac60 100644 --- a/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj +++ b/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj @@ -7,7 +7,6 @@ - diff --git a/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj index 8694c6d..3759289 100644 --- a/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -13,6 +13,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/FinancialHub/FinancialHub.sln b/src/FinancialHub/FinancialHub.sln index 5dc98ae..1fbb984 100644 --- a/src/FinancialHub/FinancialHub.sln +++ b/src/FinancialHub/FinancialHub.sln @@ -5,26 +5,18 @@ VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain", "FinancialHub.Domain\FinancialHub.Domain.csproj", "{776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{1F4F43B0-14F5-4C91-B98C-AEB8A5421258}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{2444FB9D-15D1-4193-BF04-83C4397369DA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{91A212DC-1D96-43DD-B1A0-153ACB6980D5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services", "FinancialHub.Services\FinancialHub.Services.csproj", "{7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services.NUnitTests", "FinancialHub.Services.NUnitTests\FinancialHub.Services.NUnitTests.csproj", "{DD50583D-8D5F-42B8-9225-3BCCCDC8B122}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data", "FinancialHub.Infra.Data\FinancialHub.Infra.Data.csproj", "{19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data.NUnitTests", "FinancialHub.Infra.Data.NUnitTests\FinancialHub.Infra.Data.NUnitTests.csproj", "{5A26CFA8-B077-4C91-BED9-C47339F960A2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi.NUnitTests", "FinancialHub.WebApi.NUnitTests\FinancialHub.WebApi.NUnitTests.csproj", "{40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain.Tests", "FinancialHub.Domain.Tests\FinancialHub.Domain.Tests.csproj", "{050E99E5-5F26-4157-A80A-0493D5E9DE55}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.IntegrationTests", "FinancialHub.IntegrationTests\FinancialHub.IntegrationTests.csproj", "{B6694C5F-1BCF-460D-B9EA-39A49849737A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Migrations", "FinancialHub.Infra.Migrations\FinancialHub.Infra.Migrations.csproj", "{7ED57B2C-520B-4A25-B3C1-268EEA48CADB}" @@ -33,6 +25,54 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{8AFE509C-0 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Migrations", "Migrations", "{EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Auth", "Auth", "{7CF52440-3820-40A7-B0B0-55E56F4FFF35}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{B918D713-0701-447C-B403-10DE0C769581}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{74BFDE19-E416-46A1-B9C2-878DA41B249A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{1488D2AC-39E7-414A-9B0A-344EBDA0E4E9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{93E5303C-66C1-4BF6-8823-6CBA9C3751BE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Domain", "FinancialHub.Auth.Domain\FinancialHub.Auth.Domain.csproj", "{82C01B54-91F9-4296-B2C7-F3FA230462F1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Services", "FinancialHub.Auth.Services\FinancialHub.Auth.Services.csproj", "{F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.WebApi", "FinancialHub.Auth.WebApi\FinancialHub.Auth.WebApi.csproj", "{23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Data.Tests", "FinancialHub.Auth.Infra.Data.Tests\FinancialHub.Auth.Infra.Data.Tests.csproj", "{3975688B-BF51-4DEB-8E19-777322865E83}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra", "FinancialHub.Auth.Infra\FinancialHub.Auth.Infra.csproj", "{F32C1BDA-B655-4E56-96A6-F8BD335707C6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Tests.Common", "FinancialHub.Auth.Tests.Common\FinancialHub.Auth.Tests.Common.csproj", "{5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Data", "FinancialHub.Auth.Infra.Data\FinancialHub.Auth.Infra.Data.csproj", "{72C9C13F-BF8B-4649-B504-99E634FCDDE5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Tests", "FinancialHub.Auth.Infra.Tests\FinancialHub.Auth.Infra.Tests.csproj", "{A4D904E8-5A38-4E00-8419-62CB1F24F94E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Services.Tests", "FinancialHub.Auth.Services.Tests\FinancialHub.Auth.Services.Tests.csproj", "{9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services.NUnitTests", "FinancialHub.Services.NUnitTests\FinancialHub.Services.NUnitTests.csproj", "{43423E19-2F4B-4A94-B8A7-4D2803D16A6E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{F6444C4B-6609-40E3-8D09-C52D871C5160}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain.Tests", "FinancialHub.Domain.Tests\FinancialHub.Domain.Tests.csproj", "{98A9979A-23A4-4DAA-917C-6F37794E0D06}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services", "FinancialHub.Services\FinancialHub.Services.csproj", "{2483A335-88C1-4413-9AB7-5AE0C67BBA23}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Resources", "FinancialHub.Auth.Resources\FinancialHub.Auth.Resources.csproj", "{8B091A42-5BE6-49A4-8086-C8761E0CE769}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{421DB63D-B9E6-4069-8B79-6C956506F3C5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application", "FinancialHub.Auth.Application\FinancialHub.Auth.Application.csproj", "{B3FAC69E-A3DD-4947-AD6A-89E683421D0A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application.Tests", "FinancialHub.Auth.Application.Tests\FinancialHub.Auth.Application.Tests.csproj", "{89795B5A-58F2-4614-9EE7-12468940114A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.Auth.IntegrationTests", "FinancialHub.Auth.IntegrationTests\FinancialHub.Auth.IntegrationTests.csproj", "{DD87106B-71B2-484D-A2CA-6ADD69C69CC7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,18 +83,6 @@ Global {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Release|Any CPU.Build.0 = Release|Any CPU - {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AF3B4DA6-DFE1-40D5-AD31-29FA59E14634}.Release|Any CPU.Build.0 = Release|Any CPU - {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E}.Release|Any CPU.Build.0 = Release|Any CPU - {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DD50583D-8D5F-42B8-9225-3BCCCDC8B122}.Release|Any CPU.Build.0 = Release|Any CPU {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -67,10 +95,6 @@ Global {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Debug|Any CPU.Build.0 = Debug|Any CPU {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Release|Any CPU.ActiveCfg = Release|Any CPU {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Release|Any CPU.Build.0 = Release|Any CPU - {050E99E5-5F26-4157-A80A-0493D5E9DE55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {050E99E5-5F26-4157-A80A-0493D5E9DE55}.Debug|Any CPU.Build.0 = Debug|Any CPU - {050E99E5-5F26-4157-A80A-0493D5E9DE55}.Release|Any CPU.ActiveCfg = Release|Any CPU - {050E99E5-5F26-4157-A80A-0493D5E9DE55}.Release|Any CPU.Build.0 = Release|Any CPU {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -79,20 +103,109 @@ Global {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Debug|Any CPU.Build.0 = Debug|Any CPU {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Release|Any CPU.ActiveCfg = Release|Any CPU {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Release|Any CPU.Build.0 = Release|Any CPU + {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Release|Any CPU.Build.0 = Release|Any CPU + {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}.Release|Any CPU.Build.0 = Release|Any CPU + {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Release|Any CPU.Build.0 = Release|Any CPU + {3975688B-BF51-4DEB-8E19-777322865E83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3975688B-BF51-4DEB-8E19-777322865E83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3975688B-BF51-4DEB-8E19-777322865E83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3975688B-BF51-4DEB-8E19-777322865E83}.Release|Any CPU.Build.0 = Release|Any CPU + {F32C1BDA-B655-4E56-96A6-F8BD335707C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F32C1BDA-B655-4E56-96A6-F8BD335707C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F32C1BDA-B655-4E56-96A6-F8BD335707C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F32C1BDA-B655-4E56-96A6-F8BD335707C6}.Release|Any CPU.Build.0 = Release|Any CPU + {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}.Release|Any CPU.Build.0 = Release|Any CPU + {72C9C13F-BF8B-4649-B504-99E634FCDDE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72C9C13F-BF8B-4649-B504-99E634FCDDE5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72C9C13F-BF8B-4649-B504-99E634FCDDE5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72C9C13F-BF8B-4649-B504-99E634FCDDE5}.Release|Any CPU.Build.0 = Release|Any CPU + {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.Build.0 = Release|Any CPU + {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}.Release|Any CPU.Build.0 = Release|Any CPU + {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Release|Any CPU.Build.0 = Release|Any CPU + {F6444C4B-6609-40E3-8D09-C52D871C5160}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6444C4B-6609-40E3-8D09-C52D871C5160}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6444C4B-6609-40E3-8D09-C52D871C5160}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6444C4B-6609-40E3-8D09-C52D871C5160}.Release|Any CPU.Build.0 = Release|Any CPU + {98A9979A-23A4-4DAA-917C-6F37794E0D06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {98A9979A-23A4-4DAA-917C-6F37794E0D06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {98A9979A-23A4-4DAA-917C-6F37794E0D06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {98A9979A-23A4-4DAA-917C-6F37794E0D06}.Release|Any CPU.Build.0 = Release|Any CPU + {2483A335-88C1-4413-9AB7-5AE0C67BBA23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2483A335-88C1-4413-9AB7-5AE0C67BBA23}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2483A335-88C1-4413-9AB7-5AE0C67BBA23}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2483A335-88C1-4413-9AB7-5AE0C67BBA23}.Release|Any CPU.Build.0 = Release|Any CPU + {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Release|Any CPU.Build.0 = Release|Any CPU + {B3FAC69E-A3DD-4947-AD6A-89E683421D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3FAC69E-A3DD-4947-AD6A-89E683421D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3FAC69E-A3DD-4947-AD6A-89E683421D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3FAC69E-A3DD-4947-AD6A-89E683421D0A}.Release|Any CPU.Build.0 = Release|Any CPU + {89795B5A-58F2-4614-9EE7-12468940114A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89795B5A-58F2-4614-9EE7-12468940114A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89795B5A-58F2-4614-9EE7-12468940114A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89795B5A-58F2-4614-9EE7-12468940114A}.Release|Any CPU.Build.0 = Release|Any CPU + {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} - {7B2ED2B8-E4F3-44A3-B9D6-B4C10C94E29E} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} - {DD50583D-8D5F-42B8-9225-3BCCCDC8B122} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} + {2444FB9D-15D1-4193-BF04-83C4397369DA} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} + {91A212DC-1D96-43DD-B1A0-153ACB6980D5} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} {5A26CFA8-B077-4C91-BED9-C47339F960A2} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} - {050E99E5-5F26-4157-A80A-0493D5E9DE55} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {7ED57B2C-520B-4A25-B3C1-268EEA48CADB} = {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} = {2444FB9D-15D1-4193-BF04-83C4397369DA} {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} = {2444FB9D-15D1-4193-BF04-83C4397369DA} + {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} + {B918D713-0701-447C-B403-10DE0C769581} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} + {74BFDE19-E416-46A1-B9C2-878DA41B249A} = {B918D713-0701-447C-B403-10DE0C769581} + {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} + {82C01B54-91F9-4296-B2C7-F3FA230462F1} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} + {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} + {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} + {3975688B-BF51-4DEB-8E19-777322865E83} = {74BFDE19-E416-46A1-B9C2-878DA41B249A} + {F32C1BDA-B655-4E56-96A6-F8BD335707C6} = {B918D713-0701-447C-B403-10DE0C769581} + {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} + {72C9C13F-BF8B-4649-B504-99E634FCDDE5} = {74BFDE19-E416-46A1-B9C2-878DA41B249A} + {A4D904E8-5A38-4E00-8419-62CB1F24F94E} = {B918D713-0701-447C-B403-10DE0C769581} + {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} + {43423E19-2F4B-4A94-B8A7-4D2803D16A6E} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {98A9979A-23A4-4DAA-917C-6F37794E0D06} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} + {2483A335-88C1-4413-9AB7-5AE0C67BBA23} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {8B091A42-5BE6-49A4-8086-C8761E0CE769} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} + {421DB63D-B9E6-4069-8B79-6C956506F3C5} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} + {B3FAC69E-A3DD-4947-AD6A-89E683421D0A} = {421DB63D-B9E6-4069-8B79-6C956506F3C5} + {89795B5A-58F2-4614-9EE7-12468940114A} = {421DB63D-B9E6-4069-8B79-6C956506F3C5} + {DD87106B-71B2-484D-A2CA-6ADD69C69CC7} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} From 2b2e11443b39c9973be2b52384d7208e403dfced Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jul 2023 19:55:25 -0300 Subject: [PATCH 14/30] Bump Swashbuckle.AspNetCore.SwaggerUI from 6.2.3 to 6.3.0 * Bump Swashbuckle.AspNetCore.SwaggerUI * Update SonarCloud analysis file --- .github/workflows/sonarcloud.yml | 6 ++---- .../FinancialHub.Auth.Application.csproj | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 9387f63..4507f8f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -21,12 +21,12 @@ permissions: jobs: code_analysis: name: Code Analysis - runs-on: windows-latest + runs-on: windows-latest defaults: run: working-directory: ./src/FinancialHub/ - + steps: - name: Set up JDK 11 uses: actions/setup-java@v1 @@ -52,7 +52,6 @@ jobs: - name: Install SonarCloud scanner if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' - shell: powershell run: | New-Item -Path .\.sonar\scanner -ItemType Directory dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner @@ -69,7 +68,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - shell: powershell run: | .\.sonar\scanner\dotnet-sonarscanner begin ` /k:"Chingling152_my-financial-hub" ` diff --git a/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj b/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj index 5d06204..07a5135 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj +++ b/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -10,7 +10,7 @@ - + From 877c6032439393804895499e9023883b749b6aac Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Thu, 27 Jul 2023 15:39:21 -0300 Subject: [PATCH 15/30] Release v0.4.1 * Adds tests_workflow.yml * Adds build-dotnet-project composite action * Archives api_workflow.yml and sonarcloud.yml * Adds api_releases.yml to generate versions (obsolete) * Changes Tests in two files (test_result.yml, coverage_report.yml) * Changes CI into two files (branch_main_ci.yml, branch_release_ci.yml) * Move sonarcloud analysis to ubuntu-latest * Fix sonarcloud analysis integrations tests SQL errors --- .../actions/build-dotnet-project/action.yml | 26 ++++ .github/workflows/api_releases.yml | 60 ++++++++++ .../{ => archived}/api_basic_flow.yml | 4 +- .../workflows/archived/api_clean_cache.yml | 34 ++++++ .github/workflows/archived/api_workflow.yml | 113 ++++++++++++++++++ .../workflows/{ => archived}/sonarcloud.yml | 0 .github/workflows/branch_main_ci.yml | 26 ++++ .github/workflows/branch_release_ci.yml | 20 ++++ .github/workflows/coverage_report.yml | 89 ++++++++++++++ .github/workflows/test_result.yml | 54 +++++++++ .github/workflows/tests_workflow.yml | 29 +++++ src/FinancialHub/.config/dotnet-tools.json | 6 + 12 files changed, 459 insertions(+), 2 deletions(-) create mode 100644 .github/actions/build-dotnet-project/action.yml create mode 100644 .github/workflows/api_releases.yml rename .github/workflows/{ => archived}/api_basic_flow.yml (94%) create mode 100644 .github/workflows/archived/api_clean_cache.yml create mode 100644 .github/workflows/archived/api_workflow.yml rename .github/workflows/{ => archived}/sonarcloud.yml (100%) create mode 100644 .github/workflows/branch_main_ci.yml create mode 100644 .github/workflows/branch_release_ci.yml create mode 100644 .github/workflows/coverage_report.yml create mode 100644 .github/workflows/test_result.yml create mode 100644 .github/workflows/tests_workflow.yml diff --git a/.github/actions/build-dotnet-project/action.yml b/.github/actions/build-dotnet-project/action.yml new file mode 100644 index 0000000..921b72c --- /dev/null +++ b/.github/actions/build-dotnet-project/action.yml @@ -0,0 +1,26 @@ +name: Build Dotnet Project +description: Hello! + +inputs: + project-dir: + description: 'Yay, project directory' + required: true + type: string + dotnet-version: + description: 'Yay, dotnet version' + required: false + type: string + default: 6.0.x + +runs: + using: "composite" + steps: + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: ${{ inputs.dotnet-version }} + + - name: Restore dependencies + run: dotnet restore ${{ inputs.project-dir }} + shell: bash + \ No newline at end of file diff --git a/.github/workflows/api_releases.yml b/.github/workflows/api_releases.yml new file mode 100644 index 0000000..6ad7ae9 --- /dev/null +++ b/.github/workflows/api_releases.yml @@ -0,0 +1,60 @@ +name: "API Release" + +on: + workflow_dispatch: + pull_request: + types: + - closed + branches: + - 'release/**' + +jobs: + releases: + name: Release + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Get version + run: echo "value=${BRANCH##*/}" >> $GITHUB_OUTPUT + env: + BRANCH: ${{ github.event.pull_request.base.ref }} + id: version + + - name: Create tag + uses: actions/github-script@v5 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/api/${{ steps.version.outputs.value }}', + sha: context.sha + }) + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: api/${{ steps.version.outputs.value }} + release_name: Release ${{ steps.version.outputs.value }} + body: Hello World + draft: true + prerelease: true + + # TODO: zip + #- name: Upload Release Asset + # id: upload-release-asset + # uses: actions/upload-release-asset@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # upload_url: ${{ steps.create_release.outputs.upload_url }} + # asset_path: ./my-artifact.zip + # asset_name: my-artifact.zip + # asset_content_type: application/zip \ No newline at end of file diff --git a/.github/workflows/api_basic_flow.yml b/.github/workflows/archived/api_basic_flow.yml similarity index 94% rename from .github/workflows/api_basic_flow.yml rename to .github/workflows/archived/api_basic_flow.yml index 4728cb8..d334223 100644 --- a/.github/workflows/api_basic_flow.yml +++ b/.github/workflows/archived/api_basic_flow.yml @@ -17,7 +17,7 @@ on: jobs: build: - name: Build + name: Build and Test runs-on: ubuntu-latest services: @@ -30,7 +30,7 @@ jobs: - 1450:1433 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Setup .NET uses: actions/setup-dotnet@v2 diff --git a/.github/workflows/archived/api_clean_cache.yml b/.github/workflows/archived/api_clean_cache.yml new file mode 100644 index 0000000..0fe5e22 --- /dev/null +++ b/.github/workflows/archived/api_clean_cache.yml @@ -0,0 +1,34 @@ +name: Cleanup caches by branch +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Install Github Action Cache Manager + run: gh extension install actions/gh-actions-cache + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get current merge + run: echo "value=refs/pull/${{ github.event.pull_request.number }}/merge" >> $GITHUB_OUTPUT + id: merge + + - name: Fetching list of cache key + run: | + cacheKeysForPR=$(gh actions-cache list -R ${{ github.repository }} -B ${{ steps.merge.outputs.value }} | cut -f 1 ) + set +e + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Deleting caches + run: | + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R ${{ github.repository }} -B ${{ steps.merge.outputs.value }} --confirm + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/archived/api_workflow.yml b/.github/workflows/archived/api_workflow.yml new file mode 100644 index 0000000..c5ba7bc --- /dev/null +++ b/.github/workflows/archived/api_workflow.yml @@ -0,0 +1,113 @@ +name: "API Basic Workflow" + +on: + push: + branches: + - 'main' + paths: + - 'src/FinancialHub/*' + - 'src/FinancialHub/**' + pull_request: + branches: + - 'main' + - 'release/**' + #paths: + # - 'src/FinancialHub/*' + # - 'src/FinancialHub/**' + + +env: + project-dir: ./src/FinancialHub/ + project-tests-dir: ./src/FinancialHub/ # for now it has no distiction + project-tests-results-dir: ./src/FinancialHub/TestResult # for now it has no distiction + +permissions: + checks: write + pull-requests: write + +jobs: + tests: + name: Build & Test + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ${{ env.project-dir }} + + services: + sql-database: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + SA_PASSWORD: "P@ssw0rd!" + ACCEPT_EULA: "Y" + ports: + - 1450:1433 + + steps: + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - uses: actions/checkout@v2 + + - name: Restore dependencies + run: dotnet restore + + - name: Run Tests + continue-on-error: true + run: dotnet test + --logger:"trx;logfilename=Results.xml" + --configuration release + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/composite@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + action_fail: true + files: "**/TestResults/Results.xml" + + - name: Restore Dotnet tests + run: dotnet tool restore + + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache SonarCloud scanner + id: cache-sonar-scanner + uses: actions/cache@v1 + with: + path: .\.sonar\scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + + - name: Begin Coverage Report + run: + dotnet tool run dotnet-sonarscanner begin + /k:"Chingling152_my-financial-hub" + /o:"chingling-152" + /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + /d:sonar.host.url="https://sonarcloud.io" + /d:sonar.coverage.exclusions="**/Migrations/." + /d:sonar.cs.opencover.reportsPaths="/TestResults/**/coverage.opencover.xml" + + - name: Build Project + run: dotnet build + --configuration Release + --no-restore + + - name: Run Coverage Report + continue-on-error: true + run: dotnet test + --collect:"XPlat Code Coverage;Format=opencover" + --results-directory TestResults/ + --configuration Release + + - name: Send Coverage Report + run: + dotnet tool run dotnet-sonarscanner end + /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/archived/sonarcloud.yml similarity index 100% rename from .github/workflows/sonarcloud.yml rename to .github/workflows/archived/sonarcloud.yml diff --git a/.github/workflows/branch_main_ci.yml b/.github/workflows/branch_main_ci.yml new file mode 100644 index 0000000..ee4ad20 --- /dev/null +++ b/.github/workflows/branch_main_ci.yml @@ -0,0 +1,26 @@ +name: "Main Tests & Analysis" + +on: + push: + branches: + - 'main' + paths: + - 'src/FinancialHub/*' + - 'src/FinancialHub/**' + pull_request: + branches: + - 'main' + paths: + - 'src/FinancialHub/*' + - 'src/FinancialHub/**' + +permissions: + checks: write + pull-requests: write + +jobs: + tests: + uses: ./.github/workflows/tests_workflow.yml + with: + dir: ./src/FinancialHub/ + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/branch_release_ci.yml b/.github/workflows/branch_release_ci.yml new file mode 100644 index 0000000..ed4c55d --- /dev/null +++ b/.github/workflows/branch_release_ci.yml @@ -0,0 +1,20 @@ +name: "Release Tests & Analysis" + +on: + pull_request: + branches: + - 'release/**' + paths: + - 'src/FinancialHub/*' + - 'src/FinancialHub/**' + +permissions: + checks: write + pull-requests: write + +jobs: + tests: + uses: ./.github/workflows/tests_workflow.yml + with: + dir: ./src/FinancialHub/ + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml new file mode 100644 index 0000000..bd79e4a --- /dev/null +++ b/.github/workflows/coverage_report.yml @@ -0,0 +1,89 @@ +name: Api Coverage + +on: + workflow_call: + inputs: + dir: + type: string + required: true + dotnet-version: + type: string + default: 6.0.x + +permissions: + pull-requests: read + +jobs: + code_analysis: + name: Code coverage + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ${{ inputs.dir }} + + services: + sql-database: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + SA_PASSWORD: "P@ssw0rd!" + ACCEPT_EULA: "Y" + ports: + - 1450:1433 + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Project + uses: ./.github/actions/build-dotnet-project + with: + project-dir: ${{ inputs.dir }} + dotnet-version: ${{ inputs.dotnet-version }} + + - name: Dotnet restore tools + run: dotnet tool restore + + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache SonarCloud scanner + id: cache-sonar-scanner + uses: actions/cache@v1 + with: + path: .\.sonar\scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + + - name: Begin Coverage Report + run: + dotnet tool run dotnet-sonarscanner begin + /k:"Chingling152_my-financial-hub" + /o:"chingling-152" + /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + /d:sonar.host.url="https://sonarcloud.io" + /d:sonar.coverage.exclusions="**/Migrations/." + /d:sonar.cs.opencover.reportsPaths="/TestResults/**/coverage.opencover.xml" + + - name: Build Project + run: dotnet build + --configuration Release + --no-restore + + - name: Run Coverage Report + continue-on-error: true + run: dotnet test + --collect:"XPlat Code Coverage;Format=opencover" + --results-directory TestResults/ + --configuration Release + + - name: Send Coverage Report + run: + dotnet tool run dotnet-sonarscanner end + /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + \ No newline at end of file diff --git a/.github/workflows/test_result.yml b/.github/workflows/test_result.yml new file mode 100644 index 0000000..3e6038e --- /dev/null +++ b/.github/workflows/test_result.yml @@ -0,0 +1,54 @@ +name: Api Test Result +on: + workflow_call: + inputs: + dir: + type: string + required: true + dotnet-version: + type: string + default: 6.0.x + +permissions: + checks: write + pull-requests: write + +jobs: + test_results: + name: Code Tests + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ${{ inputs.dir }} + + services: + sql-database: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + SA_PASSWORD: "P@ssw0rd!" + ACCEPT_EULA: "Y" + ports: + - 1450:1433 + + steps: + - uses: actions/checkout@v2 + + - name: Setup Project + uses: ./.github/actions/build-dotnet-project + with: + project-dir: ${{ inputs.dir }} + dotnet-version: ${{ inputs.dotnet-version }} + + - name: Run Tests + continue-on-error: true + run: dotnet test + --logger:"trx;logfilename=Results.xml" + --configuration release + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/composite@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + action_fail: true + files: "**/TestResults/Results.xml" \ No newline at end of file diff --git a/.github/workflows/tests_workflow.yml b/.github/workflows/tests_workflow.yml new file mode 100644 index 0000000..baf1d79 --- /dev/null +++ b/.github/workflows/tests_workflow.yml @@ -0,0 +1,29 @@ +name: Api Tests CI + +on: + workflow_call: + inputs: + dir: + type: string + description: "..." + required: true + dotnet-version: + type: string + description: "..." + default: 6.0.x + +jobs: + test-result: + uses: ./.github/workflows/test_result.yml + secrets: inherit + with: + dir: ${{ inputs.dir }} + dotnet-version: ${{ inputs.dotnet-version }} + + coverage-report: + needs: test-result + uses: ./.github/workflows/coverage_report.yml + secrets: inherit + with: + dir: ${{ inputs.dir }} + dotnet-version: ${{ inputs.dotnet-version }} diff --git a/src/FinancialHub/.config/dotnet-tools.json b/src/FinancialHub/.config/dotnet-tools.json index 0d1da73..ea50492 100644 --- a/src/FinancialHub/.config/dotnet-tools.json +++ b/src/FinancialHub/.config/dotnet-tools.json @@ -7,6 +7,12 @@ "commands": [ "dotnet-ef" ] + }, + "dotnet-sonarscanner": { + "version": "5.13.0", + "commands": [ + "dotnet-sonarscanner" + ] } } } \ No newline at end of file From 0a7a6ce688c0cf6e11a355b0e1882c0cf6d98ed9 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Thu, 27 Jul 2023 16:28:39 -0300 Subject: [PATCH 16/30] Release v0.4.1-1 * fix main branch analysis --- .github/workflows/coverage_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index bd79e4a..5e6a056 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -68,7 +68,7 @@ jobs: /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverage.exclusions="**/Migrations/." - /d:sonar.cs.opencover.reportsPaths="/TestResults/**/coverage.opencover.xml" + /d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml" - name: Build Project run: dotnet build From f02e9d720e01d0b59986791e6ffe8b97e4ce3c98 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Fri, 28 Jul 2023 11:22:55 -0300 Subject: [PATCH 17/30] Release v0.4.2 * Removes Exception test from UserServiceTests.create * Removes exception unit tests of Provider layers * Remove Infra.Data exceptions unit tests * Removes UserRepository update --- .../CredentialRepositoryTests.create.cs | 10 ---------- .../Users/UserRepositoryTests.update.cs | 18 ------------------ .../CredentialProviderTests.create.cs | 13 ------------- .../Users/UserProviderTests.create.cs | 13 ------------- .../Users/UserProviderTests.update.cs | 13 ------------- .../Services/Users/UserServiceTests.create.cs | 15 --------------- 6 files changed, 82 deletions(-) diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs index 0ebccd1..6f02071 100644 --- a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs @@ -36,15 +36,5 @@ public async Task CreateAsync_CredentialWithExistingId_InsertsIntoDatabaseWithDi DbContextAssert.AssertCreated(this.fixture.Context, credential); } - - [Test] - public void CreateAsync_UserNotCreated_ShouldThrowDbUpdateException() - { - var credential = this.builder.Generate(); - - Assert.ThrowsAsync( - async () => await this.repository.CreateAsync(credential) - ); - } } } diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs index 17490aa..b132199 100644 --- a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs @@ -24,23 +24,5 @@ public async Task UpdateAsync_ExistingUser_UpdatesUser() var data = fixture.Context.Users.FirstOrDefault(x => x.Id == oldUser.Id.GetValueOrDefault()); EntityAssert.Equal(newUser, data!); } - - [Test] - public void UpdateAsync_NotExistingUser_DoesNotUpdatesUser() - { - var newUser = builder.Generate(); - - Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(newUser)); - - var databaseUser = fixture.Context.Users.FirstOrDefault(u => u.Id == newUser.Id); - Assert.That(databaseUser, Is.Null); - } - - [Test] - public void UpdateAsync_NotExistingUser_ThrowsDbUpdateConcurrencyException() - { - var newUser = builder.Generate(); - Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(newUser)); - } } } diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs index 18e0c3f..cb7c6ea 100644 --- a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs @@ -17,18 +17,5 @@ public async Task CreateAsync_ValidUser_ReturnsCreatedUser() Assert.That(createdUser, Is.Not.Null); ModelAssert.Equal(credential, createdUser); } - - [Test] - public void CreateAsync_RepositoryException_ThrowsException() - { - var credential = this.builder.Generate(); - var exc = new Exception("Exception Message"); - - mockRepository - .Setup(x => x.CreateAsync(It.IsAny())) - .ThrowsAsync(exc); - - Assert.ThrowsAsync(async () => await this.provider.CreateAsync(credential)); - } } } diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs index b537199..a3f343f 100644 --- a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs @@ -17,18 +17,5 @@ public async Task CreateAsync_ValidUser_ReturnsCreatedUser() Assert.That(createdUser, Is.Not.Null); ModelAssert.Equal(user, createdUser); } - - [Test] - public void CreateAsync_RepositoryException_ThrowsException() - { - var user = this.builder.Generate(); - var exc = new Exception("Exception Message"); - - mockRepository - .Setup(x => x.CreateAsync(It.IsAny())) - .ThrowsAsync(exc); - - Assert.ThrowsAsync(async () => await this.provider.CreateAsync(user)); - } } } diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs index 7ad26ad..bb8fc2f 100644 --- a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs +++ b/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs @@ -16,18 +16,5 @@ public async Task UpdateAsync_ValidUser_ReturnsUpdatedUser() ModelAssert.Equal(user, updatedUser); } - - [Test] - public void UpdateAsync_RepositoryException_ThrowsException() - { - var user = this.builder.Generate(); - var exc = new Exception("Exception Message"); - - mockRepository - .Setup(x => x.UpdateAsync(It.IsAny())) - .ThrowsAsync(exc); - - Assert.ThrowsAsync(async () => await this.provider.UpdateAsync(user)); - } } } diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs index 7ce6528..80392e8 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs +++ b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs @@ -17,20 +17,5 @@ public async Task CreateAsync_ValidUser_ReturnsCreatedUser() ModelAssert.Equal(user, createdUserResult.Data); mockProvider.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); } - - [Test] - public void CreateAsync_Exception_ThrowsException() - { - var user = this.builder.Generate(); - var exc = new Exception("Exception Message"); - - mockProvider - .Setup(x => x.CreateAsync(It.IsAny())) - .ThrowsAsync(exc) - .Verifiable(); - - Assert.ThrowsAsync(async () => await this.service.CreateAsync(user)); - mockProvider.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); - } } } From 48a076b696298e07b16ad33e40e9ffc29168c61c Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Fri, 28 Jul 2023 14:33:52 -0300 Subject: [PATCH 18/30] Release v0.4.3 * Changes Auth Application Project layer to Presentation * Changes Services layer name to Application layer --- ...FinancialHub.Auth.Application.Tests.csproj | 3 + .../Services/Signin/SigninServiceTests.cs | 4 +- .../Services/Signin/SigninServiceTests.get.cs | 2 +- .../Signup/SignupServiceTests.create.cs | 2 +- .../Services/Signup/SignupServiceTests.cs | 4 +- .../Services/Token/TokenServiceTests.cs | 6 +- .../Token/TokenServiceTests.generate.cs | 2 +- .../Services/Users/UserServiceTests.create.cs | 2 +- .../Services/Users/UserServiceTests.cs | 4 +- .../Services/Users/UserServiceTests.get.cs | 2 +- .../Services/Users/UserServiceTests.update.cs | 2 +- .../Usings.cs | 17 +----- .../Validators/SigninModelValidatorTests.cs | 4 +- .../Validators/SignupModelValidatorTests.cs | 4 +- .../Validators/UserValidatorTests.cs | 4 +- .../Configurations/TokenServiceSettings.cs | 2 +- .../IServiceCollectionExtensions.Auth.cs | 8 +-- .../IServiceCollectionExtensions.Docs.cs | 2 +- .../IServiceCollectionExtensions.cs | 46 +++++++++++---- .../FinancialHub.Auth.Application.csproj | 21 ++++--- .../Services/SigninService.cs | 2 +- .../Services/SignupService.cs | 2 +- .../Services/TokenService.cs | 4 +- .../Services/UserService.cs | 2 +- .../FinancialHub.Auth.Application/Usings.cs | 10 ++-- .../Rules/ValidatorRulesExtensions.cs | 2 +- .../Validators/SigninModelValidator.cs | 4 +- .../Validators/SignupModelValidator.cs | 4 +- .../Validators/UserValidator.cs | 4 +- .../Asserts/ControllerResponseAssert.cs | 2 +- .../Signin/SigninControllerTests.cs | 2 +- .../Signin/SigninControllerTests.get.cs | 4 +- .../Signup/SignupControllerTests.create.cs | 4 +- .../Signup/SignupControllerTests.cs | 2 +- .../Users/UsersControllerTests.create.cs | 2 +- .../Controllers/Users/UsersControllerTests.cs | 2 +- .../Users/UsersControllerTests.get.cs | 2 +- .../Users/UsersControllerTests.update.cs | 2 +- ...nancialHub.Auth.Presentation.Tests.csproj} | 5 +- .../Usings.cs | 19 ++++++ .../.editorconfig | 0 .../Controllers/SigninController.cs | 2 +- .../Controllers/SignupController.cs | 2 +- .../Controllers/UsersController.cs | 2 +- .../IServiceCollectionExtensions.cs | 23 ++++++++ .../Extensions/SwaggerExtensions.cs | 4 +- .../FinancialHub.Auth.Presentation.csproj | 24 ++++++++ .../FinancialHub.Auth.Presentation/Usings.cs | 8 +++ .../Usings.cs | 8 --- .../IServiceCollectionExtensions.cs | 45 -------------- .../FinancialHub.Auth.Services.csproj | 27 --------- .../FinancialHub.Auth.Services/Usings.cs | 5 -- .../FinancialHub.Auth.WebApi.csproj | 2 +- .../FinancialHub.Auth.WebApi/Program.cs | 2 +- src/FinancialHub/FinancialHub.sln | 58 +++++++++---------- 55 files changed, 217 insertions(+), 216 deletions(-) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Signin/SigninServiceTests.cs (90%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Signin/SigninServiceTests.get.cs (97%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Signup/SignupServiceTests.create.cs (97%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Signup/SignupServiceTests.cs (90%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Token/TokenServiceTests.cs (85%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Token/TokenServiceTests.generate.cs (98%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Users/UserServiceTests.create.cs (91%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Users/UserServiceTests.cs (84%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Users/UserServiceTests.get.cs (95%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Services/Users/UserServiceTests.update.cs (95%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Validators/SigninModelValidatorTests.cs (97%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Validators/SignupModelValidatorTests.cs (98%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests => FinancialHub.Auth.Application.Tests}/Validators/UserValidatorTests.cs (97%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Configurations/TokenServiceSettings.cs (80%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Extensions/IServiceCollectionExtensions.Auth.cs (93%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Extensions/IServiceCollectionExtensions.Docs.cs (94%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Services/SigninService.cs (93%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Services/SignupService.cs (94%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Services/TokenService.cs (94%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Services/UserService.cs (95%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Validators/Rules/ValidatorRulesExtensions.cs (96%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Validators/SigninModelValidator.cs (79%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Validators/SignupModelValidator.cs (88%) rename src/FinancialHub/{FinancialHub.Auth.Services => FinancialHub.Auth.Application}/Validators/UserValidator.cs (84%) rename src/FinancialHub/{FinancialHub.Auth.Application.Tests => FinancialHub.Auth.Presentation.Tests}/Asserts/ControllerResponseAssert.cs (94%) rename src/FinancialHub/{FinancialHub.Auth.Application.Tests => FinancialHub.Auth.Presentation.Tests}/Controllers/Signin/SigninControllerTests.cs (89%) rename src/FinancialHub/{FinancialHub.Auth.Application.Tests => FinancialHub.Auth.Presentation.Tests}/Controllers/Signin/SigninControllerTests.get.cs (92%) rename src/FinancialHub/{FinancialHub.Auth.Application.Tests => FinancialHub.Auth.Presentation.Tests}/Controllers/Signup/SignupControllerTests.create.cs (93%) rename src/FinancialHub/{FinancialHub.Auth.Application.Tests => FinancialHub.Auth.Presentation.Tests}/Controllers/Signup/SignupControllerTests.cs (89%) rename src/FinancialHub/{FinancialHub.Auth.Application.Tests => FinancialHub.Auth.Presentation.Tests}/Controllers/Users/UsersControllerTests.create.cs (97%) rename src/FinancialHub/{FinancialHub.Auth.Application.Tests => FinancialHub.Auth.Presentation.Tests}/Controllers/Users/UsersControllerTests.cs (93%) rename src/FinancialHub/{FinancialHub.Auth.Application.Tests => FinancialHub.Auth.Presentation.Tests}/Controllers/Users/UsersControllerTests.get.cs (96%) rename src/FinancialHub/{FinancialHub.Auth.Application.Tests => FinancialHub.Auth.Presentation.Tests}/Controllers/Users/UsersControllerTests.update.cs (98%) rename src/FinancialHub/{FinancialHub.Auth.Services.Tests/FinancialHub.Auth.Services.Tests.csproj => FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj} (69%) create mode 100644 src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Usings.cs rename src/FinancialHub/{FinancialHub.Auth.Application => FinancialHub.Auth.Presentation}/.editorconfig (100%) rename src/FinancialHub/{FinancialHub.Auth.Application => FinancialHub.Auth.Presentation}/Controllers/SigninController.cs (96%) rename src/FinancialHub/{FinancialHub.Auth.Application => FinancialHub.Auth.Presentation}/Controllers/SignupController.cs (96%) rename src/FinancialHub/{FinancialHub.Auth.Application => FinancialHub.Auth.Presentation}/Controllers/UsersController.cs (98%) create mode 100644 src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs rename src/FinancialHub/{FinancialHub.Auth.Application => FinancialHub.Auth.Presentation}/Extensions/SwaggerExtensions.cs (93%) create mode 100644 src/FinancialHub/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj create mode 100644 src/FinancialHub/FinancialHub.Auth.Presentation/Usings.cs delete mode 100644 src/FinancialHub/FinancialHub.Auth.Services.Tests/Usings.cs delete mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.cs delete mode 100644 src/FinancialHub/FinancialHub.Auth.Services/FinancialHub.Auth.Services.csproj delete mode 100644 src/FinancialHub/FinancialHub.Auth.Services/Usings.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj b/src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj index 537f416..b54f157 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj @@ -9,6 +9,7 @@ + @@ -19,6 +20,8 @@ + + diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs index 2587d96..ee47797 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs @@ -1,8 +1,8 @@ using FinancialHub.Auth.Domain.Interfaces.Providers; using FinancialHub.Auth.Domain.Interfaces.Services; -using FinancialHub.Auth.Services.Services; +using FinancialHub.Auth.Application.Services; -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class SigninServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs similarity index 97% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.get.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs index d5323c0..6817a07 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signin/SigninServiceTests.get.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class SigninServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs similarity index 97% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.create.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs index 466cbae..0b75a8d 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.create.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class SignupServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs index 9cfdc34..d590ee1 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Signup/SignupServiceTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs @@ -1,8 +1,8 @@ using FinancialHub.Auth.Domain.Interfaces.Providers; using FinancialHub.Auth.Domain.Interfaces.Services; -using FinancialHub.Auth.Services.Services; +using FinancialHub.Auth.Application.Services; -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class SignupServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs similarity index 85% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs index dc2f24f..b3cc055 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs @@ -1,9 +1,9 @@ using FinancialHub.Auth.Domain.Interfaces.Services; -using FinancialHub.Auth.Services.Configurations; -using FinancialHub.Auth.Services.Services; +using FinancialHub.Auth.Application.Configurations; +using FinancialHub.Auth.Application.Services; using Microsoft.Extensions.Options; -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class TokenServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.generate.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.generate.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs index bc4a40e..d8cb62e 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Token/TokenServiceTests.generate.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs @@ -2,7 +2,7 @@ using System.IdentityModel.Tokens.Jwt; using System.Text; -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class TokenServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs similarity index 91% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs index 80392e8..f932040 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.create.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class UserServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs similarity index 84% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs index a6a3105..93bc5a0 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs @@ -1,8 +1,8 @@ using FinancialHub.Auth.Domain.Interfaces.Providers; using FinancialHub.Auth.Domain.Interfaces.Services; -using FinancialHub.Auth.Services.Services; +using FinancialHub.Auth.Application.Services; -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class UserServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.get.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs index f0010f9..55b5844 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.get.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class UserServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.update.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.update.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs index c639cf1..a6f2cba 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Services/Users/UserServiceTests.update.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Services.Tests.Services +namespace FinancialHub.Auth.Application.Tests.Services { public partial class UserServiceTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs index f493291..3701c6a 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs @@ -1,19 +1,8 @@ -global using Microsoft.AspNetCore.Mvc; - -global using Moq; global using NUnit.Framework; - -global using FinancialHub.Auth.Tests.Common.Assertions; -global using FinancialHub.Auth.Tests.Common.Builders.Models; +global using Moq; global using FinancialHub.Auth.Domain.Models; -global using FinancialHub.Auth.Domain.Interfaces.Services; - -global using FinancialHub.Domain.Results; -global using FinancialHub.Domain.Results.Errors; - -global using FinancialHub.Domain.Responses.Success; -global using FinancialHub.Domain.Responses.Errors; +global using FinancialHub.Auth.Tests.Common.Assertions; -global using FinancialHub.Auth.Application.Controllers; \ No newline at end of file +global using FinancialHub.Auth.Tests.Common.Builders.Models; diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SigninModelValidatorTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs similarity index 97% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SigninModelValidatorTests.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs index 6fbf8b2..9be1eca 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SigninModelValidatorTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs @@ -1,9 +1,9 @@ using FinancialHub.Auth.Domain.Interfaces.Resources; using FinancialHub.Auth.Resources.Providers; -using FinancialHub.Auth.Services.Validators; +using FinancialHub.Auth.Application.Validators; using System.Globalization; -namespace FinancialHub.Auth.Services.Tests.Validators +namespace FinancialHub.Auth.Application.Tests.Validators { public class SigninModelValidatorTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SignupModelValidatorTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SignupModelValidatorTests.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs index cd106f6..638ee06 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/SignupModelValidatorTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs @@ -1,9 +1,9 @@ using FinancialHub.Auth.Domain.Interfaces.Resources; using FinancialHub.Auth.Resources.Providers; -using FinancialHub.Auth.Services.Validators; +using FinancialHub.Auth.Application.Validators; using System.Globalization; -namespace FinancialHub.Auth.Services.Tests.Validators +namespace FinancialHub.Auth.Application.Tests.Validators { public class SignupModelValidatorTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/UserValidatorTests.cs b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs similarity index 97% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/UserValidatorTests.cs rename to src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs index 609dc30..5cde0fd 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Validators/UserValidatorTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs @@ -1,9 +1,9 @@ using FinancialHub.Auth.Domain.Interfaces.Resources; using FinancialHub.Auth.Resources.Providers; -using FinancialHub.Auth.Services.Validators; +using FinancialHub.Auth.Application.Validators; using System.Globalization; -namespace FinancialHub.Auth.Services.Tests.Validators +namespace FinancialHub.Auth.Application.Tests.Validators { public class UserValidatorTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Configurations/TokenServiceSettings.cs b/src/FinancialHub/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs similarity index 80% rename from src/FinancialHub/FinancialHub.Auth.Services/Configurations/TokenServiceSettings.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs index 80b9d5e..bb484c7 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Configurations/TokenServiceSettings.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Services.Configurations +namespace FinancialHub.Auth.Application.Configurations { public class TokenServiceSettings { diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Auth.cs b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs similarity index 93% rename from src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Auth.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs index 1eaccb7..5795f5e 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Auth.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs @@ -1,6 +1,6 @@ -using FinancialHub.Auth.Services.Configurations; -using FinancialHub.Auth.Services.Services; -using FinancialHub.Auth.Services.Validators; +using FinancialHub.Auth.Application.Configurations; +using FinancialHub.Auth.Application.Services; +using FinancialHub.Auth.Application.Validators; using FluentValidation; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.Configuration; @@ -8,7 +8,7 @@ using Microsoft.IdentityModel.Tokens; using System.Text; -namespace FinancialHub.Auth.Services.Extensions +namespace FinancialHub.Auth.Application.Extensions { public static partial class IServiceCollectionExtensions { diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Docs.cs b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Docs.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs index 8d73c06..39a46a1 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.Docs.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.OpenApi.Models; -namespace FinancialHub.Auth.Services.Extensions +namespace FinancialHub.Auth.Application.Extensions { public static partial class IServiceCollectionExtensions { diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs index c0606bf..bc48e6b 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs @@ -1,21 +1,43 @@ -using Microsoft.Extensions.Configuration; +using FinancialHub.Auth.Application.Services; +using FinancialHub.Auth.Application.Validators; +using FluentValidation; +using FluentValidation.AspNetCore; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using FinancialHub.Auth.Services.Extensions; -using FinancialHub.Auth.Resources.Extensions; -using FinancialHub.Auth.Infra.Extensions; -using FinancialHub.Auth.Infra.Data.Extensions; +using System.Diagnostics.CodeAnalysis; namespace FinancialHub.Auth.Application.Extensions { - public static class IServiceCollectionExtensions + [ExcludeFromCodeCoverage] + public static partial class IServiceCollectionExtensions { - public static IServiceCollection AddAuthApplication(this IServiceCollection services, IConfiguration configuration) + public static IServiceCollection AddAuthServices(this IServiceCollection services, IConfiguration configuration) { - services - .AddAuthServices(configuration) - .AddAuthResources() - .AddAuthProviders(configuration) - .AddAuthRepositories(configuration); + services.AddAuthServices(); + + services.AddAuthentication(configuration); + + services.AddAuthValidators(); + + return services; + } + + private static IServiceCollection AddAuthServices(this IServiceCollection services) + { + services.AddScoped(); + + return services; + } + + private static IServiceCollection AddAuthValidators(this IServiceCollection services) + { + services.AddFluentValidation(x => + { + x.AutomaticValidationEnabled = true; + x.DisableDataAnnotationsValidation = true; + x.ValidatorOptions.DefaultRuleLevelCascadeMode = CascadeMode.Stop; + }); + services.AddScoped, UserValidator>(); return services; } diff --git a/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj b/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj index 07a5135..05fa4af 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj +++ b/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj @@ -1,24 +1,27 @@ - + net6.0 enable enable - True - - - + + + + + + + + + + + - - - - diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Services/SigninService.cs b/src/FinancialHub/FinancialHub.Auth.Application/Services/SigninService.cs similarity index 93% rename from src/FinancialHub/FinancialHub.Auth.Services/Services/SigninService.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Services/SigninService.cs index 9e984b5..a4b4014 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Services/SigninService.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Services/SigninService.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Services.Services +namespace FinancialHub.Auth.Application.Services { public class SigninService : ISigninService { diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Services/SignupService.cs b/src/FinancialHub/FinancialHub.Auth.Application/Services/SignupService.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Auth.Services/Services/SignupService.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Services/SignupService.cs index f45e3be..ed9d986 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Services/SignupService.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Services/SignupService.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Services.Services +namespace FinancialHub.Auth.Application.Services { public class SignupService : ISignupService { diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Services/TokenService.cs b/src/FinancialHub/FinancialHub.Auth.Application/Services/TokenService.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Auth.Services/Services/TokenService.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Services/TokenService.cs index 4d8e159..9b041c0 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Services/TokenService.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Services/TokenService.cs @@ -3,9 +3,9 @@ using System.IdentityModel.Tokens.Jwt; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; -using FinancialHub.Auth.Services.Configurations; +using FinancialHub.Auth.Application.Configurations; -namespace FinancialHub.Auth.Services.Services +namespace FinancialHub.Auth.Application.Services { public class TokenService : ITokenService { diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Services/UserService.cs b/src/FinancialHub/FinancialHub.Auth.Application/Services/UserService.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Auth.Services/Services/UserService.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Services/UserService.cs index 61244fe..9c7972f 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Services/UserService.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Services/UserService.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Services.Services +namespace FinancialHub.Auth.Application.Services { public class UserService : IUserService { diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs index 0b4932f..85fccc9 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs @@ -1,8 +1,6 @@ -global using Microsoft.AspNetCore.Mvc; - -global using FinancialHub.Auth.Domain.Interfaces.Services; +global using FinancialHub.Domain.Results; +global using FinancialHub.Domain.Results.Errors; global using FinancialHub.Auth.Domain.Models; - -global using FinancialHub.Domain.Responses.Errors; -global using FinancialHub.Domain.Responses.Success; \ No newline at end of file +global using FinancialHub.Auth.Domain.Interfaces.Services; +global using FinancialHub.Auth.Domain.Interfaces.Providers; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Validators/Rules/ValidatorRulesExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs similarity index 96% rename from src/FinancialHub/FinancialHub.Auth.Services/Validators/Rules/ValidatorRulesExtensions.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs index 39e9069..2a5a3c9 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Validators/Rules/ValidatorRulesExtensions.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs @@ -1,7 +1,7 @@ using FinancialHub.Auth.Domain.Interfaces.Resources; using FluentValidation; -namespace FinancialHub.Auth.Services.Validators.Rules +namespace FinancialHub.Auth.Application.Validators.Rules { public static class ValidatorRulesExtensions { diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Validators/SigninModelValidator.cs b/src/FinancialHub/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs similarity index 79% rename from src/FinancialHub/FinancialHub.Auth.Services/Validators/SigninModelValidator.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs index abf6edc..c2ef4ab 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Validators/SigninModelValidator.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs @@ -1,8 +1,8 @@ using FinancialHub.Auth.Domain.Interfaces.Resources; -using FinancialHub.Auth.Services.Validators.Rules; +using FinancialHub.Auth.Application.Validators.Rules; using FluentValidation; -namespace FinancialHub.Auth.Services.Validators +namespace FinancialHub.Auth.Application.Validators { public class SigninModelValidator : AbstractValidator { diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Validators/SignupModelValidator.cs b/src/FinancialHub/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs similarity index 88% rename from src/FinancialHub/FinancialHub.Auth.Services/Validators/SignupModelValidator.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs index 7c8a0d0..70a1205 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Validators/SignupModelValidator.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs @@ -1,8 +1,8 @@ using FluentValidation; using FinancialHub.Auth.Domain.Interfaces.Resources; -using FinancialHub.Auth.Services.Validators.Rules; +using FinancialHub.Auth.Application.Validators.Rules; -namespace FinancialHub.Auth.Services.Validators +namespace FinancialHub.Auth.Application.Validators { public class SignupModelValidator : AbstractValidator { diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Validators/UserValidator.cs b/src/FinancialHub/FinancialHub.Auth.Application/Validators/UserValidator.cs similarity index 84% rename from src/FinancialHub/FinancialHub.Auth.Services/Validators/UserValidator.cs rename to src/FinancialHub/FinancialHub.Auth.Application/Validators/UserValidator.cs index 55c1f7d..69e7498 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services/Validators/UserValidator.cs +++ b/src/FinancialHub/FinancialHub.Auth.Application/Validators/UserValidator.cs @@ -1,8 +1,8 @@ using FluentValidation; using FinancialHub.Auth.Domain.Interfaces.Resources; -using FinancialHub.Auth.Services.Validators.Rules; +using FinancialHub.Auth.Application.Validators.Rules; -namespace FinancialHub.Auth.Services.Validators +namespace FinancialHub.Auth.Application.Validators { public class UserValidator : AbstractValidator { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Asserts/ControllerResponseAssert.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Asserts/ControllerResponseAssert.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs index c7d453a..399bf7a 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Asserts/ControllerResponseAssert.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Application.Tests.Asserts +namespace FinancialHub.Auth.Presentation.Tests.Asserts { public static class ControllerResponseAssert { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs similarity index 89% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs index bf4df06..84a7333 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Application.Tests.Controllers +namespace FinancialHub.Auth.Presentation.Tests.Controllers { public partial class SigninControllerTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs similarity index 92% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.get.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs index dc4b654..389cec3 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signin/SigninControllerTests.get.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs @@ -1,6 +1,6 @@ -using FinancialHub.Auth.Application.Tests.Asserts; +using FinancialHub.Auth.Presentation.Tests.Asserts; -namespace FinancialHub.Auth.Application.Tests.Controllers +namespace FinancialHub.Auth.Presentation.Tests.Controllers { public partial class SigninControllerTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs similarity index 93% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.create.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs index e323a7e..b208ed3 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.create.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs @@ -1,6 +1,6 @@ -using FinancialHub.Auth.Application.Tests.Asserts; +using FinancialHub.Auth.Presentation.Tests.Asserts; -namespace FinancialHub.Auth.Application.Tests.Controllers +namespace FinancialHub.Auth.Presentation.Tests.Controllers { public partial class SignupControllerTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs similarity index 89% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs index 1353b79..a05176e 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Signup/SignupControllerTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Application.Tests.Controllers +namespace FinancialHub.Auth.Presentation.Tests.Controllers { public partial class SignupControllerTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.create.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs similarity index 97% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.create.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs index a6879e6..fcc573a 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.create.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace FinancialHub.Auth.Application.Tests.Controllers +namespace FinancialHub.Auth.Presentation.Tests.Controllers { public partial class UsersControllerTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs similarity index 93% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs index 886b676..eaae3af 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Application.Tests.Controllers +namespace FinancialHub.Auth.Presentation.Tests.Controllers { public partial class UsersControllerTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.get.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs similarity index 96% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.get.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs index f8effb6..1412600 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.get.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Application.Tests.Controllers +namespace FinancialHub.Auth.Presentation.Tests.Controllers { public partial class UsersControllerTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.update.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.update.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs index f07a00b..ed4779f 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Controllers/Users/UsersControllerTests.update.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Application.Tests.Controllers +namespace FinancialHub.Auth.Presentation.Tests.Controllers { public partial class UsersControllerTests { diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/FinancialHub.Auth.Services.Tests.csproj b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj similarity index 69% rename from src/FinancialHub/FinancialHub.Auth.Services.Tests/FinancialHub.Auth.Services.Tests.csproj rename to src/FinancialHub/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj index 6385f4a..65b6027 100644 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/FinancialHub.Auth.Services.Tests.csproj +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj @@ -9,7 +9,6 @@ - @@ -19,9 +18,7 @@ - - - + diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Usings.cs new file mode 100644 index 0000000..42ed47c --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Usings.cs @@ -0,0 +1,19 @@ +global using Microsoft.AspNetCore.Mvc; + +global using Moq; +global using NUnit.Framework; + +global using FinancialHub.Auth.Tests.Common.Assertions; +global using FinancialHub.Auth.Tests.Common.Builders.Models; + +global using FinancialHub.Auth.Domain.Models; + +global using FinancialHub.Auth.Domain.Interfaces.Services; + +global using FinancialHub.Domain.Results; +global using FinancialHub.Domain.Results.Errors; + +global using FinancialHub.Domain.Responses.Success; +global using FinancialHub.Domain.Responses.Errors; + +global using FinancialHub.Auth.Presentation.Controllers; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Application/.editorconfig b/src/FinancialHub/FinancialHub.Auth.Presentation/.editorconfig similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/.editorconfig rename to src/FinancialHub/FinancialHub.Auth.Presentation/.editorconfig diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SigninController.cs b/src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SigninController.cs similarity index 96% rename from src/FinancialHub/FinancialHub.Auth.Application/Controllers/SigninController.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SigninController.cs index 025bf7f..7f198dc 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SigninController.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SigninController.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Authorization; -namespace FinancialHub.Auth.Application.Controllers +namespace FinancialHub.Auth.Presentation.Controllers { [AllowAnonymous] [ApiController] diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SignupController.cs b/src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SignupController.cs similarity index 96% rename from src/FinancialHub/FinancialHub.Auth.Application/Controllers/SignupController.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SignupController.cs index 88df22c..864266a 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application/Controllers/SignupController.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SignupController.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Authorization; -namespace FinancialHub.Auth.Application.Controllers +namespace FinancialHub.Auth.Presentation.Controllers { [AllowAnonymous] [ApiController] diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Controllers/UsersController.cs b/src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/UsersController.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Auth.Application/Controllers/UsersController.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/UsersController.cs index 4b7f38b..de545e4 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application/Controllers/UsersController.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/UsersController.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Authorization; -namespace FinancialHub.Auth.Application.Controllers +namespace FinancialHub.Auth.Presentation.Controllers { [Authorize] [ApiController] diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..188960a --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using FinancialHub.Auth.Application.Extensions; +using FinancialHub.Auth.Resources.Extensions; +using FinancialHub.Auth.Infra.Extensions; +using FinancialHub.Auth.Infra.Data.Extensions; + +namespace FinancialHub.Auth.Presentation.Extensions +{ + public static class IServiceCollectionExtensions + { + public static IServiceCollection AddAuthApplication(this IServiceCollection services, IConfiguration configuration) + { + services + .AddAuthServices(configuration) + .AddAuthResources() + .AddAuthProviders(configuration) + .AddAuthRepositories(configuration); + + return services; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Extensions/SwaggerExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs similarity index 93% rename from src/FinancialHub/FinancialHub.Auth.Application/Extensions/SwaggerExtensions.cs rename to src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs index 0141f82..9b1b382 100644 --- a/src/FinancialHub/FinancialHub.Auth.Application/Extensions/SwaggerExtensions.cs +++ b/src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs @@ -1,10 +1,10 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; -using FinancialHub.Auth.Services.Extensions; +using FinancialHub.Auth.Application.Extensions; using Microsoft.Extensions.DependencyInjection; using Microsoft.OpenApi.Models; -namespace FinancialHub.Auth.Application.Extensions +namespace FinancialHub.Auth.Presentation.Extensions { [ExcludeFromCodeCoverage] public static class SwaggerExtensions diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj b/src/FinancialHub/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj new file mode 100644 index 0000000..cd6f5a1 --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj @@ -0,0 +1,24 @@ + + + + net6.0 + enable + enable + True + + + + + + + + + + + + + + + + + diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Presentation/Usings.cs new file mode 100644 index 0000000..0b4932f --- /dev/null +++ b/src/FinancialHub/FinancialHub.Auth.Presentation/Usings.cs @@ -0,0 +1,8 @@ +global using Microsoft.AspNetCore.Mvc; + +global using FinancialHub.Auth.Domain.Interfaces.Services; + +global using FinancialHub.Auth.Domain.Models; + +global using FinancialHub.Domain.Responses.Errors; +global using FinancialHub.Domain.Responses.Success; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Services.Tests/Usings.cs deleted file mode 100644 index 3701c6a..0000000 --- a/src/FinancialHub/FinancialHub.Auth.Services.Tests/Usings.cs +++ /dev/null @@ -1,8 +0,0 @@ -global using NUnit.Framework; -global using Moq; - -global using FinancialHub.Auth.Domain.Models; - -global using FinancialHub.Auth.Tests.Common.Assertions; - -global using FinancialHub.Auth.Tests.Common.Builders.Models; diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.cs b/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.cs deleted file mode 100644 index ebf0d7a..0000000 --- a/src/FinancialHub/FinancialHub.Auth.Services/Extensions/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,45 +0,0 @@ -using FinancialHub.Auth.Services.Services; -using FinancialHub.Auth.Services.Validators; -using FluentValidation; -using FluentValidation.AspNetCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using System.Diagnostics.CodeAnalysis; - -namespace FinancialHub.Auth.Services.Extensions -{ - [ExcludeFromCodeCoverage] - public static partial class IServiceCollectionExtensions - { - public static IServiceCollection AddAuthServices(this IServiceCollection services, IConfiguration configuration) - { - services.AddAuthServices(); - - services.AddAuthentication(configuration); - - services.AddAuthValidators(); - - return services; - } - - private static IServiceCollection AddAuthServices(this IServiceCollection services) - { - services.AddScoped(); - - return services; - } - - private static IServiceCollection AddAuthValidators(this IServiceCollection services) - { - services.AddFluentValidation(x => - { - x.AutomaticValidationEnabled = true; - x.DisableDataAnnotationsValidation = true; - x.ValidatorOptions.DefaultRuleLevelCascadeMode = CascadeMode.Stop; - }); - services.AddScoped, UserValidator>(); - - return services; - } - } -} diff --git a/src/FinancialHub/FinancialHub.Auth.Services/FinancialHub.Auth.Services.csproj b/src/FinancialHub/FinancialHub.Auth.Services/FinancialHub.Auth.Services.csproj deleted file mode 100644 index 05fa4af..0000000 --- a/src/FinancialHub/FinancialHub.Auth.Services/FinancialHub.Auth.Services.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - - - - - - - - - - - - - diff --git a/src/FinancialHub/FinancialHub.Auth.Services/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Services/Usings.cs deleted file mode 100644 index 47dc281..0000000 --- a/src/FinancialHub/FinancialHub.Auth.Services/Usings.cs +++ /dev/null @@ -1,5 +0,0 @@ -global using FinancialHub.Domain.Results; -global using FinancialHub.Domain.Results.Errors; -global using FinancialHub.Auth.Domain.Models; -global using FinancialHub.Auth.Domain.Interfaces.Services; -global using FinancialHub.Auth.Domain.Interfaces.Providers; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj b/src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj index 66fad12..bfe63e3 100644 --- a/src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj +++ b/src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj @@ -28,7 +28,7 @@ - + diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs b/src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs index c7a8265..0ccc028 100644 --- a/src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs +++ b/src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs @@ -1,4 +1,4 @@ -using FinancialHub.Auth.Application.Extensions; +using FinancialHub.Auth.Presentation.Extensions; using System.Diagnostics.CodeAnalysis; namespace FinancialHub.Auth.WebApi; diff --git a/src/FinancialHub/FinancialHub.sln b/src/FinancialHub/FinancialHub.sln index 1fbb984..cf386d2 100644 --- a/src/FinancialHub/FinancialHub.sln +++ b/src/FinancialHub/FinancialHub.sln @@ -33,14 +33,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{B918D713 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{74BFDE19-E416-46A1-B9C2-878DA41B249A}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{1488D2AC-39E7-414A-9B0A-344EBDA0E4E9}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{1488D2AC-39E7-414A-9B0A-344EBDA0E4E9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{93E5303C-66C1-4BF6-8823-6CBA9C3751BE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Domain", "FinancialHub.Auth.Domain\FinancialHub.Auth.Domain.csproj", "{82C01B54-91F9-4296-B2C7-F3FA230462F1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Services", "FinancialHub.Auth.Services\FinancialHub.Auth.Services.csproj", "{F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.WebApi", "FinancialHub.Auth.WebApi\FinancialHub.Auth.WebApi.csproj", "{23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Data.Tests", "FinancialHub.Auth.Infra.Data.Tests\FinancialHub.Auth.Infra.Data.Tests.csproj", "{3975688B-BF51-4DEB-8E19-777322865E83}" @@ -53,8 +51,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Dat EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Tests", "FinancialHub.Auth.Infra.Tests\FinancialHub.Auth.Infra.Tests.csproj", "{A4D904E8-5A38-4E00-8419-62CB1F24F94E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Services.Tests", "FinancialHub.Auth.Services.Tests\FinancialHub.Auth.Services.Tests.csproj", "{9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services.NUnitTests", "FinancialHub.Services.NUnitTests\FinancialHub.Services.NUnitTests.csproj", "{43423E19-2F4B-4A94-B8A7-4D2803D16A6E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{F6444C4B-6609-40E3-8D09-C52D871C5160}" @@ -65,13 +61,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services", "Fi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Resources", "FinancialHub.Auth.Resources\FinancialHub.Auth.Resources.csproj", "{8B091A42-5BE6-49A4-8086-C8761E0CE769}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{421DB63D-B9E6-4069-8B79-6C956506F3C5}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{421DB63D-B9E6-4069-8B79-6C956506F3C5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.IntegrationTests", "FinancialHub.Auth.IntegrationTests\FinancialHub.Auth.IntegrationTests.csproj", "{DD87106B-71B2-484D-A2CA-6ADD69C69CC7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Presentation", "FinancialHub.Auth.Presentation\FinancialHub.Auth.Presentation.csproj", "{10A8A033-1884-4CD4-A413-75A8C08296D0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application", "FinancialHub.Auth.Application\FinancialHub.Auth.Application.csproj", "{B3FAC69E-A3DD-4947-AD6A-89E683421D0A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Presentation.Tests", "FinancialHub.Auth.Presentation.Tests\FinancialHub.Auth.Presentation.Tests.csproj", "{F6C7E760-0264-425B-A935-35C19701B428}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application.Tests", "FinancialHub.Auth.Application.Tests\FinancialHub.Auth.Application.Tests.csproj", "{89795B5A-58F2-4614-9EE7-12468940114A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application", "FinancialHub.Auth.Application\FinancialHub.Auth.Application.csproj", "{C36391AC-AC61-4165-9C00-0B2B4ED78C8D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialHub.Auth.IntegrationTests", "FinancialHub.Auth.IntegrationTests\FinancialHub.Auth.IntegrationTests.csproj", "{DD87106B-71B2-484D-A2CA-6ADD69C69CC7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application.Tests", "FinancialHub.Auth.Application.Tests\FinancialHub.Auth.Application.Tests.csproj", "{22448D38-BA25-4FAE-9337-BEA884C7EC57}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -107,10 +107,6 @@ Global {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Debug|Any CPU.Build.0 = Debug|Any CPU {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Release|Any CPU.ActiveCfg = Release|Any CPU {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Release|Any CPU.Build.0 = Release|Any CPU - {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033}.Release|Any CPU.Build.0 = Release|Any CPU {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Debug|Any CPU.Build.0 = Debug|Any CPU {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -135,10 +131,6 @@ Global {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.ActiveCfg = Release|Any CPU {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.Build.0 = Release|Any CPU - {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD}.Release|Any CPU.Build.0 = Release|Any CPU {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Debug|Any CPU.Build.0 = Debug|Any CPU {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -159,18 +151,26 @@ Global {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Debug|Any CPU.Build.0 = Debug|Any CPU {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Release|Any CPU.ActiveCfg = Release|Any CPU {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Release|Any CPU.Build.0 = Release|Any CPU - {B3FAC69E-A3DD-4947-AD6A-89E683421D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B3FAC69E-A3DD-4947-AD6A-89E683421D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B3FAC69E-A3DD-4947-AD6A-89E683421D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B3FAC69E-A3DD-4947-AD6A-89E683421D0A}.Release|Any CPU.Build.0 = Release|Any CPU - {89795B5A-58F2-4614-9EE7-12468940114A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {89795B5A-58F2-4614-9EE7-12468940114A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {89795B5A-58F2-4614-9EE7-12468940114A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {89795B5A-58F2-4614-9EE7-12468940114A}.Release|Any CPU.Build.0 = Release|Any CPU {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Release|Any CPU.Build.0 = Release|Any CPU + {10A8A033-1884-4CD4-A413-75A8C08296D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10A8A033-1884-4CD4-A413-75A8C08296D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10A8A033-1884-4CD4-A413-75A8C08296D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10A8A033-1884-4CD4-A413-75A8C08296D0}.Release|Any CPU.Build.0 = Release|Any CPU + {F6C7E760-0264-425B-A935-35C19701B428}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6C7E760-0264-425B-A935-35C19701B428}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6C7E760-0264-425B-A935-35C19701B428}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6C7E760-0264-425B-A935-35C19701B428}.Release|Any CPU.Build.0 = Release|Any CPU + {C36391AC-AC61-4165-9C00-0B2B4ED78C8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C36391AC-AC61-4165-9C00-0B2B4ED78C8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C36391AC-AC61-4165-9C00-0B2B4ED78C8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C36391AC-AC61-4165-9C00-0B2B4ED78C8D}.Release|Any CPU.Build.0 = Release|Any CPU + {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -190,22 +190,22 @@ Global {74BFDE19-E416-46A1-B9C2-878DA41B249A} = {B918D713-0701-447C-B403-10DE0C769581} {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} {82C01B54-91F9-4296-B2C7-F3FA230462F1} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} - {F716E442-4CAC-4CA3-B7CE-6AAA39C3D033} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} {3975688B-BF51-4DEB-8E19-777322865E83} = {74BFDE19-E416-46A1-B9C2-878DA41B249A} {F32C1BDA-B655-4E56-96A6-F8BD335707C6} = {B918D713-0701-447C-B403-10DE0C769581} {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} {72C9C13F-BF8B-4649-B504-99E634FCDDE5} = {74BFDE19-E416-46A1-B9C2-878DA41B249A} {A4D904E8-5A38-4E00-8419-62CB1F24F94E} = {B918D713-0701-447C-B403-10DE0C769581} - {9A5EB041-6280-4DA0-B811-9E2D1BCDDCAD} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} {43423E19-2F4B-4A94-B8A7-4D2803D16A6E} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} {98A9979A-23A4-4DAA-917C-6F37794E0D06} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {2483A335-88C1-4413-9AB7-5AE0C67BBA23} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} {8B091A42-5BE6-49A4-8086-C8761E0CE769} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} {421DB63D-B9E6-4069-8B79-6C956506F3C5} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} - {B3FAC69E-A3DD-4947-AD6A-89E683421D0A} = {421DB63D-B9E6-4069-8B79-6C956506F3C5} - {89795B5A-58F2-4614-9EE7-12468940114A} = {421DB63D-B9E6-4069-8B79-6C956506F3C5} {DD87106B-71B2-484D-A2CA-6ADD69C69CC7} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} + {10A8A033-1884-4CD4-A413-75A8C08296D0} = {421DB63D-B9E6-4069-8B79-6C956506F3C5} + {F6C7E760-0264-425B-A935-35C19701B428} = {421DB63D-B9E6-4069-8B79-6C956506F3C5} + {C36391AC-AC61-4165-9C00-0B2B4ED78C8D} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} + {22448D38-BA25-4FAE-9337-BEA884C7EC57} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} From 8af9a7f4642baf7a02d6b8a919bb7f3ff87a74b0 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Thu, 3 Aug 2023 12:16:32 -0300 Subject: [PATCH 19/30] Release v0.5.0 * Adds Core Module * Adds global using to Core project * Adds Core Folder to main project * Adds FinancialHub.Common project * Adds FinancialHub.Common.Tests project * Adds null forgiving in code smells (fix it later) * Changes /src/FinancialHub folder to /src/api * Changes folder reference in ci files * Moves builders from FinancialHub.Domain.Tests to FinancialHub.Common.Tests * Changes DDL file to scr/database * Remove Migrations from code coverage * Fix Auth project references to Common * Fix Core project references to Common * Fix ServiceResults & Responses code smells --- .github/workflows/branch_main_ci.yml | 10 +- .github/workflows/branch_release_ci.yml | 6 +- .../FinancialHub.Auth.Application/Usings.cs | 6 - .../FinancialHub.Auth.Domain/Usings.cs | 3 - .../Builders/Entities/UserEntityBuilder.cs | 47 ------- .../Builders/Models/UserModelBuilder.cs | 47 ------- .../Builders/Models/BaseModelBuilder.cs | 21 --- .../Repositories/ICategoriesRepository.cs | 8 -- .../Repositories/ITransactionsRepository.cs | 8 -- .../Results/Errors/InvalidDataError.cs | 12 -- .../Results/Errors/NotFoundError.cs | 12 -- .../TransactionBalanceTests.cs | 9 -- .../.config/dotnet-tools.json | 0 src/{FinancialHub => api}/.editorconfig | 0 src/{FinancialHub => api}/Dockerfile | 0 ...FinancialHub.Auth.Application.Tests.csproj | 0 .../Services/Signin/SigninServiceTests.cs | 0 .../Services/Signin/SigninServiceTests.get.cs | 0 .../Signup/SignupServiceTests.create.cs | 0 .../Services/Signup/SignupServiceTests.cs | 0 .../Services/Token/TokenServiceTests.cs | 0 .../Token/TokenServiceTests.generate.cs | 0 .../Services/Users/UserServiceTests.create.cs | 0 .../Services/Users/UserServiceTests.cs | 0 .../Services/Users/UserServiceTests.get.cs | 0 .../Services/Users/UserServiceTests.update.cs | 0 .../Usings.cs | 0 .../Validators/SigninModelValidatorTests.cs | 0 .../Validators/SignupModelValidatorTests.cs | 0 .../Validators/UserValidatorTests.cs | 0 .../Configurations/TokenServiceSettings.cs | 0 .../IServiceCollectionExtensions.Auth.cs | 0 .../IServiceCollectionExtensions.Docs.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Auth.Application.csproj | 0 .../Services/SigninService.cs | 0 .../Services/SignupService.cs | 0 .../Services/TokenService.cs | 0 .../Services/UserService.cs | 0 .../FinancialHub.Auth.Application/Usings.cs | 6 + .../Rules/ValidatorRulesExtensions.cs | 0 .../Validators/SigninModelValidator.cs | 0 .../Validators/SignupModelValidator.cs | 0 .../Validators/UserValidator.cs | 0 .../Entities/CredentialEntity.cs | 0 .../Entities/UserEntity.cs | 4 +- .../FinancialHub.Auth.Domain.csproj | 2 +- .../Interfaces/Helpers/IPasswordHelper.cs | 0 .../Providers/ICredentialProvider.cs | 0 .../Interfaces/Providers/ISigninProvider.cs | 0 .../Interfaces/Providers/ISignupProvider.cs | 0 .../Interfaces/Providers/IUserProvider.cs | 0 .../Repositories/ICredentialRepository.cs | 0 .../Repositories/IUserRepository.cs | 0 .../Resources/IErrorMessageProvider.cs | 0 .../Interfaces/Services/ISigninService.cs | 0 .../Interfaces/Services/ISignupService.cs | 0 .../Interfaces/Services/ITokenService.cs | 0 .../Interfaces/Services/IUserService.cs | 0 .../Models/CredentialModel.cs | 0 .../Models/SigninModel.cs | 0 .../Models/SignupModel.cs | 0 .../Models/TokenModel.cs | 0 .../Models/UserModel.cs | 0 src/api/FinancialHub.Auth.Domain/Usings.cs | 3 + .../Assertions/DbContextAssert.cs | 4 +- .../FinancialHub.Auth.Infra.Data.Tests.csproj | 0 .../Fixtures/DatabaseFixture.cs | 1 - .../CredentialRepositoryTests.create.cs | 0 .../Credentials/CredentialRepositoryTests.cs | 0 .../CredentialRepositoryTests.get.cs | 0 .../Users/UserRepositoryTests.create.cs | 0 .../Repositories/Users/UserRepositoryTests.cs | 0 .../Users/UserRepositoryTests.get.cs | 0 .../Users/UserRepositoryTests.update.cs | 0 .../Usings.cs | 3 +- .../Contexts/FinancialHubAuthContext.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Auth.Infra.Data.csproj | 0 .../Mapping/UserCredentialEntityMapping.cs | 0 .../Mapping/UserEntityMapping.cs | 0 ...20230503220050_Adds_User_Table.Designer.cs | 0 .../20230503220050_Adds_User_Table.cs | 0 ...615215715_Add_Credential_Table.Designer.cs | 0 .../20230615215715_Add_Credential_Table.cs | 0 .../FinancialHubAuthContextModelSnapshot.cs | 0 .../Repositories/CredentialRepository.cs | 0 .../Repositories/UserRepository.cs | 0 .../FinancialHub.Auth.Infra.Data/Usings.cs | 0 .../FinancialHub.Auth.Infra.Migrations.csproj | 0 .../FinancialHub.Auth.Infra.Tests.csproj | 0 .../CredentialProviderTests.create.cs | 0 .../Credentials/CredentialProviderTests.cs | 0 .../CredentialProviderTests.get.cs | 0 .../Providers/Signin/SigninProviderTests.cs | 0 .../SigninProviderTests.get_accounts.cs | 0 .../SignupProviderTests.create_account.cs | 0 .../Providers/Signup/SignupProviderTests.cs | 0 .../Users/UserProviderTests.create.cs | 0 .../Providers/Users/UserProviderTests.cs | 0 .../Providers/Users/UserProviderTests.get.cs | 0 .../Users/UserProviderTests.update.cs | 0 .../FinancialHub.Auth.Infra.Tests/Usings.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Auth.Infra.csproj | 0 .../Helpers/PasswordHelper.cs | 0 .../FinancialHubAuthCredentialProfile.cs | 0 .../Mappers/FinancialHubAuthProfile.cs | 0 .../Providers/CredentialProvider.cs | 0 .../Providers/SigninProvider.cs | 0 .../Providers/SignupProvider.cs | 0 .../Providers/UserProvider.cs | 0 .../FinancialHub.Auth.Infra/Usings.cs | 0 .../Base/BaseControllerTests.cs | 0 .../Controllers/SigninControllerTests.cs | 0 .../Controllers/SignupControllerTests.cs | 0 .../Controllers/UsersControllerTests.cs | 0 .../Extensions/HttpClientExtensions.cs | 0 .../Extensions/HttpContentExtensions.cs | 0 .../HttpResponseMessageExtensions.cs | 0 .../Utils/HttpClientExtensionsParameters.cs | 0 .../FinancialHub.Auth.IntegrationTests.csproj | 1 - .../Setup/FinancialHubAuthApiFixture.auth.cs | 0 .../Setup/FinancialHubAuthApiFixture.cs | 0 .../FinancialHubAuthApiFixture.database.cs | 2 +- .../Usings.cs | 4 +- .../Asserts/ControllerResponseAssert.cs | 0 .../Signin/SigninControllerTests.cs | 0 .../Signin/SigninControllerTests.get.cs | 0 .../Signup/SignupControllerTests.create.cs | 0 .../Signup/SignupControllerTests.cs | 0 .../Users/UsersControllerTests.create.cs | 0 .../Controllers/Users/UsersControllerTests.cs | 0 .../Users/UsersControllerTests.get.cs | 0 .../Users/UsersControllerTests.update.cs | 0 ...inancialHub.Auth.Presentation.Tests.csproj | 0 .../Usings.cs | 12 +- .../.editorconfig | 0 .../Controllers/SigninController.cs | 0 .../Controllers/SignupController.cs | 0 .../Controllers/UsersController.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../Extensions/SwaggerExtensions.cs | 0 .../FinancialHub.Auth.Presentation.csproj | 0 .../FinancialHub.Auth.Presentation/Usings.cs | 8 +- .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Auth.Resources.csproj | 0 .../Providers/ErrorMessageProvider.cs | 0 .../Errors/ErrorMessages.Designer.cs | 0 .../Resources/Errors/ErrorMessages.pt-BR.resx | 0 .../Resources/Errors/ErrorMessages.resx | 0 .../Assertions/EntityAssert.cs | 4 +- .../Assertions/ModelAssert.cs | 0 .../Assertions/ResponseAssert.cs | 4 +- .../Entities/UserCredentialEntityBuilder.cs | 0 .../Builders/Entities/UserEntityBuilder.cs | 0 .../Builders/Models/SigninModelBuilder.cs | 0 .../Builders/Models/SignupModelBuilder.cs | 0 .../Builders/Models/TokenModelBuilder.cs | 0 .../Models/UserCredentialModelBuilder.cs | 0 .../Builders/Models/UserModelBuilder.cs | 0 .../FinancialHub.Auth.Tests.Common.csproj | 3 +- .../FinancialHub.Auth.Tests.Common/Usings.cs | 5 +- .../FinancialHub.Auth.WebApi.csproj | 0 .../FinancialHub.Auth.WebApi/Program.cs | 0 .../Properties/launchSettings.json | 0 .../appsettings.Development.json | 0 .../appsettings.Testing.json | 0 .../FinancialHub.Auth.WebApi/appsettings.json | 0 .../Builders/Entities/BaseEntityBuilder.cs | 7 +- .../Builders/Models/BaseModelBuilder.cs | 20 +++ .../FinancialHub.Common.Tests.csproj} | 2 +- .../Entities/BaseEntity.cs | 5 +- .../FinancialHub.Common.csproj | 9 ++ .../Repositories/IBaseRepository.cs | 7 +- .../FinancialHub.Common}/Models/BaseModel.cs | 4 +- .../Responses/Errors/BaseErrorResponse.cs | 4 +- .../Responses/Errors/NotFoundErrorResponse.cs | 2 +- .../Errors/ValidationErrorResponse.cs | 2 +- .../Errors/ValidationsErrorResponse.cs | 8 +- .../Responses/Success/BaseResponse.cs | 4 +- .../Responses/Success/ItemResponse.cs | 2 +- .../Responses/Success/ListResponse.cs | 2 +- .../Success/PaginatedListResponse.cs | 2 +- .../Responses/Success/SaveResponse.cs | 2 +- .../Results/Errors/InvalidDataError.cs | 12 ++ .../Results/Errors/NotFoundError.cs | 12 ++ .../Results/Errors/ServiceError.cs | 6 +- .../Results/ServiceResult.cs | 18 +-- .../Builders/Entities/AccountEntityBuilder.cs | 4 +- .../Builders/Entities/BalanceEntityBuilder.cs | 5 +- .../Entities/CategoryEntityBuilder.cs | 4 +- .../Entities/TransactionEntityBuilder.cs | 6 +- .../Builders/Models/AccountModelBuilder.cs | 4 +- .../Builders/Models/BalanceModelBuilder.cs | 5 +- .../Builders/Models/CategoryModelBuilder.cs | 4 +- .../Models/TransactionModelBuilder.cs | 6 +- .../FinancialHub.Core.Domain.Tests.csproj} | 3 +- .../Queries/TransactionQueryTests.cs | 13 +- .../FinancialHub.Core.Domain.Tests/Usings.cs | 10 ++ .../Entities/AccountEntity.cs | 4 +- .../Entities/BalanceEntity.cs | 5 +- .../Entities/CategoryEntity.cs | 4 +- .../Entities/TransactionEntity.cs | 5 +- .../Enums/TransactionStatus.cs | 2 +- .../Enums/TransactionType.cs | 2 +- .../Filters/TransactionFilter.cs | 5 +- .../FinancialHub.Core.Domain.csproj} | 4 + .../Interfaces/Mappers/IMapperWrapper.cs | 2 +- .../Repositories/IAccountsRepository.cs | 5 +- .../Repositories/IBalancesRepository.cs | 9 +- .../Repositories/ICategoriesRepository.cs | 9 ++ .../Repositories/ITransactionsRepository.cs | 9 ++ .../Services/IAccountBalanceService.cs | 9 +- .../Interfaces/Services/IAccountsService.cs | 9 +- .../Interfaces/Services/IBalancesService.cs | 9 +- .../Interfaces/Services/ICategoriesService.cs | 9 +- .../Services/ITransactionBalanceService.cs | 8 +- .../Services/ITransactionsService.cs | 11 +- .../Models/AccountModel.cs | 4 +- .../Models/BalanceModel.cs | 4 +- .../Models/CategoryModel.cs | 4 +- .../Models/TransactionModel.cs | 8 +- .../Queries/TransactionQuery.cs | 10 +- .../FinancialHubConcepts.Designer.cs | 4 +- .../Resources/FinancialHubConcepts.resx | 0 src/api/FinancialHub.Core.Domain/Usings.cs | 8 ++ ...cialHub.Core.Infra.Data.NUnitTests.csproj} | 4 +- .../Accounts/AccountsRepositoryTests.cs | 9 +- .../BalancesRepositoryTests.amount.cs | 7 +- .../BalancesRepositoryTests.create.cs | 7 +- .../Balances/BalancesRepositoryTests.cs | 9 +- .../Base/BaseRepositoryTests.create.cs | 11 +- .../Repositories/Base/BaseRepositoryTests.cs | 15 +-- .../Base/BaseRepositoryTests.delete.cs | 11 +- .../Base/BaseRepositoryTests.get.cs | 21 +-- .../Base/BaseRepositoryTests.update.cs | 12 +- .../Categories/CategoriesRepositoryTests.cs | 9 +- .../TransactionsRepositoryTests.create.cs | 11 +- .../TransactionsRepositoryTests.cs | 10 +- .../TransactionsRepositoryTests.delete.cs | 5 +- .../TransactionsRepositoryTests.update.cs | 11 +- .../Usings.cs | 13 ++ .../Contexts/FinancialHubContext.cs | 6 +- .../IServiceCollectionExtensions.cs | 8 +- .../FinancialHub.Core.Infra.Data.csproj} | 2 +- .../Mappings/AccountEntityMapping.cs | 6 +- .../Mappings/BalanceEntityMapping.cs | 6 +- .../Mappings/CategoryEntityMapping.cs | 6 +- .../Mappings/TransactionEntityMapping.cs | 6 +- .../Repositories/AccountsRepository.cs | 6 +- .../Repositories/BalancesRepository.cs | 10 +- .../Repositories/BaseRepository.cs | 17 +-- .../Repositories/CategoriesRepository.cs | 6 +- .../Repositories/TransactionsRepository.cs | 8 +- .../FinancialHub.Core.Infra.Data/Usings.cs | 13 ++ ...FinancialHub.Core.Infra.Migrations.csproj} | 2 +- .../20220407152032_v0.2.4.Designer.cs | 4 +- .../Migrations/20220407152032_v0.2.4.cs | 4 +- .../20220520163358_add-balance.Designer.cs | 4 +- .../Migrations/20220520163358_add-balance.cs | 4 +- ...117_add-balance-to-transaction.Designer.cs | 4 +- ...220520215117_add-balance-to-transaction.cs | 4 +- ...20520215501_add-balance-active.Designer.cs | 4 +- .../20220520215501_add-balance-active.cs | 4 +- .../FinancialHubContextModelSnapshot.cs | 4 +- ...ancialHub.Core.Services.NUnitTests.csproj} | 5 +- .../AccountBalanceServiceTests.create.cs | 19 +-- .../AccountBalanceServiceTests.cs | 10 +- .../AccountBalanceServiceTests.delete.cs | 8 +- .../Accounts/AccountsServiceTests.create.cs | 10 +- .../Services/Accounts/AccountsServiceTests.cs | 24 ++-- .../Accounts/AccountsServiceTests.delete.cs | 8 +- .../Accounts/AccountsServiceTests.get.cs | 16 +-- .../Accounts/AccountsServiceTests.update.cs | 10 +- .../Balances/BalancesServiceTests.create.cs | 11 +- .../Services/Balances/BalancesServiceTests.cs | 23 ++-- .../Balances/BalancesServiceTests.delete.cs | 8 +- .../Balances/BalancesServiceTests.get.cs | 16 +-- .../Balances/BalancesServiceTests.update.cs | 19 +-- .../BalancesServiceTests.updateamount.cs | 13 +- .../CategoriesServiceTests.create.cs | 10 +- .../Categories/CategoriesServiceTests.cs | 22 ++-- .../CategoriesServiceTests.delete.cs | 8 +- .../Categories/CategoriesServiceTests.get.cs | 16 +-- .../CategoriesServiceTests.update.cs | 10 +- .../BaseTransactionBalanceTests.cs | 10 +- .../TransactionBalanceTests.create.cs | 8 +- .../TransactionBalanceTests.cs | 9 ++ .../TransactionBalanceTests.delete.cs | 13 +- .../TransactionBalanceTests.update.cs | 13 +- .../TransactionBalanceTests.updateamount.cs | 18 +-- .../TransactionsServiceTests.create.cs | 14 +- .../Transactions/TransactionsServiceTests.cs | 21 +-- .../TransactionsServiceTests.delete.cs | 10 +- .../TransactionsServiceTests.get.cs | 24 ++-- .../TransactionsServiceTests.update.cs | 13 +- .../Usings.cs | 19 +++ .../IServiceCollectionExtensions.cs | 10 +- .../FinancialHub.Core.Services.csproj} | 3 +- .../Mappers/FinancialHubAutoMapperProfile.cs | 8 +- .../Mappers/FinancialHubMapperWrapper.cs | 4 +- .../Services/AccountBalanceService.cs | 10 +- .../Services/AccountsService.cs | 10 +- .../Services/BalancesService.cs | 10 +- .../Services/CategoriesService.cs | 10 +- .../Services/TransactionBalanceService.cs | 19 ++- .../Services/TransactionsService.cs | 19 +-- src/api/FinancialHub.Core.Services/Usings.cs | 12 ++ .../Base/BaseControllerTests.cs | 13 +- .../Controllers/AccountsControllerTests.cs | 10 -- .../Controllers/BalancesControllerTests.cs | 13 +- .../Controllers/CategoriesControllerTests.cs | 10 -- .../TransactionsControllerTests.cs | 10 -- .../Extensions/HttpClientExtensions.cs | 1 - .../HttpResponseMessageExtensions.cs | 4 +- .../IServiceCollectionExtensions.cs | 1 - .../FinancialHub.IntegrationTests.csproj | 3 +- .../Setup/DbConnectionStringManager.cs | 3 +- .../Setup/FinancialHubFixture.cs | 11 +- .../FinancialHub.IntegrationTests/Usings.cs | 30 +++++ .../AccountsControllerTests.create.cs | 15 +-- .../Accounts/AccountsControllerTests.cs | 8 +- .../AccountsControllerTests.delete.cs | 6 +- .../Accounts/AccountsControllerTests.get.cs | 11 +- .../AccountsControllerTests.update.cs | 15 +-- .../BalancesControllerTests.create.cs | 13 +- .../Balances/BalancesControllerTests.cs | 8 +- .../BalancesControllerTests.delete.cs | 6 +- .../BalancesControllerTests.update.cs | 13 +- .../CategoriesControllerTests.create.cs | 13 +- .../Categories/CategoriesControllerTests.cs | 8 +- .../CategoriesControllerTests.delete.cs | 6 +- .../CategoriesControllerTests.get.cs | 11 +- .../CategoriesControllerTests.update.cs | 13 +- .../TransactionsControllerTests.create.cs | 13 +- .../TransactionsControllerTests.cs | 8 +- .../TransactionsControllerTests.delete.cs | 6 +- .../TransactionsControllerTests.get.cs | 10 +- .../TransactionsControllerTests.update.cs | 13 +- .../FinancialHub.WebApi.NUnitTests.csproj | 3 +- .../FinancialHub.WebApi.NUnitTests/Usings.cs | 25 ++++ .../Validators/AccountValidatorTests.cs | 4 +- .../Validators/BalanceValidatorTests.cs | 5 +- .../Validators/CategoryValidatorTests.cs | 4 +- .../Validators/TransactionValidatorTests.cs | 4 +- .../Controllers/AccountsController.cs | 10 +- .../Controllers/BalancesController.cs | 10 +- .../Controllers/Base/BaseController.cs | 5 +- .../Controllers/CategoriesController.cs | 10 +- .../Controllers/TransactionsController.cs | 9 +- .../IServiceCollectionExtensions.cs | 4 +- .../FinancialHub.WebApi.csproj | 5 +- .../FinancialHub.WebApi/Program.cs | 0 .../Properties/launchSettings.json | 0 .../Resources/ErrorMessages.Designer.cs | 0 .../Resources/ErrorMessages.resx | 0 .../FinancialHub.WebApi/Startup.cs | 5 +- src/api/FinancialHub.WebApi/Usings.cs | 17 +++ .../Validators/AccountValidator.cs | 3 +- .../Validators/BalanceValidator.cs | 3 +- .../Validators/CategoryValidator.cs | 3 +- .../Validators/TransactionValidator.cs | 3 +- .../appsettings.Development.json | 0 .../FinancialHub.WebApi/appsettings.json | 0 src/{FinancialHub => api}/FinancialHub.sln | 120 +++++++++++------- src/{FinancialHub => api}/docker-compose.yml | 0 {docs => src}/database/financial-hub_DDL.sql | 0 368 files changed, 740 insertions(+), 1284 deletions(-) delete mode 100644 src/FinancialHub/FinancialHub.Auth.Application/Usings.cs delete mode 100644 src/FinancialHub/FinancialHub.Auth.Domain/Usings.cs delete mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Entities/UserEntityBuilder.cs delete mode 100644 src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Models/UserModelBuilder.cs delete mode 100644 src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs delete mode 100644 src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs delete mode 100644 src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs delete mode 100644 src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs delete mode 100644 src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs delete mode 100644 src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs rename src/{FinancialHub => api}/.config/dotnet-tools.json (100%) rename src/{FinancialHub => api}/.editorconfig (100%) rename src/{FinancialHub => api}/Dockerfile (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Usings.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Services/SigninService.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Services/SignupService.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Services/TokenService.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Services/UserService.cs (100%) create mode 100644 src/api/FinancialHub.Auth.Application/Usings.cs rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Application/Validators/UserValidator.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Entities/UserEntity.cs (73%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj (73%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Models/CredentialModel.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Models/SigninModel.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Models/SignupModel.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Models/TokenModel.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Domain/Models/UserModel.cs (100%) create mode 100644 src/api/FinancialHub.Auth.Domain/Usings.cs rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs (83%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs (98%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data.Tests/Usings.cs (90%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Data/Usings.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra.Tests/Usings.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/Providers/SigninProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/Providers/SignupProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/Providers/UserProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Infra/Usings.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj (92%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs (97%) rename src/{FinancialHub => api}/FinancialHub.Auth.IntegrationTests/Usings.cs (82%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation.Tests/Usings.cs (65%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation/.editorconfig (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation/Controllers/SigninController.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation/Controllers/SignupController.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation/Controllers/UsersController.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Presentation/Usings.cs (59%) rename src/{FinancialHub => api}/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs (95%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs (89%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj (73%) rename src/{FinancialHub => api}/FinancialHub.Auth.Tests.Common/Usings.cs (56%) rename src/{FinancialHub => api}/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.WebApi/Program.cs (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.WebApi/Properties/launchSettings.json (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.WebApi/appsettings.Development.json (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.WebApi/appsettings.Testing.json (100%) rename src/{FinancialHub => api}/FinancialHub.Auth.WebApi/appsettings.json (100%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Common.Tests}/Builders/Entities/BaseEntityBuilder.cs (86%) create mode 100644 src/api/FinancialHub.Common.Tests/Builders/Models/BaseModelBuilder.cs rename src/{FinancialHub/FinancialHub.Auth.Tests.Commom/FinancialHub.Auth.Tests.Commom.csproj => api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj} (77%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Entities/BaseEntity.cs (73%) create mode 100644 src/api/FinancialHub.Common/FinancialHub.Common.csproj rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Interfaces/Repositories/IBaseRepository.cs (88%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Models/BaseModel.cs (62%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Responses/Errors/BaseErrorResponse.cs (68%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Responses/Errors/NotFoundErrorResponse.cs (77%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Responses/Errors/ValidationErrorResponse.cs (77%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Responses/Errors/ValidationsErrorResponse.cs (55%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Responses/Success/BaseResponse.cs (60%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Responses/Success/ItemResponse.cs (72%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Responses/Success/ListResponse.cs (80%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Responses/Success/PaginatedListResponse.cs (90%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Responses/Success/SaveResponse.cs (72%) create mode 100644 src/api/FinancialHub.Common/Results/Errors/InvalidDataError.cs create mode 100644 src/api/FinancialHub.Common/Results/Errors/NotFoundError.cs rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Results/Errors/ServiceError.cs (62%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Common}/Results/ServiceResult.cs (64%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Core.Domain.Tests}/Builders/Entities/AccountEntityBuilder.cs (90%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Core.Domain.Tests}/Builders/Entities/BalanceEntityBuilder.cs (93%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Core.Domain.Tests}/Builders/Entities/CategoryEntityBuilder.cs (90%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Core.Domain.Tests}/Builders/Entities/TransactionEntityBuilder.cs (95%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Core.Domain.Tests}/Builders/Models/AccountModelBuilder.cs (90%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Core.Domain.Tests}/Builders/Models/BalanceModelBuilder.cs (93%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Core.Domain.Tests}/Builders/Models/CategoryModelBuilder.cs (90%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Core.Domain.Tests}/Builders/Models/TransactionModelBuilder.cs (95%) rename src/{FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj => api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj} (81%) rename src/{FinancialHub/FinancialHub.Domain.Tests => api/FinancialHub.Core.Domain.Tests}/Queries/TransactionQueryTests.cs (95%) create mode 100644 src/api/FinancialHub.Core.Domain.Tests/Usings.cs rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Entities/AccountEntity.cs (77%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Entities/BalanceEntity.cs (81%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Entities/CategoryEntity.cs (77%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Entities/TransactionEntity.cs (87%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Enums/TransactionStatus.cs (76%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Enums/TransactionType.cs (66%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Filters/TransactionFilter.cs (79%) rename src/{FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj => api/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj} (87%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Interfaces/Mappers/IMapperWrapper.cs (77%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Interfaces/Repositories/IAccountsRepository.cs (51%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Interfaces/Repositories/IBalancesRepository.cs (60%) create mode 100644 src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs create mode 100644 src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Interfaces/Services/IAccountBalanceService.cs (59%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Interfaces/Services/IAccountsService.cs (68%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Interfaces/Services/IBalancesService.cs (72%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Interfaces/Services/ICategoriesService.cs (65%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Interfaces/Services/ITransactionBalanceService.cs (72%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Interfaces/Services/ITransactionsService.cs (67%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Models/AccountModel.cs (70%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Models/BalanceModel.cs (81%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Models/CategoryModel.cs (70%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Models/TransactionModel.cs (85%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Queries/TransactionQuery.cs (90%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Resources/FinancialHubConcepts.Designer.cs (95%) rename src/{FinancialHub/FinancialHub.Domain => api/FinancialHub.Core.Domain}/Resources/FinancialHubConcepts.resx (100%) create mode 100644 src/api/FinancialHub.Core.Domain/Usings.cs rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj => api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj} (78%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Accounts/AccountsRepositoryTests.cs (53%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Balances/BalancesRepositoryTests.amount.cs (95%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Balances/BalancesRepositoryTests.create.cs (76%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Balances/BalancesRepositoryTests.cs (71%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Base/BaseRepositoryTests.create.cs (87%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Base/BaseRepositoryTests.cs (87%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Base/BaseRepositoryTests.delete.cs (79%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Base/BaseRepositoryTests.get.cs (90%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Base/BaseRepositoryTests.update.cs (80%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Categories/CategoriesRepositoryTests.cs (54%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Transactions/TransactionsRepositoryTests.create.cs (96%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Transactions/TransactionsRepositoryTests.cs (87%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Transactions/TransactionsRepositoryTests.delete.cs (86%) rename src/{FinancialHub/FinancialHub.Infra.Data.NUnitTests => api/FinancialHub.Core.Infra.Data.NUnitTests}/Repositories/Transactions/TransactionsRepositoryTests.update.cs (94%) create mode 100644 src/api/FinancialHub.Core.Infra.Data.NUnitTests/Usings.cs rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Contexts/FinancialHubContext.cs (80%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Extensions/Configurations/IServiceCollectionExtensions.cs (82%) rename src/{FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj => api/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj} (83%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Mappings/AccountEntityMapping.cs (78%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Mappings/BalanceEntityMapping.cs (87%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Mappings/CategoryEntityMapping.cs (78%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Mappings/TransactionEntityMapping.cs (91%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Repositories/AccountsRepository.cs (53%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Repositories/BalancesRepository.cs (88%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Repositories/BaseRepository.cs (82%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Repositories/CategoriesRepository.cs (54%) rename src/{FinancialHub/FinancialHub.Infra.Data => api/FinancialHub.Core.Infra.Data}/Repositories/TransactionsRepository.cs (79%) create mode 100644 src/api/FinancialHub.Core.Infra.Data/Usings.cs rename src/{FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj => api/FinancialHub.Core.Infra.Migrations/FinancialHub.Core.Infra.Migrations.csproj} (81%) rename src/{FinancialHub/FinancialHub.Infra.Migrations => api/FinancialHub.Core.Infra.Migrations}/Migrations/20220407152032_v0.2.4.Designer.cs (98%) rename src/{FinancialHub/FinancialHub.Infra.Migrations => api/FinancialHub.Core.Infra.Migrations}/Migrations/20220407152032_v0.2.4.cs (97%) rename src/{FinancialHub/FinancialHub.Infra.Migrations => api/FinancialHub.Core.Infra.Migrations}/Migrations/20220520163358_add-balance.Designer.cs (98%) rename src/{FinancialHub/FinancialHub.Infra.Migrations => api/FinancialHub.Core.Infra.Migrations}/Migrations/20220520163358_add-balance.cs (94%) rename src/{FinancialHub/FinancialHub.Infra.Migrations => api/FinancialHub.Core.Infra.Migrations}/Migrations/20220520215117_add-balance-to-transaction.Designer.cs (98%) rename src/{FinancialHub/FinancialHub.Infra.Migrations => api/FinancialHub.Core.Infra.Migrations}/Migrations/20220520215117_add-balance-to-transaction.cs (94%) rename src/{FinancialHub/FinancialHub.Infra.Migrations => api/FinancialHub.Core.Infra.Migrations}/Migrations/20220520215501_add-balance-active.Designer.cs (98%) rename src/{FinancialHub/FinancialHub.Infra.Migrations => api/FinancialHub.Core.Infra.Migrations}/Migrations/20220520215501_add-balance-active.cs (83%) rename src/{FinancialHub/FinancialHub.Infra.Migrations => api/FinancialHub.Core.Infra.Migrations}/Migrations/FinancialHubContextModelSnapshot.cs (98%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj => api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj} (70%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/AccountBalance/AccountBalanceServiceTests.create.cs (87%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/AccountBalance/AccountBalanceServiceTests.cs (79%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/AccountBalance/AccountBalanceServiceTests.delete.cs (96%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Accounts/AccountsServiceTests.create.cs (91%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Accounts/AccountsServiceTests.cs (71%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Accounts/AccountsServiceTests.delete.cs (88%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Accounts/AccountsServiceTests.get.cs (83%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Accounts/AccountsServiceTests.update.cs (94%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Balances/BalancesServiceTests.create.cs (92%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Balances/BalancesServiceTests.cs (78%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Balances/BalancesServiceTests.delete.cs (87%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Balances/BalancesServiceTests.get.cs (85%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Balances/BalancesServiceTests.update.cs (91%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Balances/BalancesServiceTests.updateamount.cs (90%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Categories/CategoriesServiceTests.create.cs (91%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Categories/CategoriesServiceTests.cs (72%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Categories/CategoriesServiceTests.delete.cs (89%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Categories/CategoriesServiceTests.get.cs (83%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Categories/CategoriesServiceTests.update.cs (94%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/TransactionBalance/BaseTransactionBalanceTests.cs (78%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/TransactionBalance/TransactionBalanceTests.create.cs (95%) create mode 100644 src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/TransactionBalance/TransactionBalanceTests.delete.cs (95%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/TransactionBalance/TransactionBalanceTests.update.cs (94%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs (97%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Transactions/TransactionsServiceTests.create.cs (90%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Transactions/TransactionsServiceTests.cs (80%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Transactions/TransactionsServiceTests.delete.cs (95%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Transactions/TransactionsServiceTests.get.cs (81%) rename src/{FinancialHub/FinancialHub.Services.NUnitTests => api/FinancialHub.Core.Services.NUnitTests}/Services/Transactions/TransactionsServiceTests.update.cs (94%) create mode 100644 src/api/FinancialHub.Core.Services.NUnitTests/Usings.cs rename src/{FinancialHub/FinancialHub.Services => api/FinancialHub.Core.Services}/Extensions/Configurations/IServiceCollectionExtensions.cs (76%) rename src/{FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj => api/FinancialHub.Core.Services/FinancialHub.Core.Services.csproj} (72%) rename src/{FinancialHub/FinancialHub.Services => api/FinancialHub.Core.Services}/Mappers/FinancialHubAutoMapperProfile.cs (75%) rename src/{FinancialHub/FinancialHub.Services => api/FinancialHub.Core.Services}/Mappers/FinancialHubMapperWrapper.cs (82%) rename src/{FinancialHub/FinancialHub.Services => api/FinancialHub.Core.Services}/Services/AccountBalanceService.cs (88%) rename src/{FinancialHub/FinancialHub.Services => api/FinancialHub.Core.Services}/Services/AccountsService.cs (84%) rename src/{FinancialHub/FinancialHub.Services => api/FinancialHub.Core.Services}/Services/BalancesService.cs (91%) rename src/{FinancialHub/FinancialHub.Services => api/FinancialHub.Core.Services}/Services/CategoriesService.cs (83%) rename src/{FinancialHub/FinancialHub.Services => api/FinancialHub.Core.Services}/Services/TransactionBalanceService.cs (93%) rename src/{FinancialHub/FinancialHub.Services => api/FinancialHub.Core.Services}/Services/TransactionsService.cs (89%) create mode 100644 src/api/FinancialHub.Core.Services/Usings.cs rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs (94%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs (95%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs (94%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs (93%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs (96%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs (96%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs (92%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs (98%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj (82%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs (97%) rename src/{FinancialHub => api}/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs (92%) create mode 100644 src/api/FinancialHub.IntegrationTests/Usings.cs rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs (82%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs (80%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs (78%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs (77%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs (83%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs (84%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs (76%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs (74%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs (85%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs (85%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs (77%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs (78%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs (77%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs (86%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs (86%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs (82%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs (79%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs (80%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs (86%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj (78%) create mode 100644 src/api/FinancialHub.WebApi.NUnitTests/Usings.cs rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs (95%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs (95%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs (95%) rename src/{FinancialHub => api}/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs (96%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Controllers/AccountsController.cs (92%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Controllers/BalancesController.cs (87%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Controllers/Base/BaseController.cs (82%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Controllers/CategoriesController.cs (90%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Controllers/TransactionsController.cs (92%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs (92%) rename src/{FinancialHub => api}/FinancialHub.WebApi/FinancialHub.WebApi.csproj (85%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Program.cs (100%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Properties/launchSettings.json (100%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs (100%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Resources/ErrorMessages.resx (100%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Startup.cs (90%) create mode 100644 src/api/FinancialHub.WebApi/Usings.cs rename src/{FinancialHub => api}/FinancialHub.WebApi/Validators/AccountValidator.cs (88%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Validators/BalanceValidator.cs (87%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Validators/CategoryValidator.cs (88%) rename src/{FinancialHub => api}/FinancialHub.WebApi/Validators/TransactionValidator.cs (90%) rename src/{FinancialHub => api}/FinancialHub.WebApi/appsettings.Development.json (100%) rename src/{FinancialHub => api}/FinancialHub.WebApi/appsettings.json (100%) rename src/{FinancialHub => api}/FinancialHub.sln (73%) rename src/{FinancialHub => api}/docker-compose.yml (100%) rename {docs => src}/database/financial-hub_DDL.sql (100%) diff --git a/.github/workflows/branch_main_ci.yml b/.github/workflows/branch_main_ci.yml index ee4ad20..9e4219c 100644 --- a/.github/workflows/branch_main_ci.yml +++ b/.github/workflows/branch_main_ci.yml @@ -5,14 +5,14 @@ on: branches: - 'main' paths: - - 'src/FinancialHub/*' - - 'src/FinancialHub/**' + - 'src/api/*' + - 'src/api/**' pull_request: branches: - 'main' paths: - - 'src/FinancialHub/*' - - 'src/FinancialHub/**' + - 'src/api/*' + - 'src/api/**' permissions: checks: write @@ -22,5 +22,5 @@ jobs: tests: uses: ./.github/workflows/tests_workflow.yml with: - dir: ./src/FinancialHub/ + dir: ./src/api/ secrets: inherit \ No newline at end of file diff --git a/.github/workflows/branch_release_ci.yml b/.github/workflows/branch_release_ci.yml index ed4c55d..2fd81e1 100644 --- a/.github/workflows/branch_release_ci.yml +++ b/.github/workflows/branch_release_ci.yml @@ -5,8 +5,8 @@ on: branches: - 'release/**' paths: - - 'src/FinancialHub/*' - - 'src/FinancialHub/**' + - 'src/api/*' + - 'src/api/**' permissions: checks: write @@ -16,5 +16,5 @@ jobs: tests: uses: ./.github/workflows/tests_workflow.yml with: - dir: ./src/FinancialHub/ + dir: ./src/api/ secrets: inherit \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs deleted file mode 100644 index 85fccc9..0000000 --- a/src/FinancialHub/FinancialHub.Auth.Application/Usings.cs +++ /dev/null @@ -1,6 +0,0 @@ -global using FinancialHub.Domain.Results; -global using FinancialHub.Domain.Results.Errors; - -global using FinancialHub.Auth.Domain.Models; -global using FinancialHub.Auth.Domain.Interfaces.Services; -global using FinancialHub.Auth.Domain.Interfaces.Providers; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Usings.cs b/src/FinancialHub/FinancialHub.Auth.Domain/Usings.cs deleted file mode 100644 index 208bdef..0000000 --- a/src/FinancialHub/FinancialHub.Auth.Domain/Usings.cs +++ /dev/null @@ -1,3 +0,0 @@ -global using FinancialHub.Domain.Model; -global using FinancialHub.Domain.Results; -global using FinancialHub.Domain.Entities; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Entities/UserEntityBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Entities/UserEntityBuilder.cs deleted file mode 100644 index 8270af1..0000000 --- a/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Entities/UserEntityBuilder.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Bogus; -using FinancialHub.Auth.Domain.Entities; - -namespace FinancialHub.Auth.Tests.Commom.Builders.Entities -{ - public class UserEntityBuilder : Faker - { - public UserEntityBuilder() - { - this.RuleFor(x => x.FirstName, x => x.Person.FirstName); - this.RuleFor(x => x.LastName, x => x.Person.LastName); - this.RuleFor(x => x.BirthDate, x => x.Person.DateOfBirth); - this.RuleFor(x => x.Email, x => x.Person.Email); - this.RuleFor(x => x.Password, x => x.Random.AlphaNumeric(12)); - } - - public UserEntityBuilder WithName(string name) - { - this.RuleFor(x => x.FirstName, name); - return this; - } - - public UserEntityBuilder WithLastName(string name) - { - this.RuleFor(x => x.LastName, name); - return this; - } - - public UserEntityBuilder WithBirthDate(DateTime date) - { - this.RuleFor(x => x.BirthDate, date); - return this; - } - - public UserEntityBuilder WithEmail(string email) - { - this.RuleFor(x => x.Email, email); - return this; - } - - public UserEntityBuilder WithPassword(string password) - { - this.RuleFor(x => x.Password, password); - return this; - } - } -} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Models/UserModelBuilder.cs b/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Models/UserModelBuilder.cs deleted file mode 100644 index 3ab4c5c..0000000 --- a/src/FinancialHub/FinancialHub.Auth.Tests.Commom/Builders/Models/UserModelBuilder.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Bogus; -using FinancialHub.Auth.Domain.Models; - -namespace FinancialHub.Auth.Tests.Commom.Builders.Entities -{ - public class UserModelBuilder : Faker - { - public UserModelBuilder() - { - this.RuleFor(x => x.FirstName, x => x.Person.FirstName); - this.RuleFor(x => x.LastName, x => x.Person.LastName); - this.RuleFor(x => x.BirthDate, x => x.Person.DateOfBirth); - this.RuleFor(x => x.Email, x => x.Person.Email); - this.RuleFor(x => x.Password, x => x.Random.AlphaNumeric(12)); - } - - public UserModelBuilder WithName(string name) - { - this.RuleFor(x => x.FirstName, name); - return this; - } - - public UserModelBuilder WithLastName(string name) - { - this.RuleFor(x => x.LastName, name); - return this; - } - - public UserModelBuilder WithBirthDate(DateTime date) - { - this.RuleFor(x => x.BirthDate, date); - return this; - } - - public UserModelBuilder WithEmail(string email) - { - this.RuleFor(x => x.Email, email); - return this; - } - - public UserModelBuilder WithPassword(string password) - { - this.RuleFor(x => x.Password, password); - return this; - } - } -} diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs b/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs deleted file mode 100644 index e2d74a0..0000000 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BaseModelBuilder.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Bogus; -using FinancialHub.Domain.Model; -using System; - -namespace FinancialHub.Domain.Tests.Builders.Models -{ - public class BaseModelBuilder : Faker - where T : BaseModel - { - public BaseModelBuilder() - { - this.RuleFor(x => x.Id,y => y.System.Random.Guid()); - } - - public BaseModelBuilder WithId(Guid guid) - { - this.RuleFor(x => x.Id, guid); - return this; - } - } -} diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs deleted file mode 100644 index 2aeee11..0000000 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ICategoriesRepository.cs +++ /dev/null @@ -1,8 +0,0 @@ -using FinancialHub.Domain.Entities; - -namespace FinancialHub.Domain.Interfaces.Repositories -{ - public interface ICategoriesRepository : IBaseRepository - { - } -} diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs b/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs deleted file mode 100644 index 932a798..0000000 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/ITransactionsRepository.cs +++ /dev/null @@ -1,8 +0,0 @@ -using FinancialHub.Domain.Entities; - -namespace FinancialHub.Domain.Interfaces.Repositories -{ - public interface ITransactionsRepository : IBaseRepository - { - } -} diff --git a/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs b/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs deleted file mode 100644 index e585406..0000000 --- a/src/FinancialHub/FinancialHub.Domain/Results/Errors/InvalidDataError.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace FinancialHub.Domain.Results.Errors -{ - public class InvalidDataError : ServiceError - { - private const int code = 400; - public InvalidDataError(string message, Exception error = null) : base(code, message, error) - { - } - } -} diff --git a/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs b/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs deleted file mode 100644 index a2093e4..0000000 --- a/src/FinancialHub/FinancialHub.Domain/Results/Errors/NotFoundError.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace FinancialHub.Domain.Results.Errors -{ - public class NotFoundError : ServiceError - { - private const int code = 404; - public NotFoundError(string message, Exception error = null) : base(code, message, error) - { - } - } -} diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs b/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs deleted file mode 100644 index fb9ac1a..0000000 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs +++ /dev/null @@ -1,9 +0,0 @@ -using FinancialHub.Services.NUnitTests.Services.TransactionBalance; - -namespace FinancialHub.Services.NUnitTests.Services -{ - public partial class TransactionBalanceTests : BaseTransactionBalanceTests - { - - } -} diff --git a/src/FinancialHub/.config/dotnet-tools.json b/src/api/.config/dotnet-tools.json similarity index 100% rename from src/FinancialHub/.config/dotnet-tools.json rename to src/api/.config/dotnet-tools.json diff --git a/src/FinancialHub/.editorconfig b/src/api/.editorconfig similarity index 100% rename from src/FinancialHub/.editorconfig rename to src/api/.editorconfig diff --git a/src/FinancialHub/Dockerfile b/src/api/Dockerfile similarity index 100% rename from src/FinancialHub/Dockerfile rename to src/api/Dockerfile diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj b/src/api/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj rename to src/api/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs b/src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs rename to src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs b/src/api/FinancialHub.Auth.Application.Tests/Usings.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Usings.cs rename to src/api/FinancialHub.Auth.Application.Tests/Usings.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs b/src/api/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs rename to src/api/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs b/src/api/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs rename to src/api/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs b/src/api/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs rename to src/api/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs b/src/api/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs rename to src/api/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs b/src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs rename to src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs b/src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs rename to src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj b/src/api/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj rename to src/api/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Services/SigninService.cs b/src/api/FinancialHub.Auth.Application/Services/SigninService.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Services/SigninService.cs rename to src/api/FinancialHub.Auth.Application/Services/SigninService.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Services/SignupService.cs b/src/api/FinancialHub.Auth.Application/Services/SignupService.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Services/SignupService.cs rename to src/api/FinancialHub.Auth.Application/Services/SignupService.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Services/TokenService.cs b/src/api/FinancialHub.Auth.Application/Services/TokenService.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Services/TokenService.cs rename to src/api/FinancialHub.Auth.Application/Services/TokenService.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Services/UserService.cs b/src/api/FinancialHub.Auth.Application/Services/UserService.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Services/UserService.cs rename to src/api/FinancialHub.Auth.Application/Services/UserService.cs diff --git a/src/api/FinancialHub.Auth.Application/Usings.cs b/src/api/FinancialHub.Auth.Application/Usings.cs new file mode 100644 index 0000000..218d136 --- /dev/null +++ b/src/api/FinancialHub.Auth.Application/Usings.cs @@ -0,0 +1,6 @@ +global using FinancialHub.Auth.Domain.Models; +global using FinancialHub.Auth.Domain.Interfaces.Services; +global using FinancialHub.Auth.Domain.Interfaces.Providers; + +global using FinancialHub.Common.Results; +global using FinancialHub.Common.Results.Errors; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs b/src/api/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs rename to src/api/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs b/src/api/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs rename to src/api/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs b/src/api/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs rename to src/api/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Application/Validators/UserValidator.cs b/src/api/FinancialHub.Auth.Application/Validators/UserValidator.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Application/Validators/UserValidator.cs rename to src/api/FinancialHub.Auth.Application/Validators/UserValidator.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs b/src/api/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs rename to src/api/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Entities/UserEntity.cs b/src/api/FinancialHub.Auth.Domain/Entities/UserEntity.cs similarity index 73% rename from src/FinancialHub/FinancialHub.Auth.Domain/Entities/UserEntity.cs rename to src/api/FinancialHub.Auth.Domain/Entities/UserEntity.cs index 025babe..fad1aec 100644 --- a/src/FinancialHub/FinancialHub.Auth.Domain/Entities/UserEntity.cs +++ b/src/api/FinancialHub.Auth.Domain/Entities/UserEntity.cs @@ -1,6 +1,4 @@ -using FinancialHub.Domain.Entities; - -namespace FinancialHub.Auth.Domain.Entities +namespace FinancialHub.Auth.Domain.Entities { public class UserEntity : BaseEntity { diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj b/src/api/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj similarity index 73% rename from src/FinancialHub/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj rename to src/api/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj index 7247294..9f8d43d 100644 --- a/src/FinancialHub/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj +++ b/src/api/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs b/src/api/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs rename to src/api/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/CredentialModel.cs b/src/api/FinancialHub.Auth.Domain/Models/CredentialModel.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Models/CredentialModel.cs rename to src/api/FinancialHub.Auth.Domain/Models/CredentialModel.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/SigninModel.cs b/src/api/FinancialHub.Auth.Domain/Models/SigninModel.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Models/SigninModel.cs rename to src/api/FinancialHub.Auth.Domain/Models/SigninModel.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/SignupModel.cs b/src/api/FinancialHub.Auth.Domain/Models/SignupModel.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Models/SignupModel.cs rename to src/api/FinancialHub.Auth.Domain/Models/SignupModel.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/TokenModel.cs b/src/api/FinancialHub.Auth.Domain/Models/TokenModel.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Models/TokenModel.cs rename to src/api/FinancialHub.Auth.Domain/Models/TokenModel.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Domain/Models/UserModel.cs b/src/api/FinancialHub.Auth.Domain/Models/UserModel.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Domain/Models/UserModel.cs rename to src/api/FinancialHub.Auth.Domain/Models/UserModel.cs diff --git a/src/api/FinancialHub.Auth.Domain/Usings.cs b/src/api/FinancialHub.Auth.Domain/Usings.cs new file mode 100644 index 0000000..8c5e002 --- /dev/null +++ b/src/api/FinancialHub.Auth.Domain/Usings.cs @@ -0,0 +1,3 @@ +global using FinancialHub.Common.Entities; +global using FinancialHub.Common.Results; +global using FinancialHub.Common.Models; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs similarity index 83% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs index a70ca0e..ccba77b 100644 --- a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs +++ b/src/api/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs @@ -1,6 +1,4 @@ -using FinancialHub.Domain.Entities; - -namespace FinancialHub.Auth.Infra.Data.Tests.Assertions +namespace FinancialHub.Auth.Infra.Data.Tests.Assertions { internal static class DbContextAssert { diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj b/src/api/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj rename to src/api/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs index 6eef1e7..a6c8e32 100644 --- a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs +++ b/src/api/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs @@ -1,6 +1,5 @@ using FinancialHub.Auth.Infra.Data.Contexts; using Microsoft.Data.Sqlite; -using FinancialHub.Domain.Entities; using System.Collections; namespace FinancialHub.Auth.Infra.Data.Tests.Fixtures diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Usings.cs b/src/api/FinancialHub.Auth.Infra.Data.Tests/Usings.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Usings.cs rename to src/api/FinancialHub.Auth.Infra.Data.Tests/Usings.cs index 1814656..5340753 100644 --- a/src/FinancialHub/FinancialHub.Auth.Infra.Data.Tests/Usings.cs +++ b/src/api/FinancialHub.Auth.Infra.Data.Tests/Usings.cs @@ -1,10 +1,11 @@ global using NUnit.Framework; global using Microsoft.EntityFrameworkCore; +global using FinancialHub.Common.Entities; + global using FinancialHub.Auth.Tests.Common.Assertions; global using FinancialHub.Auth.Tests.Common.Builders.Entities; -global using FinancialHub.Auth.Domain.Entities; global using FinancialHub.Auth.Domain.Interfaces.Repositories; global using FinancialHub.Auth.Infra.Data.Repositories; diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs b/src/api/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs rename to src/api/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj b/src/api/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj rename to src/api/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs b/src/api/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs rename to src/api/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs b/src/api/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs rename to src/api/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs b/src/api/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs rename to src/api/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs b/src/api/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs rename to src/api/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs b/src/api/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs rename to src/api/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs b/src/api/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs rename to src/api/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs b/src/api/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs rename to src/api/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs b/src/api/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs rename to src/api/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs b/src/api/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs rename to src/api/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Data/Usings.cs b/src/api/FinancialHub.Auth.Infra.Data/Usings.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Data/Usings.cs rename to src/api/FinancialHub.Auth.Infra.Data/Usings.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj b/src/api/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj rename to src/api/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj b/src/api/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj rename to src/api/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs b/src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra.Tests/Usings.cs b/src/api/FinancialHub.Auth.Infra.Tests/Usings.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra.Tests/Usings.cs rename to src/api/FinancialHub.Auth.Infra.Tests/Usings.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj b/src/api/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj rename to src/api/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs b/src/api/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs rename to src/api/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs b/src/api/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs rename to src/api/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs b/src/api/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs rename to src/api/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs b/src/api/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs rename to src/api/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Providers/SigninProvider.cs b/src/api/FinancialHub.Auth.Infra/Providers/SigninProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/Providers/SigninProvider.cs rename to src/api/FinancialHub.Auth.Infra/Providers/SigninProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Providers/SignupProvider.cs b/src/api/FinancialHub.Auth.Infra/Providers/SignupProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/Providers/SignupProvider.cs rename to src/api/FinancialHub.Auth.Infra/Providers/SignupProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Providers/UserProvider.cs b/src/api/FinancialHub.Auth.Infra/Providers/UserProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/Providers/UserProvider.cs rename to src/api/FinancialHub.Auth.Infra/Providers/UserProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Infra/Usings.cs b/src/api/FinancialHub.Auth.Infra/Usings.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Infra/Usings.cs rename to src/api/FinancialHub.Auth.Infra/Usings.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs b/src/api/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs b/src/api/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs b/src/api/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs b/src/api/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs b/src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs b/src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs b/src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs b/src/api/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj b/src/api/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj similarity index 92% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj rename to src/api/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj index 7fb5a09..b263a00 100644 --- a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj +++ b/src/api/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj @@ -21,7 +21,6 @@ - diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs b/src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs b/src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs b/src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs similarity index 97% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs index 5da8aaf..cc71fff 100644 --- a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs +++ b/src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs @@ -1,5 +1,5 @@ using FinancialHub.Auth.Infra.Data.Contexts; -using FinancialHub.Domain.Entities; +using FinancialHub.Common.Entities; using Microsoft.Extensions.DependencyInjection; namespace FinancialHub.Auth.IntegrationTests.Setup diff --git a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Usings.cs b/src/api/FinancialHub.Auth.IntegrationTests/Usings.cs similarity index 82% rename from src/FinancialHub/FinancialHub.Auth.IntegrationTests/Usings.cs rename to src/api/FinancialHub.Auth.IntegrationTests/Usings.cs index 107b7c0..901f182 100644 --- a/src/FinancialHub/FinancialHub.Auth.IntegrationTests/Usings.cs +++ b/src/api/FinancialHub.Auth.IntegrationTests/Usings.cs @@ -6,8 +6,8 @@ global using FinancialHub.Auth.IntegrationTests.Setup; global using FinancialHub.Auth.IntegrationTests.Extensions; -global using FinancialHub.Domain.Responses.Errors; -global using FinancialHub.Domain.Responses.Success; +global using FinancialHub.Common.Responses.Errors; +global using FinancialHub.Common.Responses.Success; global using FinancialHub.Auth.Domain.Entities; global using FinancialHub.Auth.Domain.Models; diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj b/src/api/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj rename to src/api/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Usings.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Usings.cs similarity index 65% rename from src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Usings.cs rename to src/api/FinancialHub.Auth.Presentation.Tests/Usings.cs index 42ed47c..b1df58a 100644 --- a/src/FinancialHub/FinancialHub.Auth.Presentation.Tests/Usings.cs +++ b/src/api/FinancialHub.Auth.Presentation.Tests/Usings.cs @@ -6,14 +6,14 @@ global using FinancialHub.Auth.Tests.Common.Assertions; global using FinancialHub.Auth.Tests.Common.Builders.Models; -global using FinancialHub.Auth.Domain.Models; +global using FinancialHub.Common.Responses.Success; +global using FinancialHub.Common.Responses.Errors; -global using FinancialHub.Auth.Domain.Interfaces.Services; +global using FinancialHub.Common.Results; +global using FinancialHub.Common.Results.Errors; -global using FinancialHub.Domain.Results; -global using FinancialHub.Domain.Results.Errors; +global using FinancialHub.Auth.Domain.Models; -global using FinancialHub.Domain.Responses.Success; -global using FinancialHub.Domain.Responses.Errors; +global using FinancialHub.Auth.Domain.Interfaces.Services; global using FinancialHub.Auth.Presentation.Controllers; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/.editorconfig b/src/api/FinancialHub.Auth.Presentation/.editorconfig similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation/.editorconfig rename to src/api/FinancialHub.Auth.Presentation/.editorconfig diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SigninController.cs b/src/api/FinancialHub.Auth.Presentation/Controllers/SigninController.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SigninController.cs rename to src/api/FinancialHub.Auth.Presentation/Controllers/SigninController.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SignupController.cs b/src/api/FinancialHub.Auth.Presentation/Controllers/SignupController.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/SignupController.cs rename to src/api/FinancialHub.Auth.Presentation/Controllers/SignupController.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/UsersController.cs b/src/api/FinancialHub.Auth.Presentation/Controllers/UsersController.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation/Controllers/UsersController.cs rename to src/api/FinancialHub.Auth.Presentation/Controllers/UsersController.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs b/src/api/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs rename to src/api/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj b/src/api/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj rename to src/api/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Presentation/Usings.cs b/src/api/FinancialHub.Auth.Presentation/Usings.cs similarity index 59% rename from src/FinancialHub/FinancialHub.Auth.Presentation/Usings.cs rename to src/api/FinancialHub.Auth.Presentation/Usings.cs index 0b4932f..4cf0875 100644 --- a/src/FinancialHub/FinancialHub.Auth.Presentation/Usings.cs +++ b/src/api/FinancialHub.Auth.Presentation/Usings.cs @@ -1,8 +1,8 @@ global using Microsoft.AspNetCore.Mvc; -global using FinancialHub.Auth.Domain.Interfaces.Services; - global using FinancialHub.Auth.Domain.Models; -global using FinancialHub.Domain.Responses.Errors; -global using FinancialHub.Domain.Responses.Success; \ No newline at end of file +global using FinancialHub.Auth.Domain.Interfaces.Services; + +global using FinancialHub.Common.Responses.Errors; +global using FinancialHub.Common.Responses.Success; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj b/src/api/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj rename to src/api/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs b/src/api/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs rename to src/api/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs b/src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs rename to src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx b/src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx rename to src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx diff --git a/src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx b/src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx rename to src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs b/src/api/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs rename to src/api/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs index 87d1493..6c7fcbc 100644 --- a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs +++ b/src/api/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs @@ -1,4 +1,6 @@ -namespace FinancialHub.Auth.Tests.Common.Assertions +using NUnit.Framework; + +namespace FinancialHub.Auth.Tests.Common.Assertions { public static class EntityAssert { diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs b/src/api/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs rename to src/api/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs b/src/api/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs similarity index 89% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs rename to src/api/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs index fb4f26f..9938ff9 100644 --- a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs +++ b/src/api/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs @@ -1,5 +1,5 @@ -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; +using FinancialHub.Common.Responses.Errors; +using FinancialHub.Common.Responses.Success; namespace FinancialHub.Auth.Tests.Common.Assertions { diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs b/src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs rename to src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs b/src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs rename to src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs b/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs rename to src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs b/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs rename to src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs b/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs rename to src/api/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs b/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs rename to src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs b/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs rename to src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj b/src/api/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj similarity index 73% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj rename to src/api/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj index f6ffc06..24c14b3 100644 --- a/src/FinancialHub/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj +++ b/src/api/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj @@ -8,11 +8,12 @@ + - + diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Usings.cs b/src/api/FinancialHub.Auth.Tests.Common/Usings.cs similarity index 56% rename from src/FinancialHub/FinancialHub.Auth.Tests.Common/Usings.cs rename to src/api/FinancialHub.Auth.Tests.Common/Usings.cs index 53f3116..bc9af06 100644 --- a/src/FinancialHub/FinancialHub.Auth.Tests.Common/Usings.cs +++ b/src/api/FinancialHub.Auth.Tests.Common/Usings.cs @@ -1,9 +1,8 @@ global using NUnit.Framework; global using AutoBogus; - global using FinancialHub.Auth.Domain.Entities; -global using FinancialHub.Domain.Tests.Builders.Entities; +global using FinancialHub.Common.Tests.Builders.Entities; global using FinancialHub.Auth.Domain.Models; -global using FinancialHub.Domain.Tests.Builders.Models; \ No newline at end of file +global using FinancialHub.Common.Tests.Builders.Models; diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj b/src/api/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj rename to src/api/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs b/src/api/FinancialHub.Auth.WebApi/Program.cs similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.WebApi/Program.cs rename to src/api/FinancialHub.Auth.WebApi/Program.cs diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/Properties/launchSettings.json b/src/api/FinancialHub.Auth.WebApi/Properties/launchSettings.json similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.WebApi/Properties/launchSettings.json rename to src/api/FinancialHub.Auth.WebApi/Properties/launchSettings.json diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Development.json b/src/api/FinancialHub.Auth.WebApi/appsettings.Development.json similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Development.json rename to src/api/FinancialHub.Auth.WebApi/appsettings.Development.json diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Testing.json b/src/api/FinancialHub.Auth.WebApi/appsettings.Testing.json similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.Testing.json rename to src/api/FinancialHub.Auth.WebApi/appsettings.Testing.json diff --git a/src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.json b/src/api/FinancialHub.Auth.WebApi/appsettings.json similarity index 100% rename from src/FinancialHub/FinancialHub.Auth.WebApi/appsettings.json rename to src/api/FinancialHub.Auth.WebApi/appsettings.json diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs b/src/api/FinancialHub.Common.Tests/Builders/Entities/BaseEntityBuilder.cs similarity index 86% rename from src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs rename to src/api/FinancialHub.Common.Tests/Builders/Entities/BaseEntityBuilder.cs index fa01e78..78e40ae 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BaseEntityBuilder.cs +++ b/src/api/FinancialHub.Common.Tests/Builders/Entities/BaseEntityBuilder.cs @@ -1,13 +1,12 @@ using Bogus; -using System; -using FinancialHub.Domain.Entities; +using FinancialHub.Common.Entities; -namespace FinancialHub.Domain.Tests.Builders.Entities +namespace FinancialHub.Common.Tests.Builders.Entities { public abstract class BaseEntityBuilder : Faker where T : BaseEntity { - public BaseEntityBuilder() + protected BaseEntityBuilder() { this.RuleFor(x => x.Id, fake => fake.Random.Guid()); this.RuleFor(x => x.CreationTime, fake => DateTimeOffset.Now); diff --git a/src/api/FinancialHub.Common.Tests/Builders/Models/BaseModelBuilder.cs b/src/api/FinancialHub.Common.Tests/Builders/Models/BaseModelBuilder.cs new file mode 100644 index 0000000..7860072 --- /dev/null +++ b/src/api/FinancialHub.Common.Tests/Builders/Models/BaseModelBuilder.cs @@ -0,0 +1,20 @@ +using Bogus; +using FinancialHub.Common.Models; + +namespace FinancialHub.Common.Tests.Builders.Models +{ + public abstract class BaseModelBuilder : Faker + where T : BaseModel + { + protected BaseModelBuilder() + { + this.RuleFor(x => x.Id, y => y.System.Random.Guid()); + } + + public BaseModelBuilder WithId(Guid guid) + { + this.RuleFor(x => x.Id, guid); + return this; + } + } +} diff --git a/src/FinancialHub/FinancialHub.Auth.Tests.Commom/FinancialHub.Auth.Tests.Commom.csproj b/src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj similarity index 77% rename from src/FinancialHub/FinancialHub.Auth.Tests.Commom/FinancialHub.Auth.Tests.Commom.csproj rename to src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj index 1ffdcda..9700881 100644 --- a/src/FinancialHub/FinancialHub.Auth.Tests.Commom/FinancialHub.Auth.Tests.Commom.csproj +++ b/src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs b/src/api/FinancialHub.Common/Entities/BaseEntity.cs similarity index 73% rename from src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs rename to src/api/FinancialHub.Common/Entities/BaseEntity.cs index 8962c0c..37d7e6b 100644 --- a/src/FinancialHub/FinancialHub.Domain/Entities/BaseEntity.cs +++ b/src/api/FinancialHub.Common/Entities/BaseEntity.cs @@ -1,7 +1,6 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; -namespace FinancialHub.Domain.Entities +namespace FinancialHub.Common.Entities { public abstract class BaseEntity { diff --git a/src/api/FinancialHub.Common/FinancialHub.Common.csproj b/src/api/FinancialHub.Common/FinancialHub.Common.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/src/api/FinancialHub.Common/FinancialHub.Common.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs b/src/api/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs similarity index 88% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs rename to src/api/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs index aebca4d..407410d 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBaseRepository.cs +++ b/src/api/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs @@ -1,9 +1,6 @@ -using System; -using System.Threading.Tasks; -using System.Collections.Generic; -using FinancialHub.Domain.Entities; +using FinancialHub.Common.Entities; -namespace FinancialHub.Domain.Interfaces.Repositories +namespace FinancialHub.Common.Interfaces.Repositories { /// /// Base repository with basic CRUD methods diff --git a/src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs b/src/api/FinancialHub.Common/Models/BaseModel.cs similarity index 62% rename from src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs rename to src/api/FinancialHub.Common/Models/BaseModel.cs index 4277955..e15488f 100644 --- a/src/FinancialHub/FinancialHub.Domain/Models/BaseModel.cs +++ b/src/api/FinancialHub.Common/Models/BaseModel.cs @@ -1,6 +1,4 @@ -using System; - -namespace FinancialHub.Domain.Model +namespace FinancialHub.Common.Models { public abstract class BaseModel { diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs b/src/api/FinancialHub.Common/Responses/Errors/BaseErrorResponse.cs similarity index 68% rename from src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs rename to src/api/FinancialHub.Common/Responses/Errors/BaseErrorResponse.cs index 9dbe61e..450edef 100644 --- a/src/FinancialHub/FinancialHub.Domain/Responses/Errors/BaseErrorResponse.cs +++ b/src/api/FinancialHub.Common/Responses/Errors/BaseErrorResponse.cs @@ -1,11 +1,11 @@ -namespace FinancialHub.Domain.Responses.Errors +namespace FinancialHub.Common.Responses.Errors { public abstract class BaseErrorResponse { public int Code { get; protected set; } public string Message { get; protected set; } - public BaseErrorResponse(int code, string message) + protected BaseErrorResponse(int code, string message) { Code = code; Message = message; diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs b/src/api/FinancialHub.Common/Responses/Errors/NotFoundErrorResponse.cs similarity index 77% rename from src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs rename to src/api/FinancialHub.Common/Responses/Errors/NotFoundErrorResponse.cs index ffb1a2e..436249e 100644 --- a/src/FinancialHub/FinancialHub.Domain/Responses/Errors/NotFoundErrorResponse.cs +++ b/src/api/FinancialHub.Common/Responses/Errors/NotFoundErrorResponse.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Domain.Responses.Errors +namespace FinancialHub.Common.Responses.Errors { public class NotFoundErrorResponse : BaseErrorResponse { diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs b/src/api/FinancialHub.Common/Responses/Errors/ValidationErrorResponse.cs similarity index 77% rename from src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs rename to src/api/FinancialHub.Common/Responses/Errors/ValidationErrorResponse.cs index 495405d..08cefe3 100644 --- a/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationErrorResponse.cs +++ b/src/api/FinancialHub.Common/Responses/Errors/ValidationErrorResponse.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Domain.Responses.Errors +namespace FinancialHub.Common.Responses.Errors { public class ValidationErrorResponse : BaseErrorResponse { diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationsErrorResponse.cs b/src/api/FinancialHub.Common/Responses/Errors/ValidationsErrorResponse.cs similarity index 55% rename from src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationsErrorResponse.cs rename to src/api/FinancialHub.Common/Responses/Errors/ValidationsErrorResponse.cs index 4e61533..ac215e3 100644 --- a/src/FinancialHub/FinancialHub.Domain/Responses/Errors/ValidationsErrorResponse.cs +++ b/src/api/FinancialHub.Common/Responses/Errors/ValidationsErrorResponse.cs @@ -1,12 +1,10 @@ -using System.Collections.Generic; - -namespace FinancialHub.Domain.Responses.Errors +namespace FinancialHub.Common.Responses.Errors { public class ValidationsErrorResponse : BaseErrorResponse { - public Dictionary Errors { get; set; } + public Dictionary? Errors { get; set; } - public ValidationsErrorResponse(string message, Dictionary errors = null) + public ValidationsErrorResponse(string message, Dictionary? errors = null) : base(400, message) { this.Errors = errors; diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs b/src/api/FinancialHub.Common/Responses/Success/BaseResponse.cs similarity index 60% rename from src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs rename to src/api/FinancialHub.Common/Responses/Success/BaseResponse.cs index 71caed6..d4924aa 100644 --- a/src/FinancialHub/FinancialHub.Domain/Responses/Success/BaseResponse.cs +++ b/src/api/FinancialHub.Common/Responses/Success/BaseResponse.cs @@ -1,9 +1,9 @@ -namespace FinancialHub.Domain.Responses.Success +namespace FinancialHub.Common.Responses.Success { public abstract class BaseResponse { public T Data { get; } - public BaseResponse(T data) + protected BaseResponse(T data) { this.Data = data; } diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Success/ItemResponse.cs b/src/api/FinancialHub.Common/Responses/Success/ItemResponse.cs similarity index 72% rename from src/FinancialHub/FinancialHub.Domain/Responses/Success/ItemResponse.cs rename to src/api/FinancialHub.Common/Responses/Success/ItemResponse.cs index 263ec19..8f577e0 100644 --- a/src/FinancialHub/FinancialHub.Domain/Responses/Success/ItemResponse.cs +++ b/src/api/FinancialHub.Common/Responses/Success/ItemResponse.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Domain.Responses.Success +namespace FinancialHub.Common.Responses.Success { public class ItemResponse : BaseResponse { diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs b/src/api/FinancialHub.Common/Responses/Success/ListResponse.cs similarity index 80% rename from src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs rename to src/api/FinancialHub.Common/Responses/Success/ListResponse.cs index f3a1dba..78687df 100644 --- a/src/FinancialHub/FinancialHub.Domain/Responses/Success/ListResponse.cs +++ b/src/api/FinancialHub.Common/Responses/Success/ListResponse.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace FinancialHub.Domain.Responses.Success +namespace FinancialHub.Common.Responses.Success { public class ListResponse : BaseResponse> { diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs b/src/api/FinancialHub.Common/Responses/Success/PaginatedListResponse.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs rename to src/api/FinancialHub.Common/Responses/Success/PaginatedListResponse.cs index 4a1ae7e..67c0b3e 100644 --- a/src/FinancialHub/FinancialHub.Domain/Responses/Success/PaginatedListResponse.cs +++ b/src/api/FinancialHub.Common/Responses/Success/PaginatedListResponse.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace FinancialHub.Domain.Responses.Success +namespace FinancialHub.Common.Responses.Success { public class PaginatedListResponse : BaseResponse> { diff --git a/src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs b/src/api/FinancialHub.Common/Responses/Success/SaveResponse.cs similarity index 72% rename from src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs rename to src/api/FinancialHub.Common/Responses/Success/SaveResponse.cs index 331f574..74c4c65 100644 --- a/src/FinancialHub/FinancialHub.Domain/Responses/Success/SaveResponse.cs +++ b/src/api/FinancialHub.Common/Responses/Success/SaveResponse.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Domain.Responses.Success +namespace FinancialHub.Common.Responses.Success { public class SaveResponse : BaseResponse { diff --git a/src/api/FinancialHub.Common/Results/Errors/InvalidDataError.cs b/src/api/FinancialHub.Common/Results/Errors/InvalidDataError.cs new file mode 100644 index 0000000..3ca575b --- /dev/null +++ b/src/api/FinancialHub.Common/Results/Errors/InvalidDataError.cs @@ -0,0 +1,12 @@ +using System; + +namespace FinancialHub.Common.Results.Errors +{ + public class InvalidDataError : ServiceError + { + private const int code = 400; + public InvalidDataError(string message) : base(code, message) + { + } + } +} diff --git a/src/api/FinancialHub.Common/Results/Errors/NotFoundError.cs b/src/api/FinancialHub.Common/Results/Errors/NotFoundError.cs new file mode 100644 index 0000000..e990e1d --- /dev/null +++ b/src/api/FinancialHub.Common/Results/Errors/NotFoundError.cs @@ -0,0 +1,12 @@ +using System; + +namespace FinancialHub.Common.Results.Errors +{ + public class NotFoundError : ServiceError + { + private const int code = 404; + public NotFoundError(string message) : base(code, message) + { + } + } +} diff --git a/src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs b/src/api/FinancialHub.Common/Results/Errors/ServiceError.cs similarity index 62% rename from src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs rename to src/api/FinancialHub.Common/Results/Errors/ServiceError.cs index dbf2828..c424d94 100644 --- a/src/FinancialHub/FinancialHub.Domain/Results/Errors/ServiceError.cs +++ b/src/api/FinancialHub.Common/Results/Errors/ServiceError.cs @@ -1,19 +1,17 @@ using System; -namespace FinancialHub.Domain.Results.Errors +namespace FinancialHub.Common.Results.Errors { public class ServiceError { #warning it can be changed to an enum or use a different value from https codes public int Code { get; protected set; } public string Message { get; protected set; } - public Exception Error { get; protected set; } - public ServiceError(int code,string message, Exception error = null) + public ServiceError(int code,string message) { this.Code = code; this.Message = message; - this.Error = error; } } } diff --git a/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs b/src/api/FinancialHub.Common/Results/ServiceResult.cs similarity index 64% rename from src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs rename to src/api/FinancialHub.Common/Results/ServiceResult.cs index c7c44db..4d85ab7 100644 --- a/src/FinancialHub/FinancialHub.Domain/Results/ServiceResult.cs +++ b/src/api/FinancialHub.Common/Results/ServiceResult.cs @@ -1,14 +1,14 @@ -using FinancialHub.Domain.Results.Errors; +using FinancialHub.Common.Results.Errors; -namespace FinancialHub.Domain.Results +namespace FinancialHub.Common.Results { public class ServiceResult { public bool HasError => this.Error != null; - public ServiceError Error { get; protected set; } - public T Data { get; protected set; } + public ServiceError? Error { get; protected set; } + public T? Data { get; protected set; } - public ServiceResult(T data = default,ServiceError error = null) + public ServiceResult(T? data = default, ServiceError? error = null) { this.Data = data; this.Error = error; @@ -19,7 +19,7 @@ public static implicit operator ServiceResult(T result) return new ServiceResult(result); } - public static implicit operator ServiceResult(ServiceError error) + public static implicit operator ServiceResult(ServiceError? error) { return new ServiceResult(error: error); } @@ -28,14 +28,14 @@ public static implicit operator ServiceResult(ServiceError error) public class ServiceResult { public bool HasError => this.Error != null; - public ServiceError Error { get; protected set; } + public ServiceError? Error { get; protected set; } - public ServiceResult(ServiceError error = null) + public ServiceResult(ServiceError? error = null) { this.Error = error; } - public static implicit operator ServiceResult(ServiceError error) + public static implicit operator ServiceResult(ServiceError? error) { return new ServiceResult(error: error); } diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs b/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs rename to src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs index a966c6b..2f09cf7 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs @@ -1,6 +1,4 @@ -using FinancialHub.Domain.Entities; - -namespace FinancialHub.Domain.Tests.Builders.Entities +namespace FinancialHub.Core.Domain.Tests.Builders.Entities { public class AccountEntityBuilder : BaseEntityBuilder { diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs b/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs similarity index 93% rename from src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs rename to src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs index 8cea247..b999ed7 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs @@ -1,7 +1,4 @@ -using FinancialHub.Domain.Entities; -using System; - -namespace FinancialHub.Domain.Tests.Builders.Entities +namespace FinancialHub.Core.Domain.Tests.Builders.Entities { public class BalanceEntityBuilder : BaseEntityBuilder { diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs b/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs rename to src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs index c7c97e5..3573f60 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs @@ -1,6 +1,4 @@ -using FinancialHub.Domain.Entities; - -namespace FinancialHub.Domain.Tests.Builders.Entities +namespace FinancialHub.Core.Domain.Tests.Builders.Entities { public class CategoryEntityBuilder : BaseEntityBuilder { diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs b/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs rename to src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs index de95478..a1a5cc3 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs @@ -1,8 +1,6 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Enums; -using System; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Domain.Tests.Builders.Entities +namespace FinancialHub.Core.Domain.Tests.Builders.Entities { public class TransactionEntityBuilder : BaseEntityBuilder { diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs b/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs rename to src/api/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs index 98b2d19..232695d 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/AccountModelBuilder.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs @@ -1,6 +1,4 @@ -using FinancialHub.Domain.Models; - -namespace FinancialHub.Domain.Tests.Builders.Models +namespace FinancialHub.Core.Domain.Tests.Builders.Models { public class AccountModelBuilder : BaseModelBuilder { diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs b/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs similarity index 93% rename from src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs rename to src/api/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs index ac0dc89..b9dec29 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/BalanceModelBuilder.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs @@ -1,7 +1,4 @@ -using FinancialHub.Domain.Models; -using System; - -namespace FinancialHub.Domain.Tests.Builders.Models +namespace FinancialHub.Core.Domain.Tests.Builders.Models { public class BalanceModelBuilder : BaseModelBuilder { diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs b/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs rename to src/api/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs index 2f29ef1..3f188fc 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/CategoryModelBuilder.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs @@ -1,6 +1,4 @@ -using FinancialHub.Domain.Models; - -namespace FinancialHub.Domain.Tests.Builders.Models +namespace FinancialHub.Core.Domain.Tests.Builders.Models { public class CategoryModelBuilder : BaseModelBuilder { diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs b/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs rename to src/api/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs index 3edba61..eaf2807 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Builders/Models/TransactionModelBuilder.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs @@ -1,8 +1,6 @@ -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Models; -using System; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Domain.Tests.Builders.Models +namespace FinancialHub.Core.Domain.Tests.Builders.Models { public class TransactionModelBuilder : BaseModelBuilder { diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj b/src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj similarity index 81% rename from src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj rename to src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj index dd8a65f..148910d 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/FinancialHub.Domain.Tests.csproj +++ b/src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj @@ -19,7 +19,8 @@ - + + diff --git a/src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs b/src/api/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs rename to src/api/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs index 880c570..2ef0d7e 100644 --- a/src/FinancialHub/FinancialHub.Domain.Tests/Queries/TransactionQueryTests.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs @@ -1,13 +1,10 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Queries; -using FinancialHub.Domain.Tests.Builders.Entities; -using NUnit.Framework; -using System; -using System.Collections.Generic; +using NUnit.Framework; using System.Linq; +using FinancialHub.Core.Domain.Enums; +using FinancialHub.Core.Domain.Queries; +using FinancialHub.Core.Domain.Tests.Builders.Entities; -namespace FinancialHub.Domain.Tests.Queries +namespace FinancialHub.Core.Domain.Tests.Queries { public class TransactionQueryTests { diff --git a/src/api/FinancialHub.Core.Domain.Tests/Usings.cs b/src/api/FinancialHub.Core.Domain.Tests/Usings.cs new file mode 100644 index 0000000..69cef6a --- /dev/null +++ b/src/api/FinancialHub.Core.Domain.Tests/Usings.cs @@ -0,0 +1,10 @@ +// System namespaces +global using System; + +// Domain builder tests namespaces +global using FinancialHub.Common.Tests.Builders.Entities; +global using FinancialHub.Common.Tests.Builders.Models; + +// Domain Models namespaces +global using FinancialHub.Core.Domain.Entities; +global using FinancialHub.Core.Domain.Models; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs b/src/api/FinancialHub.Core.Domain/Entities/AccountEntity.cs similarity index 77% rename from src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs rename to src/api/FinancialHub.Core.Domain/Entities/AccountEntity.cs index 04d2a52..b15c010 100644 --- a/src/FinancialHub/FinancialHub.Domain/Entities/AccountEntity.cs +++ b/src/api/FinancialHub.Core.Domain/Entities/AccountEntity.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace FinancialHub.Domain.Entities +namespace FinancialHub.Core.Domain.Entities { public class AccountEntity : BaseEntity { diff --git a/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs b/src/api/FinancialHub.Core.Domain/Entities/BalanceEntity.cs similarity index 81% rename from src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs rename to src/api/FinancialHub.Core.Domain/Entities/BalanceEntity.cs index 6281e30..57252dc 100644 --- a/src/FinancialHub/FinancialHub.Domain/Entities/BalanceEntity.cs +++ b/src/api/FinancialHub.Core.Domain/Entities/BalanceEntity.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace FinancialHub.Domain.Entities +namespace FinancialHub.Core.Domain.Entities { public class BalanceEntity : BaseEntity { diff --git a/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs b/src/api/FinancialHub.Core.Domain/Entities/CategoryEntity.cs similarity index 77% rename from src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs rename to src/api/FinancialHub.Core.Domain/Entities/CategoryEntity.cs index 9d85a11..57504ee 100644 --- a/src/FinancialHub/FinancialHub.Domain/Entities/CategoryEntity.cs +++ b/src/api/FinancialHub.Core.Domain/Entities/CategoryEntity.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace FinancialHub.Domain.Entities +namespace FinancialHub.Core.Domain.Entities { public class CategoryEntity : BaseEntity { diff --git a/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs b/src/api/FinancialHub.Core.Domain/Entities/TransactionEntity.cs similarity index 87% rename from src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs rename to src/api/FinancialHub.Core.Domain/Entities/TransactionEntity.cs index cfb4573..3289b42 100644 --- a/src/FinancialHub/FinancialHub.Domain/Entities/TransactionEntity.cs +++ b/src/api/FinancialHub.Core.Domain/Entities/TransactionEntity.cs @@ -1,7 +1,6 @@ -using System; -using FinancialHub.Domain.Enums; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Domain.Entities +namespace FinancialHub.Core.Domain.Entities { public class TransactionEntity : BaseEntity { diff --git a/src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs b/src/api/FinancialHub.Core.Domain/Enums/TransactionStatus.cs similarity index 76% rename from src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs rename to src/api/FinancialHub.Core.Domain/Enums/TransactionStatus.cs index be0f978..8ca5480 100644 --- a/src/FinancialHub/FinancialHub.Domain/Enums/TransactionStatus.cs +++ b/src/api/FinancialHub.Core.Domain/Enums/TransactionStatus.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Domain.Enums +namespace FinancialHub.Core.Domain.Enums { public enum TransactionStatus { diff --git a/src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs b/src/api/FinancialHub.Core.Domain/Enums/TransactionType.cs similarity index 66% rename from src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs rename to src/api/FinancialHub.Core.Domain/Enums/TransactionType.cs index 5b9f784..adf04aa 100644 --- a/src/FinancialHub/FinancialHub.Domain/Enums/TransactionType.cs +++ b/src/api/FinancialHub.Core.Domain/Enums/TransactionType.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Domain.Enums +namespace FinancialHub.Core.Domain.Enums { public enum TransactionType { diff --git a/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs b/src/api/FinancialHub.Core.Domain/Filters/TransactionFilter.cs similarity index 79% rename from src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs rename to src/api/FinancialHub.Core.Domain/Filters/TransactionFilter.cs index a24600a..04f1e85 100644 --- a/src/FinancialHub/FinancialHub.Domain/Filters/TransactionFilter.cs +++ b/src/api/FinancialHub.Core.Domain/Filters/TransactionFilter.cs @@ -1,7 +1,6 @@ -using System; -using FinancialHub.Domain.Enums; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Domain.Filters +namespace FinancialHub.Core.Domain.Filters { public class TransactionFilter { diff --git a/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj b/src/api/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj similarity index 87% rename from src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj rename to src/api/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj index 24f4ca2..336bd9f 100644 --- a/src/FinancialHub/FinancialHub.Domain/FinancialHub.Domain.csproj +++ b/src/api/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj @@ -10,6 +10,10 @@ + + + + True diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs similarity index 77% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs rename to src/api/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs index b1560aa..642a07e 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Mappers/IMapperWrapper.cs +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Domain.Interfaces.Mappers +namespace FinancialHub.Core.Domain.Interfaces.Mappers { /// /// Wrapper interface for Mapper Classes diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs similarity index 51% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs rename to src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs index 4cb6ba4..149df61 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IAccountsRepository.cs +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs @@ -1,6 +1,7 @@ -using FinancialHub.Domain.Entities; +using FinancialHub.Common.Interfaces.Repositories; +using FinancialHub.Core.Domain.Entities; -namespace FinancialHub.Domain.Interfaces.Repositories +namespace FinancialHub.Core.Domain.Interfaces.Repositories { public interface IAccountsRepository : IBaseRepository { diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs similarity index 60% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs rename to src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs index dbaf617..b0e2070 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Repositories/IBalancesRepository.cs +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs @@ -1,9 +1,8 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Enums; -using System; -using System.Threading.Tasks; +using FinancialHub.Common.Interfaces.Repositories; +using FinancialHub.Core.Domain.Entities; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Domain.Interfaces.Repositories +namespace FinancialHub.Core.Domain.Interfaces.Repositories { public interface IBalancesRepository : IBaseRepository { diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs new file mode 100644 index 0000000..419f558 --- /dev/null +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs @@ -0,0 +1,9 @@ +using FinancialHub.Common.Interfaces.Repositories; +using FinancialHub.Core.Domain.Entities; + +namespace FinancialHub.Core.Domain.Interfaces.Repositories +{ + public interface ICategoriesRepository : IBaseRepository + { + } +} diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs new file mode 100644 index 0000000..96d267b --- /dev/null +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs @@ -0,0 +1,9 @@ +using FinancialHub.Common.Interfaces.Repositories; +using FinancialHub.Core.Domain.Entities; + +namespace FinancialHub.Core.Domain.Interfaces.Repositories +{ + public interface ITransactionsRepository : IBaseRepository + { + } +} diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs similarity index 59% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs rename to src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs index 21cc0c6..136c775 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountBalanceService.cs +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; +using FinancialHub.Common.Results; +using FinancialHub.Core.Domain.Models; -namespace FinancialHub.Domain.Interfaces.Services +namespace FinancialHub.Core.Domain.Interfaces.Services { public interface IAccountBalanceService { diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs similarity index 68% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs rename to src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs index bea7b2d..956fa77 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IAccountsService.cs +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs @@ -1,10 +1,7 @@ -using FinancialHub.Domain.Models; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using FinancialHub.Domain.Results; +using FinancialHub.Common.Results; +using FinancialHub.Core.Domain.Models; -namespace FinancialHub.Domain.Interfaces.Services +namespace FinancialHub.Core.Domain.Interfaces.Services { public interface IAccountsService { diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs similarity index 72% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs rename to src/api/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs index 0a14038..71c84bf 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/IBalancesService.cs +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; +using FinancialHub.Common.Results; +using FinancialHub.Core.Domain.Models; -namespace FinancialHub.Domain.Interfaces.Services +namespace FinancialHub.Core.Domain.Interfaces.Services { public interface IBalancesService { diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs similarity index 65% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs rename to src/api/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs index 959db36..76e2c6e 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ICategoriesService.cs +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs @@ -1,10 +1,7 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; +using FinancialHub.Common.Results; +using FinancialHub.Core.Domain.Models; -namespace FinancialHub.Domain.Interfaces.Services +namespace FinancialHub.Core.Domain.Interfaces.Services { public interface ICategoriesService { diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs similarity index 72% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs rename to src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs index 0e36821..fabd299 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionBalanceService.cs +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs @@ -1,9 +1,7 @@ -using System; -using System.Threading.Tasks; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; +using FinancialHub.Common.Results; +using FinancialHub.Core.Domain.Models; -namespace FinancialHub.Domain.Interfaces.Services +namespace FinancialHub.Core.Domain.Interfaces.Services { public interface ITransactionBalanceService { diff --git a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs b/src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs similarity index 67% rename from src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs rename to src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs index b3c2c12..653660c 100644 --- a/src/FinancialHub/FinancialHub.Domain/Interfaces/Services/ITransactionsService.cs +++ b/src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs @@ -1,11 +1,8 @@ -using System; -using System.Threading.Tasks; -using System.Collections.Generic; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Filters; -using FinancialHub.Domain.Results; +using FinancialHub.Common.Results; +using FinancialHub.Core.Domain.Models; +using FinancialHub.Core.Domain.Filters; -namespace FinancialHub.Domain.Interfaces.Services +namespace FinancialHub.Core.Domain.Interfaces.Services { public interface ITransactionsService { diff --git a/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs b/src/api/FinancialHub.Core.Domain/Models/AccountModel.cs similarity index 70% rename from src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs rename to src/api/FinancialHub.Core.Domain/Models/AccountModel.cs index 2571b29..a588e2b 100644 --- a/src/FinancialHub/FinancialHub.Domain/Models/AccountModel.cs +++ b/src/api/FinancialHub.Core.Domain/Models/AccountModel.cs @@ -1,6 +1,6 @@ -using FinancialHub.Domain.Model; +using FinancialHub.Common.Models; -namespace FinancialHub.Domain.Models +namespace FinancialHub.Core.Domain.Models { public class AccountModel : BaseModel { diff --git a/src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs b/src/api/FinancialHub.Core.Domain/Models/BalanceModel.cs similarity index 81% rename from src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs rename to src/api/FinancialHub.Core.Domain/Models/BalanceModel.cs index 44daa90..3b3f20d 100644 --- a/src/FinancialHub/FinancialHub.Domain/Models/BalanceModel.cs +++ b/src/api/FinancialHub.Core.Domain/Models/BalanceModel.cs @@ -1,7 +1,7 @@ -using FinancialHub.Domain.Model; +using FinancialHub.Common.Models; using System; -namespace FinancialHub.Domain.Models +namespace FinancialHub.Core.Domain.Models { public class BalanceModel : BaseModel { diff --git a/src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs b/src/api/FinancialHub.Core.Domain/Models/CategoryModel.cs similarity index 70% rename from src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs rename to src/api/FinancialHub.Core.Domain/Models/CategoryModel.cs index da2e449..1c60446 100644 --- a/src/FinancialHub/FinancialHub.Domain/Models/CategoryModel.cs +++ b/src/api/FinancialHub.Core.Domain/Models/CategoryModel.cs @@ -1,6 +1,6 @@ -using FinancialHub.Domain.Model; +using FinancialHub.Common.Models; -namespace FinancialHub.Domain.Models +namespace FinancialHub.Core.Domain.Models { public class CategoryModel : BaseModel { diff --git a/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs b/src/api/FinancialHub.Core.Domain/Models/TransactionModel.cs similarity index 85% rename from src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs rename to src/api/FinancialHub.Core.Domain/Models/TransactionModel.cs index f2df90c..771f0e0 100644 --- a/src/FinancialHub/FinancialHub.Domain/Models/TransactionModel.cs +++ b/src/api/FinancialHub.Core.Domain/Models/TransactionModel.cs @@ -1,9 +1,9 @@ -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Model; -using System; +using System; using System.Text.Json.Serialization; +using FinancialHub.Common.Models; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Domain.Models +namespace FinancialHub.Core.Domain.Models { public class TransactionModel : BaseModel { diff --git a/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs b/src/api/FinancialHub.Core.Domain/Queries/TransactionQuery.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs rename to src/api/FinancialHub.Core.Domain/Queries/TransactionQuery.cs index 4205751..3438ec2 100644 --- a/src/FinancialHub/FinancialHub.Domain/Queries/TransactionQuery.cs +++ b/src/api/FinancialHub.Core.Domain/Queries/TransactionQuery.cs @@ -1,10 +1,8 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Enums; +using System.Linq; +using FinancialHub.Core.Domain.Entities; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Domain.Queries +namespace FinancialHub.Core.Domain.Queries { public class TransactionQuery { diff --git a/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs b/src/api/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs rename to src/api/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs index 5fc913e..f2a30f6 100644 --- a/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.Designer.cs +++ b/src/api/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace FinancialHub.Domain.Resources { +namespace FinancialHub.Core.Domain.Resources { using System; @@ -39,7 +39,7 @@ internal FinancialHubConcepts() { public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.Domain.Resources.FinancialHubConcepts", typeof(FinancialHubConcepts).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.Core.Domain.Resources.FinancialHubConcepts", typeof(FinancialHubConcepts).Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx b/src/api/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx similarity index 100% rename from src/FinancialHub/FinancialHub.Domain/Resources/FinancialHubConcepts.resx rename to src/api/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx diff --git a/src/api/FinancialHub.Core.Domain/Usings.cs b/src/api/FinancialHub.Core.Domain/Usings.cs new file mode 100644 index 0000000..7dbf743 --- /dev/null +++ b/src/api/FinancialHub.Core.Domain/Usings.cs @@ -0,0 +1,8 @@ +// System namespaces +global using System; +global using System.Collections.Generic; +global using System.Threading.Tasks; + +// Domain Models namespaces +global using FinancialHub.Common.Entities; +global using FinancialHub.Common.Models; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj similarity index 78% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj index 61b2a72..0e206c1 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/FinancialHub.Infra.Data.NUnitTests.csproj +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs similarity index 53% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs index 1193ac1..6e73d77 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs @@ -1,10 +1,7 @@ -using NUnit.Framework; -using FinancialHub.Domain.Entities; -using FinancialHub.Infra.Data.Repositories; -using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; -using FinancialHub.Domain.Tests.Builders.Entities; +using FinancialHub.Core.Infra.Data.Repositories; +using FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base; -namespace FinancialHub.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories { public class AccountsRepositoryTests : BaseRepositoryTests { diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs index 3b183f9..a04669f 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs @@ -1,9 +1,6 @@ -using FinancialHub.Domain.Enums; -using NUnit.Framework; -using System; -using System.Threading.Tasks; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories { public partial class BalancesRepositoryTests { diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs similarity index 76% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs index f27462b..812a790 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs @@ -1,9 +1,4 @@ -using FinancialHub.Domain.Entities; -using NUnit.Framework; -using System.Linq; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories { public partial class BalancesRepositoryTests { diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs similarity index 71% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs index 9ad9e14..46ed97c 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs @@ -1,10 +1,7 @@ -using NUnit.Framework; -using FinancialHub.Domain.Entities; -using FinancialHub.Infra.Data.Repositories; -using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; -using FinancialHub.Domain.Tests.Builders.Entities; +using FinancialHub.Core.Infra.Data.Repositories; +using FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base; -namespace FinancialHub.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories { public partial class BalancesRepositoryTests : BaseRepositoryTests { diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs similarity index 87% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs index 95d99c7..192a99f 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs @@ -1,12 +1,9 @@ -using System; -using System.Linq; -using NUnit.Framework; -using System.Threading.Tasks; -using FinancialHub.Domain.Entities; +using FinancialHub.Common.Entities; -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base { - public abstract partial class BaseRepositoryTests where T : BaseEntity + public abstract partial class BaseRepositoryTests + where T : BaseEntity { protected virtual void AssertCreated(T createdItem) { diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs similarity index 87% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs index b08ad99..dbe09a0 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs @@ -1,15 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; +using System.Collections.Generic; using Microsoft.EntityFrameworkCore; using Microsoft.Data.Sqlite; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Tests.Builders.Entities; -using FinancialHub.Domain.Entities; -using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Common.Entities; +using FinancialHub.Common.Tests.Builders.Entities; +using FinancialHub.Common.Interfaces.Repositories; +using FinancialHub.Core.Infra.Data.Contexts; -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs similarity index 79% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs index 51853f8..f5bbeed 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs @@ -1,12 +1,9 @@ -using FinancialHub.Domain.Entities; -using NUnit.Framework; -using System; -using System.Linq; -using System.Threading.Tasks; +using FinancialHub.Common.Entities; -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base { - public abstract partial class BaseRepositoryTests where T : BaseEntity + public abstract partial class BaseRepositoryTests + where T : BaseEntity { [Test] [TestCase(TestName = "Delete existing Item",Category = "Delete")] diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs index c580c4e..b0c2213 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs @@ -1,15 +1,11 @@ -using System; -using System.Linq; -using NUnit.Framework; -using System.Threading.Tasks; -using System.Collections.Generic; -using FinancialHub.Domain.Entities; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +using System.Collections.Generic; +using FinancialHub.Common.Entities; + +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base { - public abstract partial class BaseRepositoryTests where T : BaseEntity + public abstract partial class BaseRepositoryTests + where T : BaseEntity { - #region Get All [Test] [TestCase(TestName = "Get All Items without data",Category = "Get")] public virtual async Task GetAllAsync_NoData_ReturnsEmpty() @@ -33,9 +29,7 @@ public virtual async Task GetAllAsync_Data_ReturnsItems() Assert.AreEqual(items,list); Assert.IsInstanceOf>(list); } - #endregion - #region Get [Test] [TestCase(TestName = "Get Items with no filter", Category = "Get")] public virtual async Task GetAsync_NoFilter_ReturnsAllItems() @@ -92,9 +86,7 @@ public virtual async Task GetAsync_WrongFilter_ReturnsEmpty() Assert.IsEmpty(list); Assert.IsInstanceOf>(list); } - #endregion - #region Get By Id [Test] [TestCase(TestName = "Get By Id with empty id", Category = "Get")] public virtual async Task GetByIdAsync_EmptyId_ReturnsNull() @@ -134,6 +126,5 @@ public virtual async Task GetByIdAsync_NonExistingId_ReturnsNull() Assert.IsNull(item); } - #endregion } } diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs similarity index 80% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs index 73bea04..73964e2 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs @@ -1,14 +1,11 @@ -using FinancialHub.Domain.Entities; +using FinancialHub.Common.Entities; using Microsoft.EntityFrameworkCore; -using NUnit.Framework; -using System; -using System.Threading.Tasks; -namespace FinancialHub.Infra.Data.NUnitTests.Repositories.Base +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base { - public abstract partial class BaseRepositoryTests where T : BaseEntity + public abstract partial class BaseRepositoryTests + where T : BaseEntity { - #region Update [Test] [TestCase(TestName = "Update existing Item", Category = "Update")] public virtual async Task UpdateAsync_ExistingItem_UpdatesItem() @@ -37,6 +34,5 @@ public virtual void UpdateAsync_NonExistingItem_ThrowsDbUpdateConcurrencyExcepti Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(item)); } - #endregion } } diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs similarity index 54% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs index fd19b4f..6a3d824 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs @@ -1,10 +1,7 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Tests.Builders.Entities; -using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; -using FinancialHub.Infra.Data.Repositories; -using NUnit.Framework; +using FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Core.Infra.Data.Repositories; -namespace FinancialHub.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories { public class CategoriesRepositoryTests : BaseRepositoryTests { diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs similarity index 96% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs index e85c3a2..f688724 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs @@ -1,11 +1,6 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using NUnit.Framework; -using System; -using System.Linq; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories +using Microsoft.EntityFrameworkCore; + +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories { public partial class TransactionsRepositoryTests { diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs similarity index 87% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs index 0823c01..f87f81e 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs @@ -1,11 +1,7 @@ -using System; -using NUnit.Framework; -using FinancialHub.Domain.Entities; -using FinancialHub.Infra.Data.Repositories; -using FinancialHub.Domain.Tests.Builders.Entities; -using FinancialHub.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Core.Infra.Data.Repositories; +using FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base; -namespace FinancialHub.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories { public partial class TransactionsRepositoryTests : BaseRepositoryTests { diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs similarity index 86% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs index 1d765eb..53df147 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs @@ -1,7 +1,4 @@ -using NUnit.Framework; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories { public partial class TransactionsRepositoryTests { diff --git a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs rename to src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs index 9c7c0c5..3f26edb 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs @@ -1,11 +1,6 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using NUnit.Framework; -using System; -using System.Linq; -using System.Threading.Tasks; - -namespace FinancialHub.Infra.Data.NUnitTests.Repositories +using Microsoft.EntityFrameworkCore; + +namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories { public partial class TransactionsRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Usings.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Usings.cs new file mode 100644 index 0000000..57502ee --- /dev/null +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Usings.cs @@ -0,0 +1,13 @@ +// System namespaces +global using System; +global using System.Linq; +global using System.Threading.Tasks; + +// 3rd party test namespaces +global using NUnit.Framework; + +// Domain Project tests namespaces +global using FinancialHub.Core.Domain.Tests.Builders.Entities; + +// Domain Project namespaces +global using FinancialHub.Core.Domain.Entities; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs b/src/api/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs similarity index 80% rename from src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs rename to src/api/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs index 859f5a9..aa3cd1f 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Contexts/FinancialHubContext.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs @@ -1,8 +1,6 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; -namespace FinancialHub.Infra.Data.Contexts +namespace FinancialHub.Core.Infra.Data.Contexts { public class FinancialHubContext : DbContext { diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs similarity index 82% rename from src/FinancialHub/FinancialHub.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs index 55d6790..6090f82 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -1,11 +1,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.EntityFrameworkCore; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Data.Contexts; -using FinancialHub.Infra.Data.Repositories; +using FinancialHub.Core.Infra.Data.Contexts; +using FinancialHub.Core.Infra.Data.Repositories; -namespace FinancialHub.Infra.Data.Extensions.Configurations +namespace FinancialHub.Core.Infra.Data.Extensions.Configurations { public static class IServiceCollectionExtensions { diff --git a/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj b/src/api/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj similarity index 83% rename from src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj rename to src/api/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj index 660d3df..6453bfe 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/FinancialHub.Infra.Data.csproj +++ b/src/api/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/AccountEntityMapping.cs b/src/api/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs similarity index 78% rename from src/FinancialHub/FinancialHub.Infra.Data/Mappings/AccountEntityMapping.cs rename to src/api/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs index 2eed4e9..9838384 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/AccountEntityMapping.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs @@ -1,8 +1,6 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace FinancialHub.Infra.Data.Mappings +namespace FinancialHub.Core.Infra.Data.Mappings { internal class AccountEntityMapping : IEntityTypeConfiguration { diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/BalanceEntityMapping.cs b/src/api/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs similarity index 87% rename from src/FinancialHub/FinancialHub.Infra.Data/Mappings/BalanceEntityMapping.cs rename to src/api/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs index 3d0e927..2f9b7e7 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/BalanceEntityMapping.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs @@ -1,8 +1,6 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace FinancialHub.Infra.Data.Mappings +namespace FinancialHub.Core.Infra.Data.Mappings { internal class BalanceEntityMapping : IEntityTypeConfiguration { diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/CategoryEntityMapping.cs b/src/api/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs similarity index 78% rename from src/FinancialHub/FinancialHub.Infra.Data/Mappings/CategoryEntityMapping.cs rename to src/api/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs index b83679f..c9641cd 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/CategoryEntityMapping.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs @@ -1,8 +1,6 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace FinancialHub.Infra.Data.Mappings +namespace FinancialHub.Core.Infra.Data.Mappings { internal class CategoryEntityMapping : IEntityTypeConfiguration { diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/TransactionEntityMapping.cs b/src/api/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs similarity index 91% rename from src/FinancialHub/FinancialHub.Infra.Data/Mappings/TransactionEntityMapping.cs rename to src/api/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs index 3566a2b..ee67d71 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Mappings/TransactionEntityMapping.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs @@ -1,8 +1,6 @@ -using FinancialHub.Domain.Entities; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace FinancialHub.Infra.Data.Mappings +namespace FinancialHub.Core.Infra.Data.Mappings { internal class TransactionEntityMapping : IEntityTypeConfiguration { diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs b/src/api/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs similarity index 53% rename from src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs rename to src/api/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs index cce4c66..52fb560 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/AccountsRepository.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs @@ -1,8 +1,6 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Core.Infra.Data.Contexts; -namespace FinancialHub.Infra.Data.Repositories +namespace FinancialHub.Core.Infra.Data.Repositories { public class AccountsRepository : BaseRepository, IAccountsRepository { diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs b/src/api/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs similarity index 88% rename from src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs rename to src/api/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs index c397a27..fec0d6a 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BalancesRepository.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs @@ -1,11 +1,7 @@ -using System; -using System.Threading.Tasks; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Core.Domain.Enums; +using FinancialHub.Core.Infra.Data.Contexts; -namespace FinancialHub.Infra.Data.Repositories +namespace FinancialHub.Core.Infra.Data.Repositories { public class BalancesRepository : BaseRepository, IBalancesRepository { diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs b/src/api/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs similarity index 82% rename from src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs rename to src/api/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs index 39bb39d..a096ac4 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/BaseRepository.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs @@ -1,16 +1,11 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.Generic; -using FinancialHub.Infra.Data.Contexts; -using Microsoft.EntityFrameworkCore; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Repositories; +using System.Linq; +using FinancialHub.Core.Infra.Data.Contexts; +using FinancialHub.Common.Entities; +using FinancialHub.Common.Interfaces.Repositories; -namespace FinancialHub.Infra.Data.Repositories +namespace FinancialHub.Core.Infra.Data.Repositories { - public class BaseRepository : - IBaseRepository + public class BaseRepository : IBaseRepository where T : BaseEntity { protected readonly FinancialHubContext context; diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs b/src/api/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs similarity index 54% rename from src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs rename to src/api/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs index 5d422c5..4842f52 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/CategoriesRepository.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs @@ -1,8 +1,6 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Core.Infra.Data.Contexts; -namespace FinancialHub.Infra.Data.Repositories +namespace FinancialHub.Core.Infra.Data.Repositories { public class CategoriesRepository : BaseRepository, ICategoriesRepository { diff --git a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs b/src/api/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs similarity index 79% rename from src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs rename to src/api/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs index 23b51c2..a0ee942 100644 --- a/src/FinancialHub/FinancialHub.Infra.Data/Repositories/TransactionsRepository.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs @@ -1,10 +1,6 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Infra.Data.Contexts; -using System; -using System.Threading.Tasks; +using FinancialHub.Core.Infra.Data.Contexts; -namespace FinancialHub.Infra.Data.Repositories +namespace FinancialHub.Core.Infra.Data.Repositories { public class TransactionsRepository : BaseRepository, ITransactionsRepository { diff --git a/src/api/FinancialHub.Core.Infra.Data/Usings.cs b/src/api/FinancialHub.Core.Infra.Data/Usings.cs new file mode 100644 index 0000000..2879c47 --- /dev/null +++ b/src/api/FinancialHub.Core.Infra.Data/Usings.cs @@ -0,0 +1,13 @@ +// System namespaces +global using System; +global using System.Collections.Generic; +global using System.Threading.Tasks; + +// 3rd party namespaces +global using Microsoft.EntityFrameworkCore; + +// Domain project interface namespaces +global using FinancialHub.Core.Domain.Interfaces.Repositories; + +// Domain Project namespaces +global using FinancialHub.Core.Domain.Entities; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj b/src/api/FinancialHub.Core.Infra.Migrations/FinancialHub.Core.Infra.Migrations.csproj similarity index 81% rename from src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj rename to src/api/FinancialHub.Core.Infra.Migrations/FinancialHub.Core.Infra.Migrations.csproj index cb4c84f..7d17912 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/FinancialHub.Infra.Migrations.csproj +++ b/src/api/FinancialHub.Core.Infra.Migrations/FinancialHub.Core.Infra.Migrations.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs rename to src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs index cf7c9cd..d53da4b 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs +++ b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs @@ -1,6 +1,6 @@ // using System; -using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Core.Infra.Data.Contexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -9,7 +9,7 @@ #nullable disable -namespace FinancialHub.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Migrations.Migrations { [DbContext(typeof(FinancialHubContext))] [Migration("20220407152032_v0.2.4")] diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs similarity index 97% rename from src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs rename to src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs index cd41f6a..ae68db4 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs +++ b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs @@ -1,10 +1,12 @@ using System; +using System.Diagnostics.CodeAnalysis; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace FinancialHub.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Migrations.Migrations { + [ExcludeFromCodeCoverage] public partial class v024 : Migration { protected override void Up(MigrationBuilder migrationBuilder) diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs rename to src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs index a2fa7f6..752eac2 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs +++ b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs @@ -1,6 +1,6 @@ // using System; -using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Core.Infra.Data.Contexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -9,7 +9,7 @@ #nullable disable -namespace FinancialHub.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Migrations.Migrations { [DbContext(typeof(FinancialHubContext))] [Migration("20220520163358_add-balance")] diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs rename to src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.cs index 1a29a44..451b14f 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520163358_add-balance.cs +++ b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.cs @@ -1,10 +1,12 @@ using System; +using System.Diagnostics.CodeAnalysis; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace FinancialHub.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Migrations.Migrations { + [ExcludeFromCodeCoverage] public partial class addbalance : Migration { protected override void Up(MigrationBuilder migrationBuilder) diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs rename to src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs index 43eee41..70bcdc9 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs +++ b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs @@ -1,6 +1,6 @@ // using System; -using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Core.Infra.Data.Contexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -9,7 +9,7 @@ #nullable disable -namespace FinancialHub.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Migrations.Migrations { [DbContext(typeof(FinancialHubContext))] [Migration("20220520215117_add-balance-to-transaction")] diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs rename to src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs index 086ef9f..a28c753 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs +++ b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs @@ -1,9 +1,11 @@ using Microsoft.EntityFrameworkCore.Migrations; +using System.Diagnostics.CodeAnalysis; #nullable disable -namespace FinancialHub.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Migrations.Migrations { + [ExcludeFromCodeCoverage] public partial class addbalancetotransaction : Migration { protected override void Up(MigrationBuilder migrationBuilder) diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs rename to src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs index fdcafa9..44d52c9 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs +++ b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs @@ -1,6 +1,6 @@ // using System; -using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Core.Infra.Data.Contexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -9,7 +9,7 @@ #nullable disable -namespace FinancialHub.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Migrations.Migrations { [DbContext(typeof(FinancialHubContext))] [Migration("20220520215501_add-balance-active")] diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs similarity index 83% rename from src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs rename to src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs index 3d65793..155589a 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs +++ b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs @@ -1,9 +1,11 @@ using Microsoft.EntityFrameworkCore.Migrations; +using System.Diagnostics.CodeAnalysis; #nullable disable -namespace FinancialHub.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Migrations.Migrations { + [ExcludeFromCodeCoverage] public partial class addbalanceactive : Migration { protected override void Up(MigrationBuilder migrationBuilder) diff --git a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs similarity index 98% rename from src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs rename to src/api/FinancialHub.Core.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs index 97e651b..3b1244e 100644 --- a/src/FinancialHub/FinancialHub.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs +++ b/src/api/FinancialHub.Core.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs @@ -1,6 +1,6 @@ // using System; -using FinancialHub.Infra.Data.Contexts; +using FinancialHub.Core.Infra.Data.Contexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -8,7 +8,7 @@ #nullable disable -namespace FinancialHub.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Migrations.Migrations { [DbContext(typeof(FinancialHubContext))] partial class FinancialHubContextModelSnapshot : ModelSnapshot diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj b/src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj similarity index 70% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj rename to src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj index 720a625..5a5c147 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/FinancialHub.Services.NUnitTests.csproj +++ b/src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj @@ -17,9 +17,8 @@ - - - + + diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs similarity index 87% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs index 64e9ec3..7c1fa1f 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs @@ -1,11 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Results.Errors; -using Moq; -using NUnit.Framework; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class AccountBalanceServiceTests { @@ -27,7 +20,7 @@ public async Task CreateAsync_CreatesAccount() ) .Verifiable(); - var result = await this.service.CreateAsync(account); + await this.service.CreateAsync(account); this.accountsService.Verify(x => x.CreateAsync(account),Times.Once); } @@ -50,7 +43,7 @@ public async Task CreateAsync_CreatesDefaultBalance() ) .Verifiable(); - var result = await this.service.CreateAsync(account); + await this.service.CreateAsync(account); this.balanceService.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); } @@ -75,7 +68,7 @@ public async Task CreateAsync_ValidAccount_ReturnsCreatedAccount() var result = await this.service.CreateAsync(account); Assert.IsFalse(result.HasError); - Assert.AreEqual(account.Name,result.Data.Name); + Assert.AreEqual(account.Name,result.Data!.Name); Assert.AreEqual(account.Description,result.Data.Description); Assert.AreEqual(account.IsActive,result.Data.IsActive); } @@ -98,7 +91,7 @@ public async Task CreateAsync_ErrorOnCreateAccount_ReturnsError() var result = await this.service.CreateAsync(account); Assert.IsTrue(result.HasError); - Assert.AreEqual(error.Message, result.Error.Message); + Assert.AreEqual(error.Message, result.Error!.Message); } [Test] @@ -123,7 +116,7 @@ public async Task CreateAsync_ErrorOnCreateDefaultBalance_ReturnsError() var result = await this.service.CreateAsync(account); Assert.IsTrue(result.HasError); - Assert.AreEqual(error.Message, result.Error.Message); + Assert.AreEqual(error.Message, result.Error!.Message); } } } diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs similarity index 79% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs index 6ab9145..b99169f 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs @@ -1,11 +1,7 @@ -using System; -using Moq; -using NUnit.Framework; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Services.Services; -using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.Core.Domain.Interfaces.Services; +using FinancialHub.Core.Services.Services; -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class AccountBalanceServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs similarity index 96% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs index a897aed..b236d07 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs @@ -1,10 +1,4 @@ -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; -using FinancialHub.Domain.Results.Errors; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class AccountBalanceServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs similarity index 91% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs index 78413d5..70cbdc4 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs @@ -1,12 +1,4 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class AccountsServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs similarity index 71% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs index 74235e8..9f75f95 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs @@ -1,18 +1,12 @@ -using System; -using System.Collections.Generic; -using AutoMapper; -using Moq; -using NUnit.Framework; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Tests.Builders.Entities; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.Services.Mappers; -using FinancialHub.Services.Services; - -namespace FinancialHub.Services.NUnitTests.Services +using AutoMapper; +using FinancialHub.Core.Domain.Interfaces.Mappers; +using FinancialHub.Core.Domain.Interfaces.Repositories; +using FinancialHub.Core.Domain.Interfaces.Services; +using FinancialHub.Core.Domain.Tests.Builders.Entities; +using FinancialHub.Core.Services.Mappers; +using FinancialHub.Core.Services.Services; + +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class AccountsServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs similarity index 88% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs index 73531e3..1225b42 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs @@ -1,10 +1,4 @@ -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class AccountsServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs similarity index 83% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs index b45a5c0..d2ef314 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs @@ -1,14 +1,6 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.Generic; +using System.Linq; -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class AccountsServiceTests { @@ -32,7 +24,7 @@ public async Task GetByUsersAsync_ValidUser_ReturnsAccounts() Assert.IsInstanceOf>>(result); Assert.IsFalse(result.HasError); - Assert.AreEqual(entitiesMock.Count(), result.Data.Count()); + Assert.AreEqual(entitiesMock.Count, result.Data!.Count); this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); this.repository.Verify(x => x.GetAllAsync(),Times.Once()); @@ -43,8 +35,6 @@ public async Task GetByUsersAsync_ValidUser_ReturnsAccounts() [TestCase(Description = "Get by user repository exception", Category = "Get")] public void GetByUsersAsync_RepositoryException_ThrowsException() { - var entitiesMock = this.GenerateAccounts(); - var exc = new Exception("mock"); this.repository .Setup(x => x.GetAllAsync()) diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs index 234e237..eb6a8b1 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs @@ -1,12 +1,4 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class AccountsServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs similarity index 92% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs index 6170f05..478a463 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs @@ -1,11 +1,4 @@ -using System.Threading.Tasks; -using Moq; -using NUnit.Framework; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class BalancesServiceTests { @@ -91,7 +84,7 @@ public async Task CreateAsync_InvalidAccountModel_ReturnsNotFoundError() var result = await this.service.CreateAsync(model); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Account with id {model.AccountId}", result.Error.Message); + Assert.AreEqual($"Not found Account with id {model.AccountId}", result.Error!.Message); this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Never); } diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs similarity index 78% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs index 6a7d078..e5e1e31 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using AutoMapper; -using Moq; -using NUnit.Framework; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Entities; -using FinancialHub.Services.Mappers; -using FinancialHub.Services.Services; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Tests.Builders.Entities; -using FinancialHub.Domain.Tests.Builders.Models; +using AutoMapper; +using FinancialHub.Core.Domain.Interfaces.Mappers; +using FinancialHub.Core.Domain.Interfaces.Repositories; +using FinancialHub.Core.Domain.Interfaces.Services; +using FinancialHub.Core.Domain.Tests.Builders.Entities; +using FinancialHub.Core.Services.Mappers; +using FinancialHub.Core.Services.Services; -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class BalancesServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs similarity index 87% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs index 52652d5..418c37c 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs @@ -1,10 +1,4 @@ -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class BalancesServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs similarity index 85% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs index ce38553..ae84631 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs @@ -1,14 +1,4 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.Generic; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class BalancesServiceTests { @@ -34,7 +24,7 @@ public async Task GetByAccountAsync_ValidAccount_ReturnsBalances() Assert.IsInstanceOf>>(result); Assert.IsFalse(result.HasError); - Assert.AreEqual(entitiesMock.Count, result.Data.Count); + Assert.AreEqual(entitiesMock.Count, result.Data!.Count); this.repository.Verify(x => x.GetAsync(It.IsAny>()), Times.Once); } @@ -55,7 +45,7 @@ public async Task GetByIdAsync_ValidId_ReturnsBalance() Assert.IsInstanceOf>(result); Assert.IsFalse(result.HasError); - Assert.AreEqual(entity.AccountId , result.Data.AccountId); + Assert.AreEqual(entity.AccountId , result.Data!.AccountId); Assert.AreEqual(entity.Amount , result.Data.Amount); Assert.AreEqual(entity.Name , result.Data.Name); Assert.AreEqual(entity.IsActive , result.Data.IsActive); diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs similarity index 91% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs index 583177d..9f72f42 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs @@ -1,11 +1,4 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class BalancesServiceTests { @@ -25,7 +18,7 @@ public async Task UpdateAsync_ValidatesIfAccountExists() this.SetUpMapper(); - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); this.accountsRepository.Verify(x => x.GetByIdAsync(model.AccountId), Times.Once); } @@ -43,7 +36,7 @@ public async Task UpdateAsync_ValidatesIfBalanceExists() var result = await this.service.UpdateAsync(id, model); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {id}", result.Error.Message); + Assert.AreEqual($"Not found Balance with id {id}", result.Error!.Message); this.repository.Verify(x => x.GetByIdAsync(id), Times.Once); } @@ -69,7 +62,7 @@ public async Task UpdateAsync_UpdatesBalance() this.SetUpMapper(); - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); } @@ -121,7 +114,7 @@ public async Task UpdateAsync_NonExistingBalanceId_ReturnsResultError() Assert.IsInstanceOf>(result); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {model.Id}", result.Error.Message); + Assert.AreEqual($"Not found Balance with id {model.Id}", result.Error!.Message); this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); @@ -148,7 +141,7 @@ public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() Assert.IsInstanceOf>(result); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Account with id {model.AccountId}", result.Error.Message); + Assert.AreEqual($"Not found Account with id {model.AccountId}", result.Error!.Message); } } } diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs index c4cd972..ad625b0 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs @@ -1,13 +1,4 @@ -using System.Threading.Tasks; -using Moq; -using NUnit.Framework; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using System; -using FinancialHub.Domain.Results.Errors; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class BalancesServiceTests { @@ -82,7 +73,7 @@ public async Task UpdateAmountAsync_NonExistingBalanceId_ReturnsResultError() Assert.IsInstanceOf>(result); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {id}", result.Error.Message); + Assert.AreEqual($"Not found Balance with id {id}", result.Error!.Message); this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs similarity index 91% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs index 6da7689..0b48efb 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs @@ -1,12 +1,4 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class CategoriesServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs similarity index 72% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs index b90e4f3..68ad3bf 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs @@ -1,18 +1,12 @@ using AutoMapper; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Tests.Builders.Entities; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.Services.Mappers; -using FinancialHub.Services.Services; -using Moq; -using NUnit.Framework; -using System; -using System.Collections.Generic; - -namespace FinancialHub.Services.NUnitTests.Services +using FinancialHub.Core.Domain.Interfaces.Mappers; +using FinancialHub.Core.Domain.Interfaces.Repositories; +using FinancialHub.Core.Domain.Interfaces.Services; +using FinancialHub.Core.Domain.Tests.Builders.Entities; +using FinancialHub.Core.Services.Mappers; +using FinancialHub.Core.Services.Services; + +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class CategoriesServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs similarity index 89% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs index fdf3858..a61b17e 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs @@ -1,10 +1,4 @@ -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class CategoriesServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs similarity index 83% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs index ef7a1ff..5c923b2 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs @@ -1,14 +1,6 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Linq; -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class CategoriesServiceTests { @@ -33,7 +25,7 @@ public async Task GetByUsersAsync_ValidUser_ReturnsCategories() Assert.IsInstanceOf>>(result); Assert.IsFalse(result.HasError); - Assert.AreEqual(entitiesMock.Count(), result.Data.Count); + Assert.AreEqual(entitiesMock.Count(), result.Data!.Count); this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); this.repository.Verify(x => x.GetAllAsync(),Times.Once()); @@ -44,8 +36,6 @@ public async Task GetByUsersAsync_ValidUser_ReturnsCategories() [TestCase(Description = "Get by user repository exception", Category = "Get")] public void GetByUsersAsync_RepositoryException_ThrowsException() { - var entitiesMock = this.CreateCategories(); - var exc = new Exception("mock"); this.repository .Setup(x => x.GetAllAsync()) diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs index 466ce76..9599f87 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs @@ -1,12 +1,4 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class CategoriesServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs similarity index 78% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs index c77f0a6..94635c9 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs @@ -1,11 +1,7 @@ -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.Services.Services; -using Moq; -using NUnit.Framework; -using System; +using FinancialHub.Core.Domain.Interfaces.Services; +using FinancialHub.Core.Services.Services; -namespace FinancialHub.Services.NUnitTests.Services.TransactionBalance +namespace FinancialHub.Core.Services.NUnitTests.Services.TransactionBalance { public abstract class BaseTransactionBalanceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs index a743218..227744a 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs @@ -1,10 +1,6 @@ -using Moq; -using NUnit.Framework; -using System.Threading.Tasks; -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Results.Errors; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class TransactionBalanceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs new file mode 100644 index 0000000..482eb05 --- /dev/null +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs @@ -0,0 +1,9 @@ +using FinancialHub.Core.Services.NUnitTests.Services.TransactionBalance; + +namespace FinancialHub.Core.Services.NUnitTests.Services +{ + public partial class TransactionBalanceTests : BaseTransactionBalanceTests + { + + } +} diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs index 4088df6..e8df895 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs @@ -1,11 +1,6 @@ -using System; -using System.Threading.Tasks; -using Moq; -using NUnit.Framework; -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Results.Errors; - -namespace FinancialHub.Services.NUnitTests.Services +using FinancialHub.Core.Domain.Enums; + +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class TransactionBalanceTests { @@ -52,7 +47,7 @@ public async Task DeleteTransactionAsync_TransactionDeleteError_ReturnsError() var result = await this.service.DeleteTransactionAsync(id); Assert.IsTrue(result.HasError); - Assert.AreEqual(error.Message ,result.Error.Message); + Assert.AreEqual(error.Message ,result.Error!.Message); } [Test] diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs index e72c3ef..fa599d0 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs @@ -1,11 +1,6 @@ -using System; -using System.Threading.Tasks; -using Moq; -using NUnit.Framework; -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Results.Errors; - -namespace FinancialHub.Services.NUnitTests.Services +using FinancialHub.Core.Domain.Enums; + +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class TransactionBalanceTests { @@ -130,7 +125,7 @@ public async Task UpdateTransactionAsync_TransactionUpdateFailed_ReturnsUpdateEr var result = await this.service.UpdateTransactionAsync(id, newTransaction); Assert.IsTrue(result.HasError); - Assert.AreEqual(error.Message, result.Error.Message); + Assert.AreEqual(error.Message, result.Error!.Message); } } } diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs similarity index 97% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs index d589072..04d318e 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs @@ -1,19 +1,15 @@ -using FinancialHub.Domain.Enums; -using FinancialHub.Services.NUnitTests.Services.TransactionBalance; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.Services.NUnitTests.Services +using FinancialHub.Core.Domain.Enums; +using FinancialHub.Core.Services.NUnitTests.Services.TransactionBalance; + +namespace FinancialHub.Core.Services.NUnitTests.Services { //TODO: fix UpdateAmount in test names //TOOD: maybe separate some testcases public partial class TransactionBalanceTests { - class UpdateAmountAsync + public class UpdateAmountAsync { - class SameBalance : BaseTransactionBalanceTests + public class SameBalance : BaseTransactionBalanceTests { [TestCase(TransactionStatus.NotCommitted, TransactionType.Expense, true)] [TestCase(TransactionStatus.NotCommitted, TransactionType.Earn, true)] @@ -236,7 +232,7 @@ public async Task PaidToNotPaid_RemovesAmountChanges(TransactionType oldType, Tr } } - class DifferenteBalance : BaseTransactionBalanceTests + public class DifferenteBalance : BaseTransactionBalanceTests { [TestCase(TransactionType.Expense, TransactionType.Expense)] [TestCase(TransactionType.Expense, TransactionType.Earn)] diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs similarity index 90% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs index 00c724b..7f81805 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs @@ -1,12 +1,4 @@ -using System; -using System.Threading.Tasks; -using Moq; -using NUnit.Framework; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class TransactionsServiceTests { @@ -75,7 +67,7 @@ public async Task CreateAsync_InvalidCategory_ReturnsNotFoundError() var result = await this.service.CreateAsync(model); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error.Message); + Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error!.Message); } [Test] @@ -92,7 +84,7 @@ public async Task CreateAsync_InvalidBalance_ReturnsNotFoundError() var result = await this.service.CreateAsync(model); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error.Message); + Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error!.Message); } } } diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs similarity index 80% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs index c5a8991..68138c2 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs @@ -1,19 +1,12 @@ using AutoMapper; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Tests.Builders.Entities; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.Services.Mappers; -using FinancialHub.Services.Services; -using Moq; -using NUnit.Framework; -using System; -using System.Collections.Generic; +using FinancialHub.Core.Domain.Interfaces.Mappers; +using FinancialHub.Core.Domain.Interfaces.Repositories; +using FinancialHub.Core.Domain.Interfaces.Services; +using FinancialHub.Core.Domain.Tests.Builders.Entities; +using FinancialHub.Core.Services.Mappers; +using FinancialHub.Core.Services.Services; -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class TransactionsServiceTests { diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs similarity index 95% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs index beeaab6..d01b710 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs @@ -1,10 +1,6 @@ -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Results; -using Moq; -using NUnit.Framework; -using System.Threading.Tasks; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class TransactionsServiceTests { @@ -65,7 +61,7 @@ public async Task DeleteAsync_NotExistingTransaction_ReturnsNotFoundError() Assert.Zero(result.Data); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Transaction with id {guid}", result.Error.Message); + Assert.AreEqual($"Not found Transaction with id {guid}", result.Error!.Message); } [Test] diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs similarity index 81% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs index c37e3d8..d8d11d4 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs @@ -1,16 +1,8 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.Generic; -using Moq; -using NUnit.Framework; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Filters; -using FinancialHub.Domain.Queries; -using FinancialHub.Domain.Results; - -namespace FinancialHub.Services.NUnitTests.Services +using System.Linq; +using FinancialHub.Core.Domain.Filters; +using FinancialHub.Core.Domain.Queries; + +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class TransactionsServiceTests { @@ -40,7 +32,7 @@ public async Task GetByUsersAsync_ValidUser_ReturnsTransactions() Assert.IsInstanceOf>>(result); Assert.IsFalse(result.HasError); - Assert.AreEqual(entitiesMock.Count, result.Data.Count); + Assert.AreEqual(entitiesMock.Count, result.Data!.Count); } [Test] @@ -61,7 +53,7 @@ public async Task GetByIdAsync_ExistingTransaction_ReturnsTransaction() Assert.IsFalse(result.HasError); Assert.IsInstanceOf>(result); - Assert.AreEqual(transaction.Id, result.Data.Id); + Assert.AreEqual(transaction.Id, result.Data!.Id); } [Test] @@ -74,7 +66,7 @@ public async Task GetByIdAsync_NonExistingTransaction_ReturnsNotFoundError() var result = await this.service.GetByIdAsync(id); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Transaction with id {id}", result.Error.Message); + Assert.AreEqual($"Not found Transaction with id {id}", result.Error!.Message); } } } diff --git a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs similarity index 94% rename from src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs rename to src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs index 182e7ec..c7b1b95 100644 --- a/src/FinancialHub/FinancialHub.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs @@ -1,11 +1,4 @@ -using Moq; -using NUnit.Framework; -using System.Threading.Tasks; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; - -namespace FinancialHub.Services.NUnitTests.Services +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class TransactionsServiceTests { @@ -109,7 +102,7 @@ public async Task UpdateAsync_InvalidCategory_ReturnsNotFoundError() var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error.Message); + Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error!.Message); } [Test] @@ -131,7 +124,7 @@ public async Task UpdateAsync_InvalidBalance_ReturnsNotFoundError() var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error.Message); + Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error!.Message); } } } diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Usings.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Usings.cs new file mode 100644 index 0000000..b9aa359 --- /dev/null +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Usings.cs @@ -0,0 +1,19 @@ +// System namespaces +global using System; +global using System.Threading.Tasks; +global using System.Collections.Generic; + +// 3rd party test namespaces +global using NUnit.Framework; +global using Moq; + +// Domain builder tests namespaces +global using FinancialHub.Core.Domain.Tests.Builders.Models; + +// Common Project namespaces +global using FinancialHub.Common.Results; +global using FinancialHub.Common.Results.Errors; + +// Domain Project namespaces +global using FinancialHub.Core.Domain.Models; +global using FinancialHub.Core.Domain.Entities; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.Services/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Core.Services/Extensions/Configurations/IServiceCollectionExtensions.cs similarity index 76% rename from src/FinancialHub/FinancialHub.Services/Extensions/Configurations/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.Core.Services/Extensions/Configurations/IServiceCollectionExtensions.cs index 184ac18..b9f92f0 100644 --- a/src/FinancialHub/FinancialHub.Services/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/src/api/FinancialHub.Core.Services/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -1,11 +1,8 @@ using Microsoft.Extensions.DependencyInjection; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Mappers; -using FinancialHub.Services.Mappers; -using FinancialHub.Services.Services; +using FinancialHub.Core.Services.Mappers; +using FinancialHub.Core.Services.Services; -namespace FinancialHub.Services.Extensions.Configurations +namespace FinancialHub.Core.Services.Extensions.Configurations { public static class IServiceCollectionExtensions { @@ -21,6 +18,7 @@ public static IServiceCollection AddServices(this IServiceCollection services) services.AddScoped(); services.AddScoped(); + return services; } } diff --git a/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj b/src/api/FinancialHub.Core.Services/FinancialHub.Core.Services.csproj similarity index 72% rename from src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj rename to src/api/FinancialHub.Core.Services/FinancialHub.Core.Services.csproj index f3cac60..d8ce9f5 100644 --- a/src/FinancialHub/FinancialHub.Services/FinancialHub.Services.csproj +++ b/src/api/FinancialHub.Core.Services/FinancialHub.Core.Services.csproj @@ -12,7 +12,8 @@ - + + diff --git a/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs b/src/api/FinancialHub.Core.Services/Mappers/FinancialHubAutoMapperProfile.cs similarity index 75% rename from src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs rename to src/api/FinancialHub.Core.Services/Mappers/FinancialHubAutoMapperProfile.cs index c369c28..fde1334 100644 --- a/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubAutoMapperProfile.cs +++ b/src/api/FinancialHub.Core.Services/Mappers/FinancialHubAutoMapperProfile.cs @@ -1,10 +1,8 @@ using AutoMapper; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Filters; -using FinancialHub.Domain.Queries; +using FinancialHub.Core.Domain.Filters; +using FinancialHub.Core.Domain.Queries; -namespace FinancialHub.Services.Mappers +namespace FinancialHub.Core.Services.Mappers { public class FinancialHubAutoMapperProfile : Profile { diff --git a/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs b/src/api/FinancialHub.Core.Services/Mappers/FinancialHubMapperWrapper.cs similarity index 82% rename from src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs rename to src/api/FinancialHub.Core.Services/Mappers/FinancialHubMapperWrapper.cs index 821cc34..165424e 100644 --- a/src/FinancialHub/FinancialHub.Services/Mappers/FinancialHubMapperWrapper.cs +++ b/src/api/FinancialHub.Core.Services/Mappers/FinancialHubMapperWrapper.cs @@ -1,7 +1,7 @@ using AutoMapper; -using FinancialHub.Domain.Interfaces.Mappers; +using FinancialHub.Core.Domain.Interfaces.Mappers; -namespace FinancialHub.Domain.Mappers +namespace FinancialHub.Core.Services.Mappers { public class FinancialHubMapperWrapper : IMapperWrapper { diff --git a/src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs b/src/api/FinancialHub.Core.Services/Services/AccountBalanceService.cs similarity index 88% rename from src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs rename to src/api/FinancialHub.Core.Services/Services/AccountBalanceService.cs index b8dd357..b9f9064 100644 --- a/src/FinancialHub/FinancialHub.Services/Services/AccountBalanceService.cs +++ b/src/api/FinancialHub.Core.Services/Services/AccountBalanceService.cs @@ -1,8 +1,4 @@ -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; - -namespace FinancialHub.Services.Services +namespace FinancialHub.Core.Services.Services { public class AccountBalanceService : IAccountBalanceService { @@ -26,7 +22,7 @@ public async Task> CreateAsync(AccountModel account) var balance = new BalanceModel() { - Name = $"{createdAccount.Data.Name} Default Balance", + Name = $"{createdAccount.Data!.Name} Default Balance", AccountId = createdAccount.Data.Id.GetValueOrDefault(), IsActive = createdAccount.Data.IsActive }; @@ -46,7 +42,7 @@ public async Task> DeleteAsync(Guid accountId) var balances = await this.balancesService.GetAllByAccountAsync(accountId); - foreach (var balance in balances.Data) + foreach (var balance in balances.Data!) { var balanceResult = await this.balancesService.DeleteAsync(balance.Id.GetValueOrDefault()); if (balanceResult.HasError) diff --git a/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs b/src/api/FinancialHub.Core.Services/Services/AccountsService.cs similarity index 84% rename from src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs rename to src/api/FinancialHub.Core.Services/Services/AccountsService.cs index 34a6445..5dbadf0 100644 --- a/src/FinancialHub/FinancialHub.Services/Services/AccountsService.cs +++ b/src/api/FinancialHub.Core.Services/Services/AccountsService.cs @@ -1,12 +1,4 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Results.Errors; - -namespace FinancialHub.Services.Services +namespace FinancialHub.Core.Services.Services { public class AccountsService : IAccountsService { diff --git a/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs b/src/api/FinancialHub.Core.Services/Services/BalancesService.cs similarity index 91% rename from src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs rename to src/api/FinancialHub.Core.Services/Services/BalancesService.cs index f116db8..649b53e 100644 --- a/src/FinancialHub/FinancialHub.Services/Services/BalancesService.cs +++ b/src/api/FinancialHub.Core.Services/Services/BalancesService.cs @@ -1,12 +1,4 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Results.Errors; - -namespace FinancialHub.Services.Services +namespace FinancialHub.Core.Services.Services { public class BalancesService : IBalancesService { diff --git a/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs b/src/api/FinancialHub.Core.Services/Services/CategoriesService.cs similarity index 83% rename from src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs rename to src/api/FinancialHub.Core.Services/Services/CategoriesService.cs index c782c2a..f543507 100644 --- a/src/FinancialHub/FinancialHub.Services/Services/CategoriesService.cs +++ b/src/api/FinancialHub.Core.Services/Services/CategoriesService.cs @@ -1,12 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Results.Errors; - -namespace FinancialHub.Services.Services +namespace FinancialHub.Core.Services.Services { public class CategoriesService : ICategoriesService { diff --git a/src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs b/src/api/FinancialHub.Core.Services/Services/TransactionBalanceService.cs similarity index 93% rename from src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs rename to src/api/FinancialHub.Core.Services/Services/TransactionBalanceService.cs index aed6d4b..9ede95a 100644 --- a/src/FinancialHub/FinancialHub.Services/Services/TransactionBalanceService.cs +++ b/src/api/FinancialHub.Core.Services/Services/TransactionBalanceService.cs @@ -1,9 +1,6 @@ -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Enums; +using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Services.Services +namespace FinancialHub.Core.Services.Services { public class TransactionBalanceService : ITransactionBalanceService { @@ -131,7 +128,7 @@ public async Task> CreateTransactionAsync(Transa return transactionResult; } - if(transactionResult.Data.IsPaid) + if(transactionResult.Data!.IsPaid) { var balanceResult = await balancesService.GetByIdAsync(transaction.BalanceId); if(balanceResult.HasError) { @@ -140,11 +137,11 @@ public async Task> CreateTransactionAsync(Transa if (transaction.Type == TransactionType.Earn) { - await balancesService.UpdateAmountAsync(transaction.BalanceId, balanceResult.Data.Amount + transaction.Amount); + await balancesService.UpdateAmountAsync(transaction.BalanceId, balanceResult.Data!.Amount + transaction.Amount); } else { - await balancesService.UpdateAmountAsync(transaction.BalanceId, balanceResult.Data.Amount - transaction.Amount); + await balancesService.UpdateAmountAsync(transaction.BalanceId, balanceResult.Data!.Amount - transaction.Amount); } } @@ -161,8 +158,8 @@ public async Task> UpdateTransactionAsync(Guid i return transactionResult; } - var oldTransaction = oldTransactionResult.Data; - var newTransaction = transactionResult.Data; + var oldTransaction = oldTransactionResult.Data!; + var newTransaction = transactionResult.Data!; var balanceResult = await balancesService.GetByIdAsync(newTransaction.BalanceId); if (newTransaction.BalanceId == oldTransaction.BalanceId) @@ -193,7 +190,7 @@ public async Task> DeleteTransactionAsync(Guid id) if (deleted.Data == 0) return false; - var transaction = oldTransaction.Data; + var transaction = oldTransaction.Data!; if (transaction.IsPaid) { var amount = transaction.Balance.Amount; diff --git a/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs b/src/api/FinancialHub.Core.Services/Services/TransactionsService.cs similarity index 89% rename from src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs rename to src/api/FinancialHub.Core.Services/Services/TransactionsService.cs index 525f58a..4bff9d1 100644 --- a/src/FinancialHub/FinancialHub.Services/Services/TransactionsService.cs +++ b/src/api/FinancialHub.Core.Services/Services/TransactionsService.cs @@ -1,15 +1,8 @@ -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Filters; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Queries; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Interfaces.Repositories; -using FinancialHub.Domain.Interfaces.Mappers; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Results.Errors; -using FinancialHub.Domain.Enums; - -namespace FinancialHub.Services.Services +using FinancialHub.Core.Domain.Filters; +using FinancialHub.Core.Domain.Queries; +using FinancialHub.Core.Domain.Enums; + +namespace FinancialHub.Core.Services.Services { public class TransactionsService : ITransactionsService { @@ -74,7 +67,7 @@ public async Task> DeleteAsync(Guid id) { return transactionResult.Error; } - var transaction = transactionResult.Data; + var transaction = transactionResult.Data!; if (transaction.Status == TransactionStatus.Committed && transaction.IsActive) { diff --git a/src/api/FinancialHub.Core.Services/Usings.cs b/src/api/FinancialHub.Core.Services/Usings.cs new file mode 100644 index 0000000..3cc3e53 --- /dev/null +++ b/src/api/FinancialHub.Core.Services/Usings.cs @@ -0,0 +1,12 @@ +// Domain Project interfaces namespaces +global using FinancialHub.Core.Domain.Interfaces.Repositories; +global using FinancialHub.Core.Domain.Interfaces.Services; +global using FinancialHub.Core.Domain.Interfaces.Mappers; + +// Common Project namespaces +global using FinancialHub.Common.Results; +global using FinancialHub.Common.Results.Errors; + +// Domain Project entities & models namespaces +global using FinancialHub.Core.Domain.Entities; +global using FinancialHub.Core.Domain.Models; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs b/src/api/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs similarity index 94% rename from src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs rename to src/api/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs index 4cff91c..be13ee1 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs +++ b/src/api/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs @@ -1,17 +1,8 @@ using System.Net.Http; -using NUnit.Framework; -using FinancialHub.IntegrationTests.Setup; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.Domain.Model; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Tests.Builders.Entities; -using System.Threading.Tasks; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Responses.Errors; -using System; using System.Net; -using FinancialHub.IntegrationTests.Extensions; using System.Linq; +using FinancialHub.IntegrationTests.Setup; +using FinancialHub.IntegrationTests.Extensions; namespace FinancialHub.IntegrationTests.Base { diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs b/src/api/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs similarity index 95% rename from src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs rename to src/api/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs index f8dd816..c257ca6 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs +++ b/src/api/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs @@ -1,16 +1,6 @@ -using System; -using System.Net; -using System.Linq; -using NUnit.Framework; -using System.Threading.Tasks; -using FinancialHub.Domain.Models; using FinancialHub.IntegrationTests.Base; using FinancialHub.IntegrationTests.Setup; using FinancialHub.IntegrationTests.Extensions; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.Domain.Tests.Builders.Entities; namespace FinancialHub.IntegrationTests { diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs b/src/api/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs similarity index 94% rename from src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs rename to src/api/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs index 719b7d0..6814a8a 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs +++ b/src/api/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs @@ -1,17 +1,6 @@ -using System; -using System.Net; -using System.Threading.Tasks; -using System.Linq; -using NUnit.Framework; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Tests.Builders.Entities; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.IntegrationTests.Base; +using FinancialHub.IntegrationTests.Base; using FinancialHub.IntegrationTests.Setup; using FinancialHub.IntegrationTests.Extensions; -using FinancialHub.Domain.Entities; -using FinancialHub.Domain.Responses.Errors; namespace FinancialHub.IntegrationTests { diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs b/src/api/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs similarity index 93% rename from src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs rename to src/api/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs index bdbe2d8..a19f159 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs +++ b/src/api/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs @@ -1,15 +1,5 @@ -using System; -using System.Net; -using System.Linq; -using NUnit.Framework; -using System.Threading.Tasks; -using FinancialHub.Domain.Models; using FinancialHub.IntegrationTests.Base; using FinancialHub.IntegrationTests.Setup; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.Domain.Tests.Builders.Entities; using FinancialHub.IntegrationTests.Extensions; namespace FinancialHub.IntegrationTests diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs b/src/api/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs similarity index 96% rename from src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs rename to src/api/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs index 8d82d91..e859e3c 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs +++ b/src/api/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs @@ -1,16 +1,6 @@ -using System; -using System.Net; -using System.Linq; -using NUnit.Framework; -using System.Threading.Tasks; using FinancialHub.IntegrationTests.Base; using FinancialHub.IntegrationTests.Setup; using FinancialHub.IntegrationTests.Extensions; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.Domain.Tests.Builders.Entities; namespace FinancialHub.IntegrationTests { diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs b/src/api/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs similarity index 96% rename from src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs rename to src/api/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs index e9b2594..605a30b 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs +++ b/src/api/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs @@ -1,7 +1,6 @@ using System.Net.Http; using System.Text; using System.Text.Json; -using System.Threading.Tasks; namespace FinancialHub.IntegrationTests.Extensions { diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs b/src/api/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs similarity index 92% rename from src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs rename to src/api/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs index a76dd82..3b508fd 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs +++ b/src/api/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs @@ -1,7 +1,5 @@ -using System; -using System.Net.Http; +using System.Net.Http; using System.Text.Json; -using System.Threading.Tasks; namespace FinancialHub.IntegrationTests.Extensions { diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs b/src/api/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs similarity index 98% rename from src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs index 443f84e..9605d5f 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs +++ b/src/api/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs @@ -1,7 +1,6 @@ using FinancialHub.IntegrationTests.Setup; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; -using System.Linq; namespace FinancialHub.IntegrationTests.Extensions { diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj b/src/api/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj similarity index 82% rename from src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj rename to src/api/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj index 5f71212..c1bd05c 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj +++ b/src/api/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj @@ -19,7 +19,8 @@ - + + diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs b/src/api/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs similarity index 97% rename from src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs rename to src/api/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs index c742f69..7df962e 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs +++ b/src/api/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Runtime.InteropServices; namespace FinancialHub.IntegrationTests.Setup diff --git a/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs b/src/api/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs similarity index 92% rename from src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs rename to src/api/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs index 1afa026..be080df 100644 --- a/src/FinancialHub/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs +++ b/src/api/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs @@ -1,15 +1,10 @@ -using System; -using System.Linq; -using System.Net.Http; +using System.Net.Http; +using System.Collections; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; using FinancialHub.WebApi; -using FinancialHub.Infra.Data.Contexts; -using FinancialHub.Domain.Entities; -using System.Collections; +using FinancialHub.Core.Infra.Data.Contexts; using FinancialHub.IntegrationTests.Extensions; -using System.Collections.Generic; -using FinancialHub.Services.Mappers; namespace FinancialHub.IntegrationTests.Setup { diff --git a/src/api/FinancialHub.IntegrationTests/Usings.cs b/src/api/FinancialHub.IntegrationTests/Usings.cs new file mode 100644 index 0000000..11aea14 --- /dev/null +++ b/src/api/FinancialHub.IntegrationTests/Usings.cs @@ -0,0 +1,30 @@ +// System namespaces +global using System; +global using System.Net; +global using System.Linq; +global using System.Collections.Generic; +global using System.Threading.Tasks; + +// 3rd party test namespaces +global using NUnit.Framework; + +// Common models namespaces +global using FinancialHub.Common.Models; +global using FinancialHub.Common.Entities; + +// Domain models namespaces +global using FinancialHub.Core.Domain.Models; +global using FinancialHub.Core.Domain.Entities; + +// Common Responses namespaces +global using FinancialHub.Common.Responses.Success; +global using FinancialHub.Common.Responses.Errors; + +// Common Builders namespaces +global using FinancialHub.Common.Tests.Builders.Models; +global using FinancialHub.Common.Tests.Builders.Entities; + +// Domain Builders namespaces +global using FinancialHub.Core.Domain.Tests.Builders.Models; +global using FinancialHub.Core.Domain.Tests.Builders.Entities; + diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs similarity index 82% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs index 38469f5..703cecf 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs @@ -1,15 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results.Errors; -using Microsoft.AspNetCore.Mvc; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { @@ -60,7 +49,7 @@ public async Task CreateAccount_ServiceError_ReturnsBadRequest() Assert.IsInstanceOf(result?.Value); var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); this.mockAccountService.Verify(x => x.CreateAsync(body), Times.Once); diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs similarity index 80% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs index c63f396..1cdfe4d 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs @@ -1,9 +1,5 @@ -using Moq; -using NUnit.Framework; -using FinancialHub.WebApi.Controllers; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Tests.Builders.Models; -using System; +using FinancialHub.WebApi.Controllers; +using FinancialHub.Core.Domain.Interfaces.Services; namespace FinancialHub.WebApi.NUnitTests.Controllers { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs similarity index 78% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs index f47cb07..cb1a590 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs @@ -1,8 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using NUnit.Framework; -using System.Threading.Tasks; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs similarity index 77% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs index 329b56a..bd88cde 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs @@ -1,13 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using Moq; -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs similarity index 83% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs index dfd95c7..be1c800 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs @@ -1,15 +1,4 @@ -using System; -using System.Threading.Tasks; -using NUnit.Framework; -using Moq; -using Microsoft.AspNetCore.Mvc; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Results.Errors; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { @@ -62,7 +51,7 @@ public async Task UpdateAccount_Invalid_ReturnsBadRequest() Assert.IsInstanceOf(result?.Value); var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs similarity index 84% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs index cd80f89..53a2bc7 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs @@ -1,15 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results.Errors; -using Microsoft.AspNetCore.Mvc; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class BalancesControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs similarity index 76% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs index abe26a8..82c1441 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs @@ -1,9 +1,5 @@ -using Moq; -using NUnit.Framework; -using FinancialHub.WebApi.Controllers; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Tests.Builders.Models; -using System; +using FinancialHub.WebApi.Controllers; +using FinancialHub.Core.Domain.Interfaces.Services; namespace FinancialHub.WebApi.NUnitTests.Controllers { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs similarity index 74% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs index 703ab02..ff7f157 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs @@ -1,8 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using NUnit.Framework; -using System.Threading.Tasks; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class BalancesControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs similarity index 85% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs index 65b3094..b65c664 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs @@ -1,15 +1,4 @@ -using System; -using System.Threading.Tasks; -using NUnit.Framework; -using Moq; -using Microsoft.AspNetCore.Mvc; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Results.Errors; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class BalancesControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs similarity index 85% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs index a1ea546..b461a11 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs @@ -1,15 +1,4 @@ -using Moq; -using System; -using System.Threading.Tasks; -using NUnit.Framework; -using Microsoft.AspNetCore.Mvc; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results.Errors; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs similarity index 77% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs index 1c6b068..ecfa17c 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs @@ -1,9 +1,5 @@ -using Moq; -using System; -using NUnit.Framework; -using FinancialHub.WebApi.Controllers; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.WebApi.Controllers; +using FinancialHub.Core.Domain.Interfaces.Services; namespace FinancialHub.WebApi.NUnitTests.Controllers { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs similarity index 78% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs index 355f8cf..7640248 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs @@ -1,8 +1,4 @@ -using NUnit.Framework; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs similarity index 77% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs index 1c94956..962fbe7 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs @@ -1,13 +1,4 @@ -using NUnit.Framework; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Moq; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs similarity index 86% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs index 1f26cec..7724175 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs @@ -1,15 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Results.Errors; -using Microsoft.AspNetCore.Mvc; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs similarity index 86% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs index 42d5040..df6a8f5 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs @@ -1,15 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results.Errors; -using Microsoft.AspNetCore.Mvc; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs similarity index 82% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs index c8e8ffc..5e71dcd 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs @@ -1,9 +1,5 @@ -using Moq; -using System; -using NUnit.Framework; -using FinancialHub.WebApi.Controllers; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.WebApi.Controllers; +using FinancialHub.Core.Domain.Interfaces.Services; namespace FinancialHub.WebApi.NUnitTests.Controllers { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs similarity index 79% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs index f64deb2..2f7676b 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs @@ -1,8 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using NUnit.Framework; -using System.Threading.Tasks; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs similarity index 80% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs index d639ac6..2672657 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs @@ -1,12 +1,4 @@ -using FinancialHub.Domain.Filters; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results; -using Microsoft.AspNetCore.Mvc; -using Moq; -using NUnit.Framework; -using System.Collections.Generic; -using System.Threading.Tasks; +using FinancialHub.Core.Domain.Filters; namespace FinancialHub.WebApi.NUnitTests.Controllers { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs similarity index 86% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs index 34e7373..a7dbcad 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs @@ -1,15 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results; -using FinancialHub.Domain.Results.Errors; -using Microsoft.AspNetCore.Mvc; -using Moq; -using NUnit.Framework; -using System; -using System.Threading.Tasks; - -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.WebApi.NUnitTests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj b/src/api/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj similarity index 78% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj rename to src/api/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj index 98e77fb..fa21fb4 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj +++ b/src/api/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj @@ -16,8 +16,7 @@ - - + diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Usings.cs b/src/api/FinancialHub.WebApi.NUnitTests/Usings.cs new file mode 100644 index 0000000..3dbec46 --- /dev/null +++ b/src/api/FinancialHub.WebApi.NUnitTests/Usings.cs @@ -0,0 +1,25 @@ +// System namespaces +global using System; +global using System.Collections.Generic; +global using System.Threading.Tasks; + +// Asp.Net namespaces +global using Microsoft.AspNetCore.Mvc; + +// 3rd party test namespaces +global using Moq; +global using NUnit.Framework; + +// Domain Project tests namespaces +global using FinancialHub.Core.Domain.Tests.Builders.Models; + +// Domain Model namespaces +global using FinancialHub.Core.Domain.Models; + +// Common Result namespaces +global using FinancialHub.Common.Results; +global using FinancialHub.Common.Results.Errors; + +// Common Response namespaces +global using FinancialHub.Common.Responses.Errors; +global using FinancialHub.Common.Responses.Success; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs b/src/api/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs similarity index 95% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs index d6770e3..ba30d62 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs @@ -1,6 +1,4 @@ -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.WebApi.Validators; -using NUnit.Framework; +using FinancialHub.WebApi.Validators; namespace FinancialHub.WebApi.NUnitTests.Validators { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs b/src/api/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs similarity index 95% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs index a2c9d62..e09f054 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs @@ -1,7 +1,4 @@ -using NUnit.Framework; -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.WebApi.Validators; -using System; +using FinancialHub.WebApi.Validators; namespace FinancialHub.WebApi.NUnitTests.Validators { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs b/src/api/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs similarity index 95% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs index 583967b..f154179 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs @@ -1,6 +1,4 @@ -using FinancialHub.Domain.Tests.Builders.Models; -using FinancialHub.WebApi.Validators; -using NUnit.Framework; +using FinancialHub.WebApi.Validators; namespace FinancialHub.WebApi.NUnitTests.Validators { diff --git a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs b/src/api/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs similarity index 96% rename from src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs rename to src/api/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs index 0d82eae..93cfc2b 100644 --- a/src/FinancialHub/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs +++ b/src/api/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs @@ -1,7 +1,5 @@ -using FinancialHub.Domain.Enums; -using FinancialHub.Domain.Tests.Builders.Models; +using FinancialHub.Core.Domain.Enums; using FinancialHub.WebApi.Validators; -using NUnit.Framework; namespace FinancialHub.WebApi.NUnitTests.Validators { diff --git a/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs b/src/api/FinancialHub.WebApi/Controllers/AccountsController.cs similarity index 92% rename from src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs rename to src/api/FinancialHub.WebApi/Controllers/AccountsController.cs index 36c50af..6bb4f35 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Controllers/AccountsController.cs +++ b/src/api/FinancialHub.WebApi/Controllers/AccountsController.cs @@ -1,12 +1,4 @@ -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; - -namespace FinancialHub.WebApi.Controllers +namespace FinancialHub.WebApi.Controllers { [ApiController] [Route("[controller]")] diff --git a/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs b/src/api/FinancialHub.WebApi/Controllers/BalancesController.cs similarity index 87% rename from src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs rename to src/api/FinancialHub.WebApi/Controllers/BalancesController.cs index ad14152..3edd063 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Controllers/BalancesController.cs +++ b/src/api/FinancialHub.WebApi/Controllers/BalancesController.cs @@ -1,12 +1,4 @@ -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Responses.Errors; - -namespace FinancialHub.WebApi.Controllers +namespace FinancialHub.WebApi.Controllers { [ApiController] [Route("[controller]")] diff --git a/src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs b/src/api/FinancialHub.WebApi/Controllers/Base/BaseController.cs similarity index 82% rename from src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs rename to src/api/FinancialHub.WebApi/Controllers/Base/BaseController.cs index ba1e19c..a27f03f 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Controllers/Base/BaseController.cs +++ b/src/api/FinancialHub.WebApi/Controllers/Base/BaseController.cs @@ -1,7 +1,4 @@ -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Results; -using Microsoft.AspNetCore.Mvc; -using System.Collections.Generic; +using FinancialHub.Common.Results; namespace FinancialHub.WebApi.Controllers.Base { diff --git a/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs b/src/api/FinancialHub.WebApi/Controllers/CategoriesController.cs similarity index 90% rename from src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs rename to src/api/FinancialHub.WebApi/Controllers/CategoriesController.cs index 2b168c1..b0635e4 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Controllers/CategoriesController.cs +++ b/src/api/FinancialHub.WebApi/Controllers/CategoriesController.cs @@ -1,12 +1,4 @@ -using FinancialHub.Domain.Interfaces.Services; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Models; -using Microsoft.AspNetCore.Mvc; -using System.Threading.Tasks; -using System; - -namespace FinancialHub.WebApi.Controllers +namespace FinancialHub.WebApi.Controllers { [ApiController] [Route("[controller]")] diff --git a/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs b/src/api/FinancialHub.WebApi/Controllers/TransactionsController.cs similarity index 92% rename from src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs rename to src/api/FinancialHub.WebApi/Controllers/TransactionsController.cs index 761dcfc..fc61aba 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Controllers/TransactionsController.cs +++ b/src/api/FinancialHub.WebApi/Controllers/TransactionsController.cs @@ -1,11 +1,4 @@ -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using FinancialHub.Domain.Models; -using FinancialHub.Domain.Filters; -using FinancialHub.Domain.Responses.Errors; -using FinancialHub.Domain.Responses.Success; -using FinancialHub.Domain.Interfaces.Services; +using FinancialHub.Core.Domain.Filters; namespace FinancialHub.WebApi.Controllers { diff --git a/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs similarity index 92% rename from src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs index 3108109..f7becec 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/src/api/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -1,9 +1,7 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using FluentValidation; using FluentValidation.AspNetCore; using Microsoft.OpenApi.Models; -using FinancialHub.Domain.Models; using FinancialHub.WebApi.Validators; namespace FinancialHub.WebApi.Extensions.Configurations diff --git a/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/src/api/FinancialHub.WebApi/FinancialHub.WebApi.csproj similarity index 85% rename from src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj rename to src/api/FinancialHub.WebApi/FinancialHub.WebApi.csproj index 3759289..1b95d64 100644 --- a/src/FinancialHub/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/src/api/FinancialHub.WebApi/FinancialHub.WebApi.csproj @@ -24,9 +24,8 @@ - - - + + diff --git a/src/FinancialHub/FinancialHub.WebApi/Program.cs b/src/api/FinancialHub.WebApi/Program.cs similarity index 100% rename from src/FinancialHub/FinancialHub.WebApi/Program.cs rename to src/api/FinancialHub.WebApi/Program.cs diff --git a/src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json b/src/api/FinancialHub.WebApi/Properties/launchSettings.json similarity index 100% rename from src/FinancialHub/FinancialHub.WebApi/Properties/launchSettings.json rename to src/api/FinancialHub.WebApi/Properties/launchSettings.json diff --git a/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs b/src/api/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs similarity index 100% rename from src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs rename to src/api/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs diff --git a/src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx b/src/api/FinancialHub.WebApi/Resources/ErrorMessages.resx similarity index 100% rename from src/FinancialHub/FinancialHub.WebApi/Resources/ErrorMessages.resx rename to src/api/FinancialHub.WebApi/Resources/ErrorMessages.resx diff --git a/src/FinancialHub/FinancialHub.WebApi/Startup.cs b/src/api/FinancialHub.WebApi/Startup.cs similarity index 90% rename from src/FinancialHub/FinancialHub.WebApi/Startup.cs rename to src/api/FinancialHub.WebApi/Startup.cs index f91fdc5..9bbb997 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Startup.cs +++ b/src/api/FinancialHub.WebApi/Startup.cs @@ -3,10 +3,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.OpenApi.Models; using FinancialHub.WebApi.Extensions.Configurations; -using FinancialHub.Infra.Data.Extensions.Configurations; -using FinancialHub.Services.Extensions.Configurations; +using FinancialHub.Core.Infra.Data.Extensions.Configurations; +using FinancialHub.Core.Services.Extensions.Configurations; namespace FinancialHub.WebApi { diff --git a/src/api/FinancialHub.WebApi/Usings.cs b/src/api/FinancialHub.WebApi/Usings.cs new file mode 100644 index 0000000..4eec32d --- /dev/null +++ b/src/api/FinancialHub.WebApi/Usings.cs @@ -0,0 +1,17 @@ +// System namespaces +global using System; +global using System.Collections.Generic; +global using System.Threading.Tasks; + +// Asp.Net namespaces +global using Microsoft.AspNetCore.Mvc; + +// Domain Models namespaces +global using FinancialHub.Core.Domain.Models; + +// Domain Interfaces namespaces +global using FinancialHub.Core.Domain.Interfaces.Services; + +// Common Response namespaces +global using FinancialHub.Common.Responses.Success; +global using FinancialHub.Common.Responses.Errors; \ No newline at end of file diff --git a/src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs b/src/api/FinancialHub.WebApi/Validators/AccountValidator.cs similarity index 88% rename from src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs rename to src/api/FinancialHub.WebApi/Validators/AccountValidator.cs index 5b31e68..e335931 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Validators/AccountValidator.cs +++ b/src/api/FinancialHub.WebApi/Validators/AccountValidator.cs @@ -1,5 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.WebApi.Resources; +using FinancialHub.WebApi.Resources; using FluentValidation; namespace FinancialHub.WebApi.Validators diff --git a/src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs b/src/api/FinancialHub.WebApi/Validators/BalanceValidator.cs similarity index 87% rename from src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs rename to src/api/FinancialHub.WebApi/Validators/BalanceValidator.cs index 4f688a9..6f3ef33 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Validators/BalanceValidator.cs +++ b/src/api/FinancialHub.WebApi/Validators/BalanceValidator.cs @@ -1,5 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.WebApi.Resources; +using FinancialHub.WebApi.Resources; using FluentValidation; namespace FinancialHub.WebApi.Validators diff --git a/src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs b/src/api/FinancialHub.WebApi/Validators/CategoryValidator.cs similarity index 88% rename from src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs rename to src/api/FinancialHub.WebApi/Validators/CategoryValidator.cs index 08ab766..c86b7ce 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Validators/CategoryValidator.cs +++ b/src/api/FinancialHub.WebApi/Validators/CategoryValidator.cs @@ -1,5 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.WebApi.Resources; +using FinancialHub.WebApi.Resources; using FluentValidation; namespace FinancialHub.WebApi.Validators diff --git a/src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs b/src/api/FinancialHub.WebApi/Validators/TransactionValidator.cs similarity index 90% rename from src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs rename to src/api/FinancialHub.WebApi/Validators/TransactionValidator.cs index 3096473..3b6167f 100644 --- a/src/FinancialHub/FinancialHub.WebApi/Validators/TransactionValidator.cs +++ b/src/api/FinancialHub.WebApi/Validators/TransactionValidator.cs @@ -1,5 +1,4 @@ -using FinancialHub.Domain.Models; -using FinancialHub.WebApi.Resources; +using FinancialHub.WebApi.Resources; using FluentValidation; namespace FinancialHub.WebApi.Validators diff --git a/src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json b/src/api/FinancialHub.WebApi/appsettings.Development.json similarity index 100% rename from src/FinancialHub/FinancialHub.WebApi/appsettings.Development.json rename to src/api/FinancialHub.WebApi/appsettings.Development.json diff --git a/src/FinancialHub/FinancialHub.WebApi/appsettings.json b/src/api/FinancialHub.WebApi/appsettings.json similarity index 100% rename from src/FinancialHub/FinancialHub.WebApi/appsettings.json rename to src/api/FinancialHub.WebApi/appsettings.json diff --git a/src/FinancialHub/FinancialHub.sln b/src/api/FinancialHub.sln similarity index 73% rename from src/FinancialHub/FinancialHub.sln rename to src/api/FinancialHub.sln index cf386d2..43944e6 100644 --- a/src/FinancialHub/FinancialHub.sln +++ b/src/api/FinancialHub.sln @@ -3,24 +3,16 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain", "FinancialHub.Domain\FinancialHub.Domain.csproj", "{776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{1F4F43B0-14F5-4C91-B98C-AEB8A5421258}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{2444FB9D-15D1-4193-BF04-83C4397369DA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{91A212DC-1D96-43DD-B1A0-153ACB6980D5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data", "FinancialHub.Infra.Data\FinancialHub.Infra.Data.csproj", "{19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Data.NUnitTests", "FinancialHub.Infra.Data.NUnitTests\FinancialHub.Infra.Data.NUnitTests.csproj", "{5A26CFA8-B077-4C91-BED9-C47339F960A2}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi.NUnitTests", "FinancialHub.WebApi.NUnitTests\FinancialHub.WebApi.NUnitTests.csproj", "{40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.IntegrationTests", "FinancialHub.IntegrationTests\FinancialHub.IntegrationTests.csproj", "{B6694C5F-1BCF-460D-B9EA-39A49849737A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Infra.Migrations", "FinancialHub.Infra.Migrations\FinancialHub.Infra.Migrations.csproj", "{7ED57B2C-520B-4A25-B3C1-268EEA48CADB}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{8AFE509C-0DD0-4C85-8BEA-24FB599293D7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Migrations", "Migrations", "{EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E}" @@ -51,14 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Dat EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Tests", "FinancialHub.Auth.Infra.Tests\FinancialHub.Auth.Infra.Tests.csproj", "{A4D904E8-5A38-4E00-8419-62CB1F24F94E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services.NUnitTests", "FinancialHub.Services.NUnitTests\FinancialHub.Services.NUnitTests.csproj", "{43423E19-2F4B-4A94-B8A7-4D2803D16A6E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{F6444C4B-6609-40E3-8D09-C52D871C5160}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Domain.Tests", "FinancialHub.Domain.Tests\FinancialHub.Domain.Tests.csproj", "{98A9979A-23A4-4DAA-917C-6F37794E0D06}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Services", "FinancialHub.Services\FinancialHub.Services.csproj", "{2483A335-88C1-4413-9AB7-5AE0C67BBA23}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Resources", "FinancialHub.Auth.Resources\FinancialHub.Auth.Resources.csproj", "{8B091A42-5BE6-49A4-8086-C8761E0CE769}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{421DB63D-B9E6-4069-8B79-6C956506F3C5}" @@ -73,24 +59,34 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Applicati EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application.Tests", "FinancialHub.Auth.Application.Tests\FinancialHub.Auth.Application.Tests.csproj", "{22448D38-BA25-4FAE-9337-BEA884C7EC57}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{B00013E6-DB9F-415A-B542-6D32DA258EB2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common.Tests", "FinancialHub.Common.Tests\FinancialHub.Common.Tests.csproj", "{AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common", "FinancialHub.Common\FinancialHub.Common.csproj", "{83866048-B248-4D23-9716-559AB5A5E860}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data", "FinancialHub.Core.Infra.Data\FinancialHub.Core.Infra.Data.csproj", "{4B4B713A-4134-4221-A62A-7597FE72694C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data.NUnitTests", "FinancialHub.Core.Infra.Data.NUnitTests\FinancialHub.Core.Infra.Data.NUnitTests.csproj", "{2ED0A937-8026-4CCF-820A-5C2D10401AFC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Migrations", "FinancialHub.Core.Infra.Migrations\FinancialHub.Core.Infra.Migrations.csproj", "{15162FAE-26C6-4335-9919-762278E53DEF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Services", "FinancialHub.Core.Services\FinancialHub.Core.Services.csproj", "{FBB12706-8963-46AF-A0B2-4095939BB007}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Services.NUnitTests", "FinancialHub.Core.Services.NUnitTests\FinancialHub.Core.Services.NUnitTests.csproj", "{9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain", "FinancialHub.Core.Domain\FinancialHub.Core.Domain.csproj", "{84D15870-8431-49D4-A075-9BA5D9B0CF0A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain.Tests", "FinancialHub.Core.Domain.Tests\FinancialHub.Core.Domain.Tests.csproj", "{2E731A85-ED5E-4826-93E0-239F012C7DC4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A}.Release|Any CPU.Build.0 = Release|Any CPU - {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3}.Release|Any CPU.Build.0 = Release|Any CPU - {5A26CFA8-B077-4C91-BED9-C47339F960A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5A26CFA8-B077-4C91-BED9-C47339F960A2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5A26CFA8-B077-4C91-BED9-C47339F960A2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5A26CFA8-B077-4C91-BED9-C47339F960A2}.Release|Any CPU.Build.0 = Release|Any CPU {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Debug|Any CPU.Build.0 = Debug|Any CPU {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -99,10 +95,6 @@ Global {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Release|Any CPU.Build.0 = Release|Any CPU - {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7ED57B2C-520B-4A25-B3C1-268EEA48CADB}.Release|Any CPU.Build.0 = Release|Any CPU {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Debug|Any CPU.Build.0 = Debug|Any CPU {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -131,22 +123,10 @@ Global {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.ActiveCfg = Release|Any CPU {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.Build.0 = Release|Any CPU - {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {43423E19-2F4B-4A94-B8A7-4D2803D16A6E}.Release|Any CPU.Build.0 = Release|Any CPU {F6444C4B-6609-40E3-8D09-C52D871C5160}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F6444C4B-6609-40E3-8D09-C52D871C5160}.Debug|Any CPU.Build.0 = Debug|Any CPU {F6444C4B-6609-40E3-8D09-C52D871C5160}.Release|Any CPU.ActiveCfg = Release|Any CPU {F6444C4B-6609-40E3-8D09-C52D871C5160}.Release|Any CPU.Build.0 = Release|Any CPU - {98A9979A-23A4-4DAA-917C-6F37794E0D06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {98A9979A-23A4-4DAA-917C-6F37794E0D06}.Debug|Any CPU.Build.0 = Debug|Any CPU - {98A9979A-23A4-4DAA-917C-6F37794E0D06}.Release|Any CPU.ActiveCfg = Release|Any CPU - {98A9979A-23A4-4DAA-917C-6F37794E0D06}.Release|Any CPU.Build.0 = Release|Any CPU - {2483A335-88C1-4413-9AB7-5AE0C67BBA23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2483A335-88C1-4413-9AB7-5AE0C67BBA23}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2483A335-88C1-4413-9AB7-5AE0C67BBA23}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2483A335-88C1-4413-9AB7-5AE0C67BBA23}.Release|Any CPU.Build.0 = Release|Any CPU {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Debug|Any CPU.Build.0 = Debug|Any CPU {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -171,18 +151,52 @@ Global {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Debug|Any CPU.Build.0 = Debug|Any CPU {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Release|Any CPU.ActiveCfg = Release|Any CPU {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Release|Any CPU.Build.0 = Release|Any CPU + {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}.Release|Any CPU.Build.0 = Release|Any CPU + {83866048-B248-4D23-9716-559AB5A5E860}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83866048-B248-4D23-9716-559AB5A5E860}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83866048-B248-4D23-9716-559AB5A5E860}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83866048-B248-4D23-9716-559AB5A5E860}.Release|Any CPU.Build.0 = Release|Any CPU + {4B4B713A-4134-4221-A62A-7597FE72694C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B4B713A-4134-4221-A62A-7597FE72694C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B4B713A-4134-4221-A62A-7597FE72694C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B4B713A-4134-4221-A62A-7597FE72694C}.Release|Any CPU.Build.0 = Release|Any CPU + {2ED0A937-8026-4CCF-820A-5C2D10401AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2ED0A937-8026-4CCF-820A-5C2D10401AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2ED0A937-8026-4CCF-820A-5C2D10401AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2ED0A937-8026-4CCF-820A-5C2D10401AFC}.Release|Any CPU.Build.0 = Release|Any CPU + {15162FAE-26C6-4335-9919-762278E53DEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15162FAE-26C6-4335-9919-762278E53DEF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15162FAE-26C6-4335-9919-762278E53DEF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15162FAE-26C6-4335-9919-762278E53DEF}.Release|Any CPU.Build.0 = Release|Any CPU + {FBB12706-8963-46AF-A0B2-4095939BB007}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FBB12706-8963-46AF-A0B2-4095939BB007}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FBB12706-8963-46AF-A0B2-4095939BB007}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FBB12706-8963-46AF-A0B2-4095939BB007}.Release|Any CPU.Build.0 = Release|Any CPU + {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}.Release|Any CPU.Build.0 = Release|Any CPU + {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Release|Any CPU.Build.0 = Release|Any CPU + {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {776EA70E-D7ED-4A92-AB2F-0C7CDE3B5B7A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {2444FB9D-15D1-4193-BF04-83C4397369DA} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {91A212DC-1D96-43DD-B1A0-153ACB6980D5} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} - {19E36296-E7CC-4D88-8F72-5B13ABE9A4E3} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} - {5A26CFA8-B077-4C91-BED9-C47339F960A2} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} - {7ED57B2C-520B-4A25-B3C1-268EEA48CADB} = {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} + {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} + {B6694C5F-1BCF-460D-B9EA-39A49849737A} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} = {2444FB9D-15D1-4193-BF04-83C4397369DA} {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} = {2444FB9D-15D1-4193-BF04-83C4397369DA} {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} @@ -196,9 +210,7 @@ Global {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} {72C9C13F-BF8B-4649-B504-99E634FCDDE5} = {74BFDE19-E416-46A1-B9C2-878DA41B249A} {A4D904E8-5A38-4E00-8419-62CB1F24F94E} = {B918D713-0701-447C-B403-10DE0C769581} - {43423E19-2F4B-4A94-B8A7-4D2803D16A6E} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} - {98A9979A-23A4-4DAA-917C-6F37794E0D06} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} - {2483A335-88C1-4413-9AB7-5AE0C67BBA23} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {F6444C4B-6609-40E3-8D09-C52D871C5160} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} {8B091A42-5BE6-49A4-8086-C8761E0CE769} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} {421DB63D-B9E6-4069-8B79-6C956506F3C5} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} {DD87106B-71B2-484D-A2CA-6ADD69C69CC7} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} @@ -206,6 +218,16 @@ Global {F6C7E760-0264-425B-A935-35C19701B428} = {421DB63D-B9E6-4069-8B79-6C956506F3C5} {C36391AC-AC61-4165-9C00-0B2B4ED78C8D} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} {22448D38-BA25-4FAE-9337-BEA884C7EC57} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} + {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} + {83866048-B248-4D23-9716-559AB5A5E860} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} + {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} + {4B4B713A-4134-4221-A62A-7597FE72694C} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} + {2ED0A937-8026-4CCF-820A-5C2D10401AFC} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} + {15162FAE-26C6-4335-9919-762278E53DEF} = {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} + {FBB12706-8963-46AF-A0B2-4095939BB007} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {84D15870-8431-49D4-A075-9BA5D9B0CF0A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} + {2E731A85-ED5E-4826-93E0-239F012C7DC4} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} diff --git a/src/FinancialHub/docker-compose.yml b/src/api/docker-compose.yml similarity index 100% rename from src/FinancialHub/docker-compose.yml rename to src/api/docker-compose.yml diff --git a/docs/database/financial-hub_DDL.sql b/src/database/financial-hub_DDL.sql similarity index 100% rename from docs/database/financial-hub_DDL.sql rename to src/database/financial-hub_DDL.sql From b91473a5e1f38c53f107a5f77b55abcc5864f31b Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Fri, 18 Aug 2023 20:43:13 -0300 Subject: [PATCH 20/30] Release v0.5.1 * Add Testing configuration to Core.Integration tests * Update NUnit to 3.13.3 in Core Projects * Break complex unit tests from TransactionRepository * Moves BaseResponseAssert to Common Project * Moves Model Assertions to Core.Domain.Tests * Rename FinancialHub.WebApi to FinancialHub.Core.WebApi * Rename FinancialHub.WebApi unit and integration tests to * Removes BaseControllerTests class * Removes unit tests with exceptions from AccountsService, CategoriesService and TransactionRepository * Fix Core project unit and integration tests * Fix BaseRepository unit tests --- .../Asserts/ControllerResponseAssert.cs | 8 +- .../FinancialHub.Auth.Tests.Common/Usings.cs | 4 +- .../Responses/BaseResponseAssert.cs} | 5 +- .../FinancialHub.Common.Tests.csproj | 1 + .../Entities/BalanceEntityAssert.cs | 19 ++ .../Assertions/Models/AccountModelAssert.cs | 12 ++ .../Assertions/Models/BalanceModelAssert.cs | 19 ++ .../Assertions/Models/CategoryModelAssert.cs | 12 ++ .../Models/TransactionModelAssert.cs | 17 ++ .../FinancialHub.Core.Domain.Tests.csproj | 2 +- .../FinancialHub.Core.Domain.Tests/Usings.cs | 3 + ...ncialHub.Core.Infra.Data.NUnitTests.csproj | 2 +- .../Base/BaseRepositoryTests.delete.cs | 12 +- .../Base/BaseRepositoryTests.get.cs | 25 +-- .../TransactionsRepositoryTests.create.cs | 48 +++-- .../TransactionsRepositoryTests.delete.cs | 21 +- .../TransactionsRepositoryTests.update.cs | 30 ++- .../Base/BaseControllerTests.cs | 33 +++ .../Controllers/AccountsControllerTests.cs | 19 +- .../Controllers/BalancesControllerTests.cs | 26 +-- .../Controllers/CategoriesControllerTests.cs | 20 +- .../TransactionsControllerTests.cs | 79 ++------ .../Extensions/HttpClientExtensions.cs | 2 +- .../HttpResponseMessageExtensions.cs | 2 +- ...FinancialHub.Core.IntegrationTests.csproj} | 4 +- .../Setup/FinancialHubFixture.cs | 11 +- .../Usings.cs | 11 +- ...nancialHub.Core.Services.NUnitTests.csproj | 2 +- .../AccountBalanceServiceTests.create.cs | 8 +- .../Accounts/AccountsServiceTests.create.cs | 30 --- .../Accounts/AccountsServiceTests.delete.cs | 19 -- .../Accounts/AccountsServiceTests.get.cs | 24 --- .../Accounts/AccountsServiceTests.update.cs | 35 ---- .../Balances/BalancesServiceTests.get.cs | 9 +- .../CategoriesServiceTests.create.cs | 30 --- .../CategoriesServiceTests.delete.cs | 20 -- .../Categories/CategoriesServiceTests.get.cs | 24 --- .../CategoriesServiceTests.update.cs | 46 +---- .../AccountsControllerTests.create.cs | 2 +- .../Accounts/AccountsControllerTests.cs | 4 +- .../AccountsControllerTests.delete.cs | 2 +- .../Accounts/AccountsControllerTests.get.cs | 2 +- .../AccountsControllerTests.update.cs | 2 +- .../BalancesControllerTests.create.cs | 2 +- .../Balances/BalancesControllerTests.cs | 4 +- .../BalancesControllerTests.delete.cs | 2 +- .../BalancesControllerTests.update.cs | 2 +- .../CategoriesControllerTests.create.cs | 2 +- .../Categories/CategoriesControllerTests.cs | 4 +- .../CategoriesControllerTests.delete.cs | 2 +- .../CategoriesControllerTests.get.cs | 2 +- .../CategoriesControllerTests.update.cs | 2 +- .../TransactionsControllerTests.create.cs | 2 +- .../TransactionsControllerTests.cs | 4 +- .../TransactionsControllerTests.delete.cs | 2 +- .../TransactionsControllerTests.get.cs | 2 +- .../TransactionsControllerTests.update.cs | 2 +- ...inancialHub.Core.WebApi.NUnitTests.csproj} | 4 +- .../Usings.cs | 0 .../Validators/AccountValidatorTests.cs | 4 +- .../Validators/BalanceValidatorTests.cs | 4 +- .../Validators/CategoryValidatorTests.cs | 4 +- .../Validators/TransactionValidatorTests.cs | 4 +- .../Controllers/AccountsController.cs | 2 +- .../Controllers/BalancesController.cs | 2 +- .../Controllers/CategoriesController.cs | 2 +- .../Controllers/TransactionsController.cs | 2 +- .../IServiceCollectionExtensions.cs | 4 +- .../FinancialHub.Core.WebApi.csproj} | 8 + .../Program.cs | 2 +- .../Properties/launchSettings.json | 0 .../Resources/ErrorMessages.Designer.cs | 4 +- .../Resources/ErrorMessages.resx | 0 .../Startup.cs | 4 +- .../Usings.cs | 1 - .../Validators/AccountValidator.cs | 4 +- .../Validators/BalanceValidator.cs | 4 +- .../Validators/CategoryValidator.cs | 4 +- .../Validators/TransactionValidator.cs | 4 +- .../appsettings.Development.json | 0 .../appsettings.Testing.json | 13 ++ .../appsettings.json | 0 .../Base/BaseControllerTests.cs | 191 ------------------ .../IServiceCollectionExtensions.cs | 26 --- .../Setup/DbConnectionStringManager.cs | 43 ---- .../Controllers/Base/BaseController.cs | 24 --- src/api/FinancialHub.sln | 42 ++-- 87 files changed, 361 insertions(+), 785 deletions(-) rename src/api/{FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs => FinancialHub.Common.Tests/Assertions/Responses/BaseResponseAssert.cs} (86%) create mode 100644 src/api/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs create mode 100644 src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs create mode 100644 src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs create mode 100644 src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs create mode 100644 src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs create mode 100644 src/api/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs rename src/api/{FinancialHub.IntegrationTests => FinancialHub.Core.IntegrationTests}/Controllers/AccountsControllerTests.cs (89%) rename src/api/{FinancialHub.IntegrationTests => FinancialHub.Core.IntegrationTests}/Controllers/BalancesControllerTests.cs (87%) rename src/api/{FinancialHub.IntegrationTests => FinancialHub.Core.IntegrationTests}/Controllers/CategoriesControllerTests.cs (87%) rename src/api/{FinancialHub.IntegrationTests => FinancialHub.Core.IntegrationTests}/Controllers/TransactionsControllerTests.cs (72%) rename src/api/{FinancialHub.IntegrationTests => FinancialHub.Core.IntegrationTests}/Extensions/HttpClientExtensions.cs (93%) rename src/api/{FinancialHub.IntegrationTests => FinancialHub.Core.IntegrationTests}/Extensions/HttpResponseMessageExtensions.cs (93%) rename src/api/{FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj => FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj} (87%) rename src/api/{FinancialHub.IntegrationTests => FinancialHub.Core.IntegrationTests}/Setup/FinancialHubFixture.cs (88%) rename src/api/{FinancialHub.IntegrationTests => FinancialHub.Core.IntegrationTests}/Usings.cs (70%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Accounts/AccountsControllerTests.create.cs (97%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Accounts/AccountsControllerTests.cs (88%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Accounts/AccountsControllerTests.delete.cs (89%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Accounts/AccountsControllerTests.get.cs (94%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Accounts/AccountsControllerTests.update.cs (97%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Balances/BalancesControllerTests.create.cs (97%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Balances/BalancesControllerTests.cs (85%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Balances/BalancesControllerTests.delete.cs (87%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Balances/BalancesControllerTests.update.cs (97%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Categories/CategoriesControllerTests.create.cs (97%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Categories/CategoriesControllerTests.cs (85%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Categories/CategoriesControllerTests.delete.cs (89%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Categories/CategoriesControllerTests.get.cs (94%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Categories/CategoriesControllerTests.update.cs (97%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Transactions/TransactionsControllerTests.create.cs (97%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Transactions/TransactionsControllerTests.cs (89%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Transactions/TransactionsControllerTests.delete.cs (89%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Transactions/TransactionsControllerTests.get.cs (95%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Controllers/Transactions/TransactionsControllerTests.update.cs (97%) rename src/api/{FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj => FinancialHub.Core.WebApi.NUnitTests/FinancialHub.Core.WebApi.NUnitTests.csproj} (80%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Usings.cs (100%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Validators/AccountValidatorTests.cs (95%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Validators/BalanceValidatorTests.cs (95%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Validators/CategoryValidatorTests.cs (96%) rename src/api/{FinancialHub.WebApi.NUnitTests => FinancialHub.Core.WebApi.NUnitTests}/Validators/TransactionValidatorTests.cs (96%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Controllers/AccountsController.cs (98%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Controllers/BalancesController.cs (97%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Controllers/CategoriesController.cs (98%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Controllers/TransactionsController.cs (98%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Extensions/Configurations/IServiceCollectionExtensions.cs (93%) rename src/api/{FinancialHub.WebApi/FinancialHub.WebApi.csproj => FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj} (86%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Program.cs (93%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Properties/launchSettings.json (100%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Resources/ErrorMessages.Designer.cs (95%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Resources/ErrorMessages.resx (100%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Startup.cs (93%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Usings.cs (91%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Validators/AccountValidator.cs (84%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Validators/BalanceValidator.cs (84%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Validators/CategoryValidator.cs (84%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/Validators/TransactionValidator.cs (88%) rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/appsettings.Development.json (100%) create mode 100644 src/api/FinancialHub.Core.WebApi/appsettings.Testing.json rename src/api/{FinancialHub.WebApi => FinancialHub.Core.WebApi}/appsettings.json (100%) delete mode 100644 src/api/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs delete mode 100644 src/api/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs delete mode 100644 src/api/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs delete mode 100644 src/api/FinancialHub.WebApi/Controllers/Base/BaseController.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs b/src/api/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs index 399bf7a..a97653e 100644 --- a/src/api/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs +++ b/src/api/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs @@ -1,4 +1,6 @@ -namespace FinancialHub.Auth.Presentation.Tests.Asserts +using FinancialHub.Common.Tests.Assertions.Responses; + +namespace FinancialHub.Auth.Presentation.Tests.Asserts { public static class ControllerResponseAssert { @@ -10,7 +12,7 @@ public static void IsValid(BaseResponse expectedResponse, ObjectResult res Assert.That(result.Value, Is.TypeOf(expectedResponse.GetType())); var response = result.Value as BaseResponse; - ResponseAssert.IsValid(expectedResponse, response!); + BaseResponseAssert.IsValid(expectedResponse, response!); }); } @@ -22,7 +24,7 @@ public static void HasError(BaseErrorResponse expectedResponse, ObjectResult res Assert.That(result.Value, Is.TypeOf(expectedResponse.GetType())); var response = result.Value as ValidationErrorResponse; - ResponseAssert.HasError(expectedResponse, response!); + BaseResponseAssert.HasError(expectedResponse, response!); }); } } diff --git a/src/api/FinancialHub.Auth.Tests.Common/Usings.cs b/src/api/FinancialHub.Auth.Tests.Common/Usings.cs index bc9af06..d110713 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Usings.cs +++ b/src/api/FinancialHub.Auth.Tests.Common/Usings.cs @@ -2,7 +2,7 @@ global using AutoBogus; global using FinancialHub.Auth.Domain.Entities; -global using FinancialHub.Common.Tests.Builders.Entities; - global using FinancialHub.Auth.Domain.Models; + +global using FinancialHub.Common.Tests.Builders.Entities; global using FinancialHub.Common.Tests.Builders.Models; diff --git a/src/api/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs b/src/api/FinancialHub.Common.Tests/Assertions/Responses/BaseResponseAssert.cs similarity index 86% rename from src/api/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs rename to src/api/FinancialHub.Common.Tests/Assertions/Responses/BaseResponseAssert.cs index 9938ff9..5a142ec 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Assertions/ResponseAssert.cs +++ b/src/api/FinancialHub.Common.Tests/Assertions/Responses/BaseResponseAssert.cs @@ -1,9 +1,10 @@ using FinancialHub.Common.Responses.Errors; using FinancialHub.Common.Responses.Success; +using NUnit.Framework; -namespace FinancialHub.Auth.Tests.Common.Assertions +namespace FinancialHub.Common.Tests.Assertions.Responses { - public static class ResponseAssert + public static class BaseResponseAssert { public static void IsValid(T expected, BaseResponse response) { diff --git a/src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj b/src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj index 9700881..d3b696a 100644 --- a/src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj +++ b/src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj @@ -8,6 +8,7 @@ + diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs new file mode 100644 index 0000000..9e70b87 --- /dev/null +++ b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs @@ -0,0 +1,19 @@ +namespace FinancialHub.Core.Domain.Tests.Assertions.Entities +{ + public static class BalanceEntityAssert + { + public static void Equal(BalanceEntity expected, BalanceEntity result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.AccountId, result.AccountId); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + + public static void Equal(BalanceEntity expected, BalanceModel result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.AccountId, result.AccountId); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + } +} diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs new file mode 100644 index 0000000..65e805e --- /dev/null +++ b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs @@ -0,0 +1,12 @@ +namespace FinancialHub.Core.Domain.Tests.Assertions.Models +{ + public static class AccountModelAssert + { + public static void Equal(AccountModel expected, AccountModel result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.Description, result.Description); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + } +} diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs new file mode 100644 index 0000000..8817a50 --- /dev/null +++ b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs @@ -0,0 +1,19 @@ +namespace FinancialHub.Core.Domain.Tests.Assertions.Models +{ + public static class BalanceModelAssert + { + public static void Equal(BalanceModel expected, BalanceModel result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.AccountId, result.AccountId); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + + public static void Equal(BalanceModel expected, BalanceEntity result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.AccountId, result.AccountId); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + } +} diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs new file mode 100644 index 0000000..ffb228c --- /dev/null +++ b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs @@ -0,0 +1,12 @@ +namespace FinancialHub.Core.Domain.Tests.Assertions.Models +{ + public static class CategoryModelAssert + { + public static void Equal(CategoryModel expected, CategoryModel result) + { + Assert.AreEqual(expected.Name, result.Name); + Assert.AreEqual(expected.Description, result.Description); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + } +} diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs new file mode 100644 index 0000000..b5d64ec --- /dev/null +++ b/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs @@ -0,0 +1,17 @@ +namespace FinancialHub.Core.Domain.Tests.Assertions.Models +{ + public static class TransactionModelAssert + { + public static void Equal(TransactionModel expected, TransactionModel result) + { + Assert.AreEqual(expected.BalanceId, result.BalanceId); + Assert.AreEqual(expected.CategoryId, result.CategoryId); + Assert.AreEqual(expected.TargetDate, result.TargetDate); + Assert.AreEqual(expected.FinishDate, result.FinishDate); + Assert.AreEqual(expected.Amount, result.Amount); + Assert.AreEqual(expected.Type, result.Type); + Assert.AreEqual(expected.Description, result.Description); + Assert.AreEqual(expected.IsActive, result.IsActive); + } + } +} diff --git a/src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj b/src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj index 148910d..2b38092 100644 --- a/src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj +++ b/src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/api/FinancialHub.Core.Domain.Tests/Usings.cs b/src/api/FinancialHub.Core.Domain.Tests/Usings.cs index 69cef6a..75ac6bf 100644 --- a/src/api/FinancialHub.Core.Domain.Tests/Usings.cs +++ b/src/api/FinancialHub.Core.Domain.Tests/Usings.cs @@ -1,6 +1,9 @@ // System namespaces global using System; +// 3rd party test namespaces +global using NUnit.Framework; + // Domain builder tests namespaces global using FinancialHub.Common.Tests.Builders.Entities; global using FinancialHub.Common.Tests.Builders.Models; diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj index 0e206c1..4757581 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj @@ -9,7 +9,7 @@ - + all diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs index f5bbeed..2429fa8 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs @@ -2,11 +2,11 @@ namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base { - public abstract partial class BaseRepositoryTests + public abstract partial class BaseRepositoryTests where T : BaseEntity { [Test] - [TestCase(TestName = "Delete existing Item",Category = "Delete")] + [TestCase(TestName = "Delete existing Item", Category = "Delete")] public virtual async Task DeleteAsync_ExistingItem_AffectsOneRow() { var items = this.GenerateData(); @@ -14,19 +14,19 @@ public virtual async Task DeleteAsync_ExistingItem_AffectsOneRow() this.context.ChangeTracker.Clear(); var affectedRows = await this.repository.DeleteAsync(items.First().Id.Value); - Assert.AreEqual(1,affectedRows); - Assert.AreEqual(items.Count - 1,context.Set().ToList().Count); + Assert.AreEqual(1, affectedRows); + Assert.AreEqual(items.Count - 1, context.Set().ToList().Count); } [Test] - [TestCase(TestName = "Delete non existing Item",Category = "Delete")] + [TestCase(TestName = "Delete non existing Item", Category = "Delete")] public virtual async Task DeleteAsync_NonExistingItem_AffectsNothing() { var items = this.GenerateData(); await this.InsertData(items); this.context.ChangeTracker.Clear(); - var affectedRows = await this.repository.DeleteAsync(new Guid()); + var affectedRows = await this.repository.DeleteAsync(Guid.Empty); Assert.AreEqual(0, affectedRows); Assert.IsNotEmpty(context.Set().ToList()); } diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs index b0c2213..d5a260a 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs @@ -48,8 +48,7 @@ public virtual async Task GetAsync_NoFilter_ReturnsAllItems() [TestCase(TestName = "Get Items not setting filter", Category = "Get")] public virtual async Task GetAsync_NullFilter_ThrowsArgumentNullException() { - var items = this.GenerateData(); - items = await this.InsertData(items); + await this.InsertData(this.GenerateData()); Assert.ThrowsAsync(typeof(ArgumentNullException), async () => await this.repository.GetAsync(null)); } @@ -76,10 +75,9 @@ public virtual async Task GetAsync_Filter_ReturnsFilteredItems() [TestCase(TestName = "Get Items with wrong filter", Category = "Get")] public virtual async Task GetAsync_WrongFilter_ReturnsEmpty() { - var items = this.GenerateData(10, 100); - items = await this.InsertData(items); + await this.InsertData(this.GenerateData(10, 100)); - Func filter = (x) => x.Id == new Guid(); + static bool filter(T x) => x.Id == Guid.Empty; var list = await this.repository.GetAsync(filter); @@ -87,18 +85,6 @@ public virtual async Task GetAsync_WrongFilter_ReturnsEmpty() Assert.IsInstanceOf>(list); } - [Test] - [TestCase(TestName = "Get By Id with empty id", Category = "Get")] - public virtual async Task GetByIdAsync_EmptyId_ReturnsNull() - { - var items = this.GenerateData(); - items = await this.InsertData(items); - - var item = await this.repository.GetByIdAsync(Guid.Empty); - - Assert.IsNull(item); - } - [Test] [TestCase(TestName = "Get By Id with existing id", Category = "Get")] public virtual async Task GetByIdAsync_ExistingId_ReturnsItem() @@ -119,10 +105,9 @@ public virtual async Task GetByIdAsync_ExistingId_ReturnsItem() [TestCase(TestName = "Get By Id with non-existing id", Category = "Get")] public virtual async Task GetByIdAsync_NonExistingId_ReturnsNull() { - var items = this.GenerateData(); - items = await this.InsertData(items); + await this.InsertData(this.GenerateData()); - var item = await this.repository.GetByIdAsync(new Guid()); + var item = await this.repository.GetByIdAsync(Guid.Empty); Assert.IsNull(item); } diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs index f688724..95c9da9 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs @@ -71,47 +71,51 @@ public override async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithThe } [Test] - [TestCase(TestName = "Create new Transaction without Updates/Creates Balance or Category", Category = "Create")] - public async Task CreateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() + [TestCase(TestName = "Create new Transaction without Updates/Creates Category", Category = "Create")] + public async Task CreateAsync_ValidItemWithCategory_DoesNotUpdateCategory() { - #warning this test is too complex - - /***** ARRANGE *****/ var entity = this.GenerateObject(); - //INSERTS ACCOUNT AND CATEGORY - var oldBalance = this.GenerateBalance(entity.BalanceId); var oldCategory = this.GenerateCategory(entity.CategoryId); - await this.InsertData(oldBalance); + await this.InsertData(entity.Balance); await this.InsertData(oldCategory); - //CHANGES TRANSACTION'S CATEGORY AND BALANCE - entity.Balance.Name = Guid.NewGuid().ToString(); entity.Category.Name = Guid.NewGuid().ToString(); - /***** ACT *****/ - var result = await this.repository.CreateAsync(entity); - /***** ASSERT *****/ - this.AssertCreated(result); - - //SHOULD NOT CREATE ACCOUNTS OR CATEGORIES - Assert.AreEqual(1,this.context.Balances.Count()); Assert.AreEqual(1,this.context.Categories.Count()); - var account = this.context.Balances.FirstOrDefault(x => x.Id == entity.BalanceId); var category = this.context.Categories.FirstOrDefault(x => x.Id == entity.CategoryId); - //SHOULD NOT UPDATE DATABASE - Assert.AreEqual(oldBalance, account); Assert.AreEqual(oldCategory, category); + Assert.AreEqual(oldCategory, result.Category); + } + + [Test] + [TestCase(TestName = "Create new Transaction without Updates/Creates Balance", Category = "Create")] + public async Task CreateAsync_ValidItemWithBalance_DoesNotUpdateBalance() + { + var entity = this.GenerateObject(); - //SHOULD NOT RETURN THE WRONG ITEM + var oldBalance = this.GenerateBalance(entity.BalanceId); + + await this.InsertData(oldBalance); + await this.InsertData(entity.Category); + + entity.Balance.Name = Guid.NewGuid().ToString(); + + var result = await this.repository.CreateAsync(entity); + + this.AssertCreated(result); + Assert.AreEqual(1, this.context.Balances.Count()); + + var balance = this.context.Balances.FirstOrDefault(x => x.Id == entity.BalanceId); + + Assert.AreEqual(oldBalance, balance); Assert.AreEqual(oldBalance, result.Balance); - Assert.AreEqual(oldCategory, result.Category); } [Test] diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs index 53df147..591d414 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs @@ -3,7 +3,7 @@ public partial class TransactionsRepositoryTests { [Test] - public async Task DeleteAsync_ValidItemWithNestChild_DoesNotDeleteNestChild() + public async Task DeleteAsync_DoesNotDeleteBalance() { var entity = this.GenerateObject(); @@ -17,7 +17,24 @@ public async Task DeleteAsync_ValidItemWithNestChild_DoesNotDeleteNestChild() Assert.AreEqual(1,result); Assert.IsEmpty(this.context.Transactions.Local); - Assert.AreEqual(1, this.context.Accounts.Local.Count); + Assert.AreEqual(1, this.context.Balances.Local.Count); + } + + [Test] + public async Task DeleteAsync_DoesNotDeleteCategory() + { + var entity = this.GenerateObject(); + + await this.InsertData(entity.Balance); + await this.InsertData(entity.Category); + await this.InsertData(entity); + this.context.ChangeTracker.Clear(); + + var result = await this.repository.DeleteAsync(entity.Id.Value); + + Assert.AreEqual(1, result); + + Assert.IsEmpty(this.context.Transactions.Local); Assert.AreEqual(1, this.context.Categories.Local.Count); } } diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs index 3f26edb..0a2c4d9 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs +++ b/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs @@ -14,8 +14,8 @@ protected async Task InsertTransaction(TransactionEntity entity) } [Test] - [TestCase(TestName = "Update Transaction but no Balances or Category", Category = "Update")] - public async Task UpdateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() + [TestCase(TestName = "Update Transaction but not Balance", Category = "Update")] + public async Task UpdateAsync_ValidItemWithBalance_DoesNotUpdateBalance() { var entity = this.GenerateObject(); await this.InsertTransaction(entity); @@ -23,18 +23,29 @@ public async Task UpdateAsync_ValidItemWithNestChild_DoesNotUpdateNestChild() var changedEntity = this.GenerateTransaction(entity.Id, entity.BalanceId, entity.CategoryId); var result = await this.repository.UpdateAsync(changedEntity); - + this.AssertCreated(result); - - //SHOULD NOT CREATE Assert.AreEqual(1, this.context.Balances.Local.Count); + + var balance = this.context.Balances.FirstOrDefault(x => x.Id == changedEntity.BalanceId); + Assert.AreEqual(balance, result.Balance); + } + + [Test] + [TestCase(TestName = "Update Transaction but not Category", Category = "Update")] + public async Task UpdateAsync_ValidItemWithCategory_DoesNotUpdateCategory() + { + var entity = this.GenerateObject(); + await this.InsertTransaction(entity); + + var changedEntity = this.GenerateTransaction(entity.Id, entity.BalanceId, entity.CategoryId); + + var result = await this.repository.UpdateAsync(changedEntity); + + this.AssertCreated(result); Assert.AreEqual(1, this.context.Categories.Local.Count); - var account = this.context.Balances.FirstOrDefault(x => x.Id == changedEntity.BalanceId); var category = this.context.Categories.FirstOrDefault(x => x.Id == changedEntity.CategoryId); - - //SHOULD NOT UPDATE DATABASE - Assert.AreEqual(account, result.Balance); Assert.AreEqual(category, result.Category); } @@ -83,7 +94,6 @@ public async Task UpdateAsync_ChangeCategoryId_ChangesCategory() public async Task UpdateAsync_InvalidBalanceId_ThrowsDbUpdateException() { var entity = this.GenerateObject(); - var oldCategoryId = entity.Category.Id; await this.InsertTransaction(entity); diff --git a/src/api/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs b/src/api/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs new file mode 100644 index 0000000..98cbd0c --- /dev/null +++ b/src/api/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs @@ -0,0 +1,33 @@ +using System.Net.Http; + +namespace FinancialHub.Core.IntegrationTests.Base +{ + [TestFixtureSource(typeof(FinancialHubApiFixture))] + public abstract class BaseControllerTests + { + protected readonly FinancialHubApiFixture fixture; + protected HttpClient client => fixture.Client; + + protected readonly string baseEndpoint; + protected readonly Random random; + + protected BaseControllerTests(FinancialHubApiFixture fixture,string endpoint) + { + this.fixture = fixture; + this.baseEndpoint = endpoint; + this.random = new Random(); + } + + [SetUp] + public virtual void SetUp() + { + this.fixture.CreateDatabase(); + } + + [TearDown] + public virtual void TearDown() + { + this.fixture.ClearData(); + } + } +} diff --git a/src/api/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs b/src/api/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs similarity index 89% rename from src/api/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs rename to src/api/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs index c257ca6..fd4d237 100644 --- a/src/api/FinancialHub.IntegrationTests/Controllers/AccountsControllerTests.cs +++ b/src/api/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs @@ -1,8 +1,4 @@ -using FinancialHub.IntegrationTests.Base; -using FinancialHub.IntegrationTests.Setup; -using FinancialHub.IntegrationTests.Extensions; - -namespace FinancialHub.IntegrationTests +namespace FinancialHub.Core.IntegrationTests { public class AccountsControllerTests : BaseControllerTests { @@ -23,20 +19,13 @@ public override void SetUp() base.SetUp(); } - protected static void AssertEqual(AccountModel expected, AccountModel result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.Description, result.Description); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - protected async Task AssertGetExists(AccountModel expected) { var getResponse = await this.client.GetAsync(baseEndpoint); var getResult = await getResponse.ReadContentAsync>(); Assert.AreEqual(1, getResult?.Data.Count); - AssertEqual(expected, getResult!.Data.First()); + AccountModelAssert.Equal(expected, getResult!.Data.First()); } protected void Populate(int amount = 10) @@ -88,7 +77,7 @@ public async Task Post_ValidAccount_ReturnCreatedAccount() var result = await response.ReadContentAsync>(); Assert.IsNotNull(result?.Data); - AssertEqual(data, result!.Data); + AccountModelAssert.Equal(data, result!.Data); } [Test] @@ -115,7 +104,7 @@ public async Task Put_ExistingAccount_ReturnUpdatedAccount() var result = await response.ReadContentAsync>(); Assert.IsNotNull(result?.Data); Assert.AreEqual(body.Id, result?.Data.Id); - AssertEqual(body,result!.Data); + AccountModelAssert.Equal(body,result!.Data); } [Test] diff --git a/src/api/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs b/src/api/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs similarity index 87% rename from src/api/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs rename to src/api/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs index 6814a8a..cc35466 100644 --- a/src/api/FinancialHub.IntegrationTests/Controllers/BalancesControllerTests.cs +++ b/src/api/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs @@ -1,8 +1,4 @@ -using FinancialHub.IntegrationTests.Base; -using FinancialHub.IntegrationTests.Setup; -using FinancialHub.IntegrationTests.Extensions; - -namespace FinancialHub.IntegrationTests +namespace FinancialHub.Core.IntegrationTests { public class BalancesControllerTests : BaseControllerTests { @@ -22,24 +18,10 @@ public override void SetUp() base.SetUp(); } - protected static void AssertEqual(BalanceModel expected, BalanceModel result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.AccountId, result.AccountId); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - - protected static void AssertEqual(BalanceModel expected, BalanceEntity result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.AccountId, result.AccountId); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - protected void AssertExists(BalanceModel expected) { var data = this.fixture.GetData(); - AssertEqual(expected, data.First()); + BalanceModelAssert.Equal(expected, data.First()); } [Test] @@ -54,7 +36,7 @@ public async Task Post_ValidBalance_ReturnsCreatedBalance() var result = await response.ReadContentAsync>(); Assert.IsNotNull(result?.Data); - AssertEqual(data, result!.Data); + BalanceModelAssert.Equal(data, result!.Data); } [Test] @@ -104,7 +86,7 @@ public async Task Put_ExistingBalance_ReturnsUpdatedBalance() var result = await response.ReadContentAsync>(); Assert.IsNotNull(result?.Data); - AssertEqual(data, result!.Data); + BalanceModelAssert.Equal(data, result!.Data); } [Test] diff --git a/src/api/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs b/src/api/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs similarity index 87% rename from src/api/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs rename to src/api/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs index a19f159..aa83f76 100644 --- a/src/api/FinancialHub.IntegrationTests/Controllers/CategoriesControllerTests.cs +++ b/src/api/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs @@ -1,15 +1,10 @@ -using FinancialHub.IntegrationTests.Base; -using FinancialHub.IntegrationTests.Setup; -using FinancialHub.IntegrationTests.Extensions; - -namespace FinancialHub.IntegrationTests +namespace FinancialHub.Core.IntegrationTests { public class CategoriesControllerTests : BaseControllerTests { private CategoryEntityBuilder dataBuilder; private CategoryModelBuilder builder; - public CategoriesControllerTests(FinancialHubApiFixture fixture) : base(fixture, "/categories") { @@ -22,20 +17,13 @@ public override void SetUp() base.SetUp(); } - protected static void AssertEqual(CategoryModel expected, CategoryModel result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.Description, result.Description); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - protected async Task AssertGetExists(CategoryModel expected) { var getResponse = await this.client.GetAsync(baseEndpoint); var getResult = await getResponse.ReadContentAsync>(); Assert.AreEqual(1, getResult?.Data.Count); - AssertEqual(expected, getResult!.Data.First()); + CategoryModelAssert.Equal(expected, getResult!.Data.First()); } [Test] @@ -61,7 +49,7 @@ public async Task Post_ValidCategory_ReturnCreatedCategory() var result = await response.ReadContentAsync>(); Assert.IsNotNull(result?.Data); - AssertEqual(data, result!.Data); + CategoryModelAssert.Equal(data, result!.Data); } [Test] @@ -88,7 +76,7 @@ public async Task Put_ExistingCategory_ReturnUpdatedCategory() var result = await response.ReadContentAsync>(); Assert.IsNotNull(result?.Data); Assert.AreEqual(body.Id, result?.Data.Id); - AssertEqual(body,result!.Data); + CategoryModelAssert.Equal(body,result!.Data); } [Test] diff --git a/src/api/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs b/src/api/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs similarity index 72% rename from src/api/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs rename to src/api/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs index e859e3c..104cdfb 100644 --- a/src/api/FinancialHub.IntegrationTests/Controllers/TransactionsControllerTests.cs +++ b/src/api/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs @@ -1,8 +1,4 @@ -using FinancialHub.IntegrationTests.Base; -using FinancialHub.IntegrationTests.Setup; -using FinancialHub.IntegrationTests.Extensions; - -namespace FinancialHub.IntegrationTests +namespace FinancialHub.Core.IntegrationTests { public class TransactionsControllerTests : BaseControllerTests { @@ -21,25 +17,13 @@ public override void SetUp() base.SetUp(); } - protected static void AssertEqual(TransactionModel expected, TransactionModel result) - { - Assert.AreEqual(expected.BalanceId, result.BalanceId); - Assert.AreEqual(expected.CategoryId, result.CategoryId); - Assert.AreEqual(expected.TargetDate, result.TargetDate); - Assert.AreEqual(expected.FinishDate, result.FinishDate); - Assert.AreEqual(expected.Amount, result.Amount); - Assert.AreEqual(expected.Type, result.Type); - Assert.AreEqual(expected.Description, result.Description); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - protected async Task AssertGetExists(TransactionModel expected) { var getResponse = await this.client.GetAsync(baseEndpoint); var getResult = await getResponse.ReadContentAsync>(); Assert.AreEqual(1, getResult?.Data.Count); - AssertEqual(expected, getResult!.Data.First()); + TransactionModelAssert.Equal(expected, getResult!.Data.First()); } protected TransactionModel CreateValidTransaction(bool isActive = true) @@ -49,25 +33,11 @@ protected TransactionModel CreateValidTransaction(bool isActive = true) this.fixture.AddData(model.Category); this.fixture.AddData(model.Balance); - var data = entityBuilder + return modelBuilder .WithBalanceId(model.Balance.Id) .WithCategoryId(model.Category.Id) .WithActiveStatus(isActive) .Generate(); - - return new TransactionModel() - { - Id = data.Id, - CategoryId = data.CategoryId, - BalanceId = data.BalanceId, - Description = data.Description, - FinishDate = data.FinishDate, - TargetDate = data.TargetDate, - Amount = data.Amount, - Status = data.Status, - Type = data.Type, - IsActive = data.IsActive, - }; } protected TransactionModel InsertTransaction(bool isActive = true) @@ -89,19 +59,12 @@ protected TransactionModel InsertTransaction(bool isActive = true) data = this.fixture.AddData(data).First(); - return new TransactionModel() - { - Id = data.Id, - CategoryId = data.CategoryId, - BalanceId = data.BalanceId, - Description = data.Description, - FinishDate = data.FinishDate, - TargetDate = data.TargetDate, - Amount = data.Amount, - Status = data.Status, - Type = data.Type, - IsActive = data.IsActive, - }; + return modelBuilder + .WithBalanceId(balance.Id) + .WithCategoryId(category.Id) + .WithActiveStatus(isActive) + .WithId(data.Id.GetValueOrDefault()) + .Generate(); } protected TransactionModel[] InsertTransactions(bool isActive = true) @@ -119,20 +82,14 @@ protected TransactionModel[] InsertTransactions(bool isActive = true) this.fixture.AddData(data.ToArray()); + return data.Select( - x => new TransactionModel() - { - Id = x.Id, - CategoryId = x.CategoryId, - BalanceId = x.BalanceId, - Description = x.Description, - FinishDate = x.FinishDate, - TargetDate = x.TargetDate, - Amount = x.Amount, - Status = x.Status, - Type = x.Type, - IsActive = x.IsActive, - } + x => modelBuilder + .WithBalanceId(x.BalanceId) + .WithCategoryId(x.BalanceId) + .WithActiveStatus(isActive) + .WithId(x.Id.GetValueOrDefault()) + .Generate() ).ToArray(); } @@ -170,7 +127,7 @@ public async Task Post_ValidTransaction_ReturnCreatedTransaction() var result = await response.ReadContentAsync>(); Assert.IsNotNull(result?.Data); - AssertEqual(data, result!.Data); + TransactionModelAssert.Equal(data, result!.Data); } [Test] @@ -201,7 +158,7 @@ public async Task Put_ExistingTransaction_ReturnUpdatedTransaction() var result = await response.ReadContentAsync>(); Assert.IsNotNull(result?.Data); Assert.AreEqual(body.Id, result?.Data.Id); - AssertEqual(body,result!.Data); + TransactionModelAssert.Equal(body,result!.Data); } [Test] diff --git a/src/api/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs b/src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs similarity index 93% rename from src/api/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs rename to src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs index 605a30b..cde0c68 100644 --- a/src/api/FinancialHub.IntegrationTests/Extensions/HttpClientExtensions.cs +++ b/src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs @@ -2,7 +2,7 @@ using System.Text; using System.Text.Json; -namespace FinancialHub.IntegrationTests.Extensions +namespace FinancialHub.Core.IntegrationTests.Extensions { public static class HttpClientExtensions { diff --git a/src/api/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs b/src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs similarity index 93% rename from src/api/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs rename to src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs index 3b508fd..256becc 100644 --- a/src/api/FinancialHub.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs +++ b/src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs @@ -1,7 +1,7 @@ using System.Net.Http; using System.Text.Json; -namespace FinancialHub.IntegrationTests.Extensions +namespace FinancialHub.Core.IntegrationTests.Extensions { public static class HttpResponseMessageExtensions { diff --git a/src/api/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj b/src/api/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj similarity index 87% rename from src/api/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj rename to src/api/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj index c1bd05c..1bf1b11 100644 --- a/src/api/FinancialHub.IntegrationTests/FinancialHub.IntegrationTests.csproj +++ b/src/api/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj @@ -13,7 +13,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/src/api/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs b/src/api/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs similarity index 88% rename from src/api/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs rename to src/api/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs index be080df..3905598 100644 --- a/src/api/FinancialHub.IntegrationTests/Setup/FinancialHubFixture.cs +++ b/src/api/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs @@ -2,11 +2,11 @@ using System.Collections; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; -using FinancialHub.WebApi; +using FinancialHub.Core.WebApi; using FinancialHub.Core.Infra.Data.Contexts; -using FinancialHub.IntegrationTests.Extensions; +using Microsoft.AspNetCore.Hosting; -namespace FinancialHub.IntegrationTests.Setup +namespace FinancialHub.Core.IntegrationTests.Setup { public class FinancialHubApiFixture : IEnumerable, IDisposable { @@ -19,10 +19,7 @@ public FinancialHubApiFixture() .WithWebHostBuilder( builder => { - builder.ConfigureServices(services => - { - services.AddTestDbContext(); - }); + builder.UseEnvironment("Testing"); } ); diff --git a/src/api/FinancialHub.IntegrationTests/Usings.cs b/src/api/FinancialHub.Core.IntegrationTests/Usings.cs similarity index 70% rename from src/api/FinancialHub.IntegrationTests/Usings.cs rename to src/api/FinancialHub.Core.IntegrationTests/Usings.cs index 11aea14..c6b3bf8 100644 --- a/src/api/FinancialHub.IntegrationTests/Usings.cs +++ b/src/api/FinancialHub.Core.IntegrationTests/Usings.cs @@ -8,11 +8,14 @@ // 3rd party test namespaces global using NUnit.Framework; -// Common models namespaces +// Domain Asserts namespaces +global using FinancialHub.Core.Domain.Tests.Assertions.Models; + +// Common Models namespaces global using FinancialHub.Common.Models; global using FinancialHub.Common.Entities; -// Domain models namespaces +// Domain Models namespaces global using FinancialHub.Core.Domain.Models; global using FinancialHub.Core.Domain.Entities; @@ -28,3 +31,7 @@ global using FinancialHub.Core.Domain.Tests.Builders.Models; global using FinancialHub.Core.Domain.Tests.Builders.Entities; +// Integration Tests SetUp namespaces +global using FinancialHub.Core.IntegrationTests.Base; +global using FinancialHub.Core.IntegrationTests.Setup; +global using FinancialHub.Core.IntegrationTests.Extensions; \ No newline at end of file diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj b/src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj index 5a5c147..a3556b9 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj +++ b/src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs index 7c1fa1f..ceab256 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs @@ -1,4 +1,6 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +using FinancialHub.Core.Domain.Tests.Assertions.Models; + +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class AccountBalanceServiceTests { @@ -68,9 +70,7 @@ public async Task CreateAsync_ValidAccount_ReturnsCreatedAccount() var result = await this.service.CreateAsync(account); Assert.IsFalse(result.HasError); - Assert.AreEqual(account.Name,result.Data!.Name); - Assert.AreEqual(account.Description,result.Data.Description); - Assert.AreEqual(account.IsActive,result.Data.IsActive); + AccountModelAssert.Equal(account, result.Data!); } [Test] diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs index 70cbdc4..e08e18a 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs @@ -32,35 +32,5 @@ public async Task CreateAsync_ValidAccountModel_ReturnsAccountModel() this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); } - - [Test] - [TestCase(Description = "Create repository exception", Category = "Create")] - public void CreateAsync_RepositoryException_ThrowsException() - { - var model = this.accountModelBuilder.Generate(); - var exc = new Exception("mock"); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Throws(exc) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - - var exception = Assert.ThrowsAsync( - async () => await this.service.CreateAsync(model) - ); - - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); - } } } diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs index 1225b42..cd36835 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs @@ -18,24 +18,5 @@ public async Task DeleteAsync_RepositorySuccess_ReturnsAccountModel() Assert.AreEqual(expectedResult,result.Data); this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); } - - [Test] - public void DeleteAsync_RepositoryException_ThrowsException() - { - var guid = Guid.NewGuid(); - var exc = new Exception("mock"); - - this.repository - .Setup(x => x.DeleteAsync(guid)) - .Throws(exc) - .Verifiable(); - - var exception = Assert.ThrowsAsync( - async () => await this.service.DeleteAsync(guid) - ); - - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.DeleteAsync(guid), Times.Once()); - } } } diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs index d2ef314..241c082 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs @@ -29,29 +29,5 @@ public async Task GetByUsersAsync_ValidUser_ReturnsAccounts() this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); this.repository.Verify(x => x.GetAllAsync(),Times.Once()); } - - - [Test] - [TestCase(Description = "Get by user repository exception", Category = "Get")] - public void GetByUsersAsync_RepositoryException_ThrowsException() - { - var exc = new Exception("mock"); - this.repository - .Setup(x => x.GetAllAsync()) - .Throws(exc) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map>(It.IsAny>())) - .Returns>((ent) => this.mapper.Map>(ent)) - .Verifiable(); - - var exception = Assert.ThrowsAsync( - async ()=> await this.service.GetAllByUserAsync(string.Empty) - ); - - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.GetAllAsync(), Times.Once()); - } } } diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs index eb6a8b1..61c1734 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs @@ -64,40 +64,5 @@ public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); } - - [Test] - [TestCase(Description = "Update repository exception", Category = "Update")] - public void UpdateAsync_RepositoryException_ThrowsException() - { - var model = this.accountModelBuilder.Generate(); - var exc = new Exception("mock"); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Throws(exc) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - - var exception = Assert.ThrowsAsync( - async () => await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model) - ); - - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once()); - } } } diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs index ae84631..34ac1ba 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs @@ -1,4 +1,6 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +using FinancialHub.Core.Domain.Tests.Assertions.Entities; + +namespace FinancialHub.Core.Services.NUnitTests.Services { public partial class BalancesServiceTests { @@ -45,10 +47,7 @@ public async Task GetByIdAsync_ValidId_ReturnsBalance() Assert.IsInstanceOf>(result); Assert.IsFalse(result.HasError); - Assert.AreEqual(entity.AccountId , result.Data!.AccountId); - Assert.AreEqual(entity.Amount , result.Data.Amount); - Assert.AreEqual(entity.Name , result.Data.Name); - Assert.AreEqual(entity.IsActive , result.Data.IsActive); + BalanceEntityAssert.Equal(entity, result.Data!); this.repository.Verify(x => x.GetByIdAsync(entity.Id.GetValueOrDefault()), Times.Once); } diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs index 0b48efb..96fa1f4 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs @@ -32,35 +32,5 @@ public async Task CreateAsync_ValidCategoryModel_ReturnsCategoryModel() this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); } - - [Test] - [TestCase(Description = "Create repository exception", Category = "Create")] - public void CreateAsync_RepositoryException_ThrowsException() - { - var model = this.categoryModelBuilder.Generate(); - var exc = new Exception("mock"); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Throws(exc) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - - var exception = Assert.ThrowsAsync( - async () => await this.service.CreateAsync(model) - ); - - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once()); - } } } diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs index a61b17e..f2337d1 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs @@ -19,25 +19,5 @@ public async Task DeleteAsync_RepositorySuccess_ReturnsCategoryModel() Assert.AreEqual(expectedResult,result.Data); this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); } - - [Test] - [TestCase(Description = "Update repository exception", Category = "Delete")] - public async Task DeleteAsync_RepositoryException_ThrowsException() - { - var guid = Guid.NewGuid(); - var exc = new Exception("mock"); - - this.repository - .Setup(x => x.DeleteAsync(guid)) - .Throws(exc) - .Verifiable(); - - var exception = Assert.ThrowsAsync( - async () => await this.service.DeleteAsync(guid) - ); - - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.DeleteAsync(guid), Times.Once()); - } } } diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs index 5c923b2..96b90cb 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs @@ -30,29 +30,5 @@ public async Task GetByUsersAsync_ValidUser_ReturnsCategories() this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); this.repository.Verify(x => x.GetAllAsync(),Times.Once()); } - - - [Test] - [TestCase(Description = "Get by user repository exception", Category = "Get")] - public void GetByUsersAsync_RepositoryException_ThrowsException() - { - var exc = new Exception("mock"); - this.repository - .Setup(x => x.GetAllAsync()) - .Throws(exc) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map>(It.IsAny>())) - .Returns>((ent) => this.mapper.Map>(ent)) - .Verifiable(); - - var exception = Assert.ThrowsAsync( - async ()=> await this.service.GetAllByUserAsync(string.Empty) - ); - - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.GetAllAsync(), Times.Once()); - } } } diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs index 9599f87..56d9745 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs @@ -44,10 +44,13 @@ public async Task UpdateAsync_ValidCategoryModel_ReturnsCategoryModel() [TestCase(Description = "Update non existing Category", Category = "Update")] public async Task UpdateAsync_NonExistingCategoryId_ReturnsResultError() { - var model = this.categoryModelBuilder.Generate(); + var id = Guid.NewGuid(); + var model = this.categoryModelBuilder + .WithId(id) + .Generate(); this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .Setup(x => x.GetByIdAsync(id)) .ReturnsAsync(default(CategoryEntity)) .Verifiable(); @@ -56,48 +59,13 @@ public async Task UpdateAsync_NonExistingCategoryId_ReturnsResultError() .Returns(async (x) => await Task.FromResult(x)) .Verifiable(); - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + var result = await this.service.UpdateAsync(id, model); Assert.IsInstanceOf>(result); Assert.IsTrue(result.HasError); - this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); + this.repository.Verify(x => x.GetByIdAsync(id), Times.Once); this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); } - - [Test] - [TestCase(Description = "Update repository exception", Category = "Update")] - public void UpdateAsync_RepositoryException_ThrowsException() - { - var model = this.categoryModelBuilder.Generate(); - var exc = new Exception("mock"); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Throws(exc) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - - var exception = Assert.ThrowsAsync( - async () => await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model) - ); - - Assert.IsInstanceOf(exc.GetType(), exception); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once()); - } } } diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs similarity index 97% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs index 703cecf..a552e1b 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs similarity index 88% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs index 1cdfe4d..617f3e6 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs @@ -1,7 +1,7 @@ -using FinancialHub.WebApi.Controllers; +using FinancialHub.Core.WebApi.Controllers; using FinancialHub.Core.Domain.Interfaces.Services; -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs similarity index 89% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs index cb1a590..b3775d5 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs similarity index 94% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs index bd88cde..9311692 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs similarity index 97% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs index be1c800..8e5fe58 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs similarity index 97% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs index 53a2bc7..a46c24a 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class BalancesControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs similarity index 85% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs index 82c1441..5918410 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs @@ -1,7 +1,7 @@ -using FinancialHub.WebApi.Controllers; +using FinancialHub.Core.WebApi.Controllers; using FinancialHub.Core.Domain.Interfaces.Services; -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class BalancesControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs similarity index 87% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs index ff7f157..bef6f4a 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class BalancesControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs similarity index 97% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs index b65c664..574f564 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class BalancesControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs similarity index 97% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs index b461a11..36c7ed4 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs similarity index 85% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs index ecfa17c..a73ed22 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs @@ -1,7 +1,7 @@ -using FinancialHub.WebApi.Controllers; +using FinancialHub.Core.WebApi.Controllers; using FinancialHub.Core.Domain.Interfaces.Services; -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs similarity index 89% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs index 7640248..c32f932 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs similarity index 94% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs index 962fbe7..9ff3da8 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs similarity index 97% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs index 7724175..82e1ab4 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs similarity index 97% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs index df6a8f5..15feb97 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs similarity index 89% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs index 5e71dcd..6f19bb2 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs @@ -1,7 +1,7 @@ -using FinancialHub.WebApi.Controllers; +using FinancialHub.Core.WebApi.Controllers; using FinancialHub.Core.Domain.Interfaces.Services; -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs similarity index 89% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs index 2f7676b..4cb5779 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs similarity index 95% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs index 2672657..7ce085f 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Filters; -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs similarity index 97% rename from src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs index a7dbcad..3cda960 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.NUnitTests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj b/src/api/FinancialHub.Core.WebApi.NUnitTests/FinancialHub.Core.WebApi.NUnitTests.csproj similarity index 80% rename from src/api/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj rename to src/api/FinancialHub.Core.WebApi.NUnitTests/FinancialHub.Core.WebApi.NUnitTests.csproj index fa21fb4..e452af9 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/FinancialHub.WebApi.NUnitTests.csproj +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/FinancialHub.Core.WebApi.NUnitTests.csproj @@ -10,14 +10,14 @@ - + - + diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Usings.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Usings.cs similarity index 100% rename from src/api/FinancialHub.WebApi.NUnitTests/Usings.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Usings.cs diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/AccountValidatorTests.cs similarity index 95% rename from src/api/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/AccountValidatorTests.cs index ba30d62..e1de157 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Validators/AccountValidatorTests.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/AccountValidatorTests.cs @@ -1,6 +1,6 @@ -using FinancialHub.WebApi.Validators; +using FinancialHub.Core.WebApi.Validators; -namespace FinancialHub.WebApi.NUnitTests.Validators +namespace FinancialHub.Core.WebApi.NUnitTests.Validators { public class AccountValidatorTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs similarity index 95% rename from src/api/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs index e09f054..9a17143 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs @@ -1,6 +1,6 @@ -using FinancialHub.WebApi.Validators; +using FinancialHub.Core.WebApi.Validators; -namespace FinancialHub.WebApi.NUnitTests.Validators +namespace FinancialHub.Core.WebApi.NUnitTests.Validators { public class BalanceValidatorTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs similarity index 96% rename from src/api/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs index f154179..797e4c9 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs @@ -1,6 +1,6 @@ -using FinancialHub.WebApi.Validators; +using FinancialHub.Core.WebApi.Validators; -namespace FinancialHub.WebApi.NUnitTests.Validators +namespace FinancialHub.Core.WebApi.NUnitTests.Validators { public class CategoryValidatorTests { diff --git a/src/api/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs b/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs similarity index 96% rename from src/api/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs rename to src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs index 93cfc2b..be463a1 100644 --- a/src/api/FinancialHub.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs +++ b/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.Domain.Enums; -using FinancialHub.WebApi.Validators; +using FinancialHub.Core.WebApi.Validators; -namespace FinancialHub.WebApi.NUnitTests.Validators +namespace FinancialHub.Core.WebApi.NUnitTests.Validators { public class TransactionValidatorTests { diff --git a/src/api/FinancialHub.WebApi/Controllers/AccountsController.cs b/src/api/FinancialHub.Core.WebApi/Controllers/AccountsController.cs similarity index 98% rename from src/api/FinancialHub.WebApi/Controllers/AccountsController.cs rename to src/api/FinancialHub.Core.WebApi/Controllers/AccountsController.cs index 6bb4f35..cec6600 100644 --- a/src/api/FinancialHub.WebApi/Controllers/AccountsController.cs +++ b/src/api/FinancialHub.Core.WebApi/Controllers/AccountsController.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.Controllers +namespace FinancialHub.Core.WebApi.Controllers { [ApiController] [Route("[controller]")] diff --git a/src/api/FinancialHub.WebApi/Controllers/BalancesController.cs b/src/api/FinancialHub.Core.WebApi/Controllers/BalancesController.cs similarity index 97% rename from src/api/FinancialHub.WebApi/Controllers/BalancesController.cs rename to src/api/FinancialHub.Core.WebApi/Controllers/BalancesController.cs index 3edd063..32975ca 100644 --- a/src/api/FinancialHub.WebApi/Controllers/BalancesController.cs +++ b/src/api/FinancialHub.Core.WebApi/Controllers/BalancesController.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.Controllers +namespace FinancialHub.Core.WebApi.Controllers { [ApiController] [Route("[controller]")] diff --git a/src/api/FinancialHub.WebApi/Controllers/CategoriesController.cs b/src/api/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs similarity index 98% rename from src/api/FinancialHub.WebApi/Controllers/CategoriesController.cs rename to src/api/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs index b0635e4..4d7ffc5 100644 --- a/src/api/FinancialHub.WebApi/Controllers/CategoriesController.cs +++ b/src/api/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.WebApi.Controllers +namespace FinancialHub.Core.WebApi.Controllers { [ApiController] [Route("[controller]")] diff --git a/src/api/FinancialHub.WebApi/Controllers/TransactionsController.cs b/src/api/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs similarity index 98% rename from src/api/FinancialHub.WebApi/Controllers/TransactionsController.cs rename to src/api/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs index fc61aba..65642fa 100644 --- a/src/api/FinancialHub.WebApi/Controllers/TransactionsController.cs +++ b/src/api/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Filters; -namespace FinancialHub.WebApi.Controllers +namespace FinancialHub.Core.WebApi.Controllers { [ApiController] [Route("[controller]")] diff --git a/src/api/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs similarity index 93% rename from src/api/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs rename to src/api/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs index f7becec..3308141 100644 --- a/src/api/FinancialHub.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/src/api/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -2,9 +2,9 @@ using FluentValidation; using FluentValidation.AspNetCore; using Microsoft.OpenApi.Models; -using FinancialHub.WebApi.Validators; +using FinancialHub.Core.WebApi.Validators; -namespace FinancialHub.WebApi.Extensions.Configurations +namespace FinancialHub.Core.WebApi.Extensions.Configurations { public static class IServiceCollectionExtensions { diff --git a/src/api/FinancialHub.WebApi/FinancialHub.WebApi.csproj b/src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj similarity index 86% rename from src/api/FinancialHub.WebApi/FinancialHub.WebApi.csproj rename to src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj index 1b95d64..3caa213 100644 --- a/src/api/FinancialHub.WebApi/FinancialHub.WebApi.csproj +++ b/src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj @@ -36,6 +36,14 @@ + + + PreserveNewest + true + PreserveNewest + + + ResXFileCodeGenerator diff --git a/src/api/FinancialHub.WebApi/Program.cs b/src/api/FinancialHub.Core.WebApi/Program.cs similarity index 93% rename from src/api/FinancialHub.WebApi/Program.cs rename to src/api/FinancialHub.Core.WebApi/Program.cs index 8e457c5..0bf61e1 100644 --- a/src/api/FinancialHub.WebApi/Program.cs +++ b/src/api/FinancialHub.Core.WebApi/Program.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; -namespace FinancialHub.WebApi +namespace FinancialHub.Core.WebApi { public class Program { diff --git a/src/api/FinancialHub.WebApi/Properties/launchSettings.json b/src/api/FinancialHub.Core.WebApi/Properties/launchSettings.json similarity index 100% rename from src/api/FinancialHub.WebApi/Properties/launchSettings.json rename to src/api/FinancialHub.Core.WebApi/Properties/launchSettings.json diff --git a/src/api/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs b/src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.Designer.cs similarity index 95% rename from src/api/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs rename to src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.Designer.cs index 346f095..8c5db0f 100644 --- a/src/api/FinancialHub.WebApi/Resources/ErrorMessages.Designer.cs +++ b/src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace FinancialHub.WebApi.Resources { +namespace FinancialHub.Core.WebApi.Resources { using System; @@ -39,7 +39,7 @@ internal ErrorMessages() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.WebApi.Resources.ErrorMessages", typeof(ErrorMessages).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.Core.WebApi.Resources.ErrorMessages", typeof(ErrorMessages).Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/api/FinancialHub.WebApi/Resources/ErrorMessages.resx b/src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.resx similarity index 100% rename from src/api/FinancialHub.WebApi/Resources/ErrorMessages.resx rename to src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.resx diff --git a/src/api/FinancialHub.WebApi/Startup.cs b/src/api/FinancialHub.Core.WebApi/Startup.cs similarity index 93% rename from src/api/FinancialHub.WebApi/Startup.cs rename to src/api/FinancialHub.Core.WebApi/Startup.cs index 9bbb997..00dbf7a 100644 --- a/src/api/FinancialHub.WebApi/Startup.cs +++ b/src/api/FinancialHub.Core.WebApi/Startup.cs @@ -3,11 +3,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using FinancialHub.WebApi.Extensions.Configurations; +using FinancialHub.Core.WebApi.Extensions.Configurations; using FinancialHub.Core.Infra.Data.Extensions.Configurations; using FinancialHub.Core.Services.Extensions.Configurations; -namespace FinancialHub.WebApi +namespace FinancialHub.Core.WebApi { public class Startup { diff --git a/src/api/FinancialHub.WebApi/Usings.cs b/src/api/FinancialHub.Core.WebApi/Usings.cs similarity index 91% rename from src/api/FinancialHub.WebApi/Usings.cs rename to src/api/FinancialHub.Core.WebApi/Usings.cs index 4eec32d..9b4689b 100644 --- a/src/api/FinancialHub.WebApi/Usings.cs +++ b/src/api/FinancialHub.Core.WebApi/Usings.cs @@ -1,6 +1,5 @@ // System namespaces global using System; -global using System.Collections.Generic; global using System.Threading.Tasks; // Asp.Net namespaces diff --git a/src/api/FinancialHub.WebApi/Validators/AccountValidator.cs b/src/api/FinancialHub.Core.WebApi/Validators/AccountValidator.cs similarity index 84% rename from src/api/FinancialHub.WebApi/Validators/AccountValidator.cs rename to src/api/FinancialHub.Core.WebApi/Validators/AccountValidator.cs index e335931..202bf49 100644 --- a/src/api/FinancialHub.WebApi/Validators/AccountValidator.cs +++ b/src/api/FinancialHub.Core.WebApi/Validators/AccountValidator.cs @@ -1,7 +1,7 @@ -using FinancialHub.WebApi.Resources; +using FinancialHub.Core.WebApi.Resources; using FluentValidation; -namespace FinancialHub.WebApi.Validators +namespace FinancialHub.Core.WebApi.Validators { public class AccountValidator : AbstractValidator { diff --git a/src/api/FinancialHub.WebApi/Validators/BalanceValidator.cs b/src/api/FinancialHub.Core.WebApi/Validators/BalanceValidator.cs similarity index 84% rename from src/api/FinancialHub.WebApi/Validators/BalanceValidator.cs rename to src/api/FinancialHub.Core.WebApi/Validators/BalanceValidator.cs index 6f3ef33..9b21317 100644 --- a/src/api/FinancialHub.WebApi/Validators/BalanceValidator.cs +++ b/src/api/FinancialHub.Core.WebApi/Validators/BalanceValidator.cs @@ -1,7 +1,7 @@ -using FinancialHub.WebApi.Resources; +using FinancialHub.Core.WebApi.Resources; using FluentValidation; -namespace FinancialHub.WebApi.Validators +namespace FinancialHub.Core.WebApi.Validators { public class BalanceValidator : AbstractValidator { diff --git a/src/api/FinancialHub.WebApi/Validators/CategoryValidator.cs b/src/api/FinancialHub.Core.WebApi/Validators/CategoryValidator.cs similarity index 84% rename from src/api/FinancialHub.WebApi/Validators/CategoryValidator.cs rename to src/api/FinancialHub.Core.WebApi/Validators/CategoryValidator.cs index c86b7ce..f62fb5d 100644 --- a/src/api/FinancialHub.WebApi/Validators/CategoryValidator.cs +++ b/src/api/FinancialHub.Core.WebApi/Validators/CategoryValidator.cs @@ -1,7 +1,7 @@ -using FinancialHub.WebApi.Resources; +using FinancialHub.Core.WebApi.Resources; using FluentValidation; -namespace FinancialHub.WebApi.Validators +namespace FinancialHub.Core.WebApi.Validators { public class CategoryValidator : AbstractValidator { diff --git a/src/api/FinancialHub.WebApi/Validators/TransactionValidator.cs b/src/api/FinancialHub.Core.WebApi/Validators/TransactionValidator.cs similarity index 88% rename from src/api/FinancialHub.WebApi/Validators/TransactionValidator.cs rename to src/api/FinancialHub.Core.WebApi/Validators/TransactionValidator.cs index 3b6167f..4fab67e 100644 --- a/src/api/FinancialHub.WebApi/Validators/TransactionValidator.cs +++ b/src/api/FinancialHub.Core.WebApi/Validators/TransactionValidator.cs @@ -1,7 +1,7 @@ -using FinancialHub.WebApi.Resources; +using FinancialHub.Core.WebApi.Resources; using FluentValidation; -namespace FinancialHub.WebApi.Validators +namespace FinancialHub.Core.WebApi.Validators { public class TransactionValidator : AbstractValidator { diff --git a/src/api/FinancialHub.WebApi/appsettings.Development.json b/src/api/FinancialHub.Core.WebApi/appsettings.Development.json similarity index 100% rename from src/api/FinancialHub.WebApi/appsettings.Development.json rename to src/api/FinancialHub.Core.WebApi/appsettings.Development.json diff --git a/src/api/FinancialHub.Core.WebApi/appsettings.Testing.json b/src/api/FinancialHub.Core.WebApi/appsettings.Testing.json new file mode 100644 index 0000000..9398fef --- /dev/null +++ b/src/api/FinancialHub.Core.WebApi/appsettings.Testing.json @@ -0,0 +1,13 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "ConnectionStrings": { + "default": "Server=localhost,1450;Database=financial_hub;user=sa;pwd=P@ssw0rd!;" + }, + "AllowedHosts": "*" +} diff --git a/src/api/FinancialHub.WebApi/appsettings.json b/src/api/FinancialHub.Core.WebApi/appsettings.json similarity index 100% rename from src/api/FinancialHub.WebApi/appsettings.json rename to src/api/FinancialHub.Core.WebApi/appsettings.json diff --git a/src/api/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs b/src/api/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs deleted file mode 100644 index be13ee1..0000000 --- a/src/api/FinancialHub.IntegrationTests/Base/BaseControllerTests.cs +++ /dev/null @@ -1,191 +0,0 @@ -using System.Net.Http; -using System.Net; -using System.Linq; -using FinancialHub.IntegrationTests.Setup; -using FinancialHub.IntegrationTests.Extensions; - -namespace FinancialHub.IntegrationTests.Base -{ - [TestFixtureSource(typeof(FinancialHubApiFixture))] - public abstract class BaseControllerTests - { - protected readonly FinancialHubApiFixture fixture; - protected HttpClient client => fixture.Client; - - protected readonly string baseEndpoint; - protected readonly Random random; - - public BaseControllerTests(FinancialHubApiFixture fixture,string endpoint) - { - this.fixture = fixture; - this.baseEndpoint = endpoint; - this.random = new Random(); - } - - [SetUp] - public virtual void SetUp() - { - this.fixture.CreateDatabase(); - } - - [TearDown] - public virtual void TearDown() - { - this.fixture.ClearData(); - } - } - - [Obsolete("Not used")] - [TestFixtureSource(typeof(FinancialHubApiFixture))] - public abstract class BaseControllerTests - where T : BaseModel - where Y : BaseEntity - { - protected readonly FinancialHubApiFixture fixture; - protected HttpClient client => fixture.Client; - - protected readonly string baseEndpoint; - protected readonly string name; - - protected BaseModelBuilder modelBuilder; - protected BaseEntityBuilder entityBuilder; - - public BaseControllerTests(FinancialHubApiFixture fixture, string name ,string endpoint) - { - this.fixture = fixture; - this.name = name; - this.baseEndpoint = endpoint; - } - - [SetUp] - public virtual void SetUp() - { - this.fixture.CreateDatabase(); - } - - [TearDown] - public virtual void TearDown() - { - this.fixture.ClearData(); - } - - protected virtual void AssertEqual(T expected, T result) - { - - } - - protected async Task AssertGetExists(T expected) - { - var getResponse = await this.client.GetAsync(baseEndpoint); - - var getResult = await getResponse.ReadContentAsync>(); - Assert.AreEqual(1, getResult?.Data.Count); - AssertEqual(expected, getResult!.Data.First()); - } - - [Test] - public async Task GetAll_ReturnData() - { - var data = entityBuilder.Generate(10); - this.fixture.AddData(data.ToArray()); - - var response = await this.client.GetAsync(baseEndpoint); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.AreEqual(data.Count, result?.Data.Count); - } - - [Test] - public async Task Post_ValidData_ReturnCreatedData() - { - var data = this.modelBuilder.Generate(); - - var response = await this.client.PostAsync(baseEndpoint, data); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - AssertEqual(data, result!.Data); - } - - [Test] - public async Task Post_ValidData_CreateData() - { - var body = this.modelBuilder.Generate(); - - await this.client.PostAsync(baseEndpoint, body); - - await this.AssertGetExists(body); - } - - [Test] - public async Task Put_ExistingData_ReturnUpdatedData() - { - var id = Guid.NewGuid(); - this.fixture.AddData(entityBuilder.WithId(id).Generate()); - - var body = this.modelBuilder.WithId(id).Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - Assert.AreEqual(body.Id, result?.Data.Id); - AssertEqual(body, result!.Data); - } - - [Test] - public async Task Put_ExistingData_UpdatesData() - { - var id = Guid.NewGuid(); - this.fixture.AddData(entityBuilder.WithId(id).Generate()); - - var body = this.modelBuilder.WithId(id).Generate(); - await this.client.PutAsync($"{baseEndpoint}/{id}", body); - - await this.AssertGetExists(body); - } - - [Test] - public async Task Put_NonExistingData_ReturnNotFoundError() - { - var id = Guid.NewGuid(); - var body = this.modelBuilder.WithId(id).Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); - Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); - - var result = await response.ReadContentAsync(); - Assert.AreEqual($"Not found {name} with id {id}", result!.Message); - } - - [Test] - public async Task Delete_ReturnNoContent() - { - var id = Guid.NewGuid(); - - var data = entityBuilder.WithId(id).Generate(); - this.fixture.AddData(data); - - var response = await this.client.DeleteAsync($"{baseEndpoint}/{id}"); - Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); - } - - [Test] - public async Task Delete_RemovesDataFromDatabase() - { - var id = Guid.NewGuid(); - - var data = entityBuilder.WithId(id).Generate(); - this.fixture.AddData(data); - - await this.client.DeleteAsync($"{baseEndpoint}/{id}"); - - var getResponse = await this.client.GetAsync(baseEndpoint); - var getResult = await getResponse.ReadContentAsync>(); - Assert.IsEmpty(getResult!.Data); - } - } -} diff --git a/src/api/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs b/src/api/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs deleted file mode 100644 index 9605d5f..0000000 --- a/src/api/FinancialHub.IntegrationTests/Extensions/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -using FinancialHub.IntegrationTests.Setup; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; - -namespace FinancialHub.IntegrationTests.Extensions -{ - public static class IServiceCollectionExtensions - { - public static IServiceCollection AddTestDbContext(this IServiceCollection services) - where Context : DbContext - { - var dbContextOptions = services.SingleOrDefault( - d => d.ServiceType == typeof(DbContextOptions) - ); - services.Remove(dbContextOptions!); - - services.AddDbContext(options => - { - options.UseSqlServer(DbConnectionStringManager.ConnectionString); - options.EnableSensitiveDataLogging(true); - options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); - }); - return services; - } - } -} diff --git a/src/api/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs b/src/api/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs deleted file mode 100644 index 7df962e..0000000 --- a/src/api/FinancialHub.IntegrationTests/Setup/DbConnectionStringManager.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.IO; -using System.Runtime.InteropServices; - -namespace FinancialHub.IntegrationTests.Setup -{ - internal static class DbConnectionStringManager - { - private const string DockerConnectionString = "Server=localhost,1450;Database=financial_hub;user=sa;pwd=P@ssw0rd!;"; - private const string LocalDbConnectionString = "Server=(LocalDB)\\MSSQLLocalDB;Database=financial_hub;Trusted_Connection=True;"; - - public static string ConnectionString - { - get - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && LocalDbExists()) - { - return LocalDbConnectionString; - } - - return DockerConnectionString; - } - } - private static readonly string sqlServerLocalDbPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), - "Microsoft SQL Server" - ); - - private static bool LocalDbExists() - { - var files = Directory.GetFiles( - sqlServerLocalDbPath, - "SqlLocalDB.exe", - new EnumerationOptions() - { - IgnoreInaccessible = true, - RecurseSubdirectories = true - } - ); - - return files.Length > 0; - } - } -} diff --git a/src/api/FinancialHub.WebApi/Controllers/Base/BaseController.cs b/src/api/FinancialHub.WebApi/Controllers/Base/BaseController.cs deleted file mode 100644 index a27f03f..0000000 --- a/src/api/FinancialHub.WebApi/Controllers/Base/BaseController.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FinancialHub.Common.Results; - -namespace FinancialHub.WebApi.Controllers.Base -{ - [ApiController] - [System.Obsolete("Maybe use a middleware")] - public abstract class BaseController : ControllerBase - { - protected IActionResult CreateResponse(ServiceResult result) - { - return this.StatusCode(result.Error.Code,result.Data); - } - - protected IActionResult SuccessListResponse(ServiceResult> result) - { - return this.Ok(new ListResponse(result.Data)); - } - - protected IActionResult SuccessSaveResponse(ServiceResult result) - { - return this.Ok(new SaveResponse(result.Data)); - } - } -} diff --git a/src/api/FinancialHub.sln b/src/api/FinancialHub.sln index 43944e6..b14e779 100644 --- a/src/api/FinancialHub.sln +++ b/src/api/FinancialHub.sln @@ -9,10 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{2444FB9D EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{91A212DC-1D96-43DD-B1A0-153ACB6980D5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi.NUnitTests", "FinancialHub.WebApi.NUnitTests\FinancialHub.WebApi.NUnitTests.csproj", "{40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.IntegrationTests", "FinancialHub.IntegrationTests\FinancialHub.IntegrationTests.csproj", "{B6694C5F-1BCF-460D-B9EA-39A49849737A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{8AFE509C-0DD0-4C85-8BEA-24FB599293D7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Migrations", "Migrations", "{EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E}" @@ -43,8 +39,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Dat EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Tests", "FinancialHub.Auth.Infra.Tests\FinancialHub.Auth.Infra.Tests.csproj", "{A4D904E8-5A38-4E00-8419-62CB1F24F94E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.WebApi", "FinancialHub.WebApi\FinancialHub.WebApi.csproj", "{F6444C4B-6609-40E3-8D09-C52D871C5160}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Resources", "FinancialHub.Auth.Resources\FinancialHub.Auth.Resources.csproj", "{8B091A42-5BE6-49A4-8086-C8761E0CE769}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{421DB63D-B9E6-4069-8B79-6C956506F3C5}" @@ -81,20 +75,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain.Tests", "FinancialHub.Core.Domain.Tests\FinancialHub.Core.Domain.Tests.csproj", "{2E731A85-ED5E-4826-93E0-239F012C7DC4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.IntegrationTests", "FinancialHub.Core.IntegrationTests\FinancialHub.Core.IntegrationTests.csproj", "{B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi", "FinancialHub.Core.WebApi\FinancialHub.Core.WebApi.csproj", "{F30D2F25-88CE-416B-B958-0F07668EB3B7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi.NUnitTests", "FinancialHub.Core.WebApi.NUnitTests\FinancialHub.Core.WebApi.NUnitTests.csproj", "{CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C}.Release|Any CPU.Build.0 = Release|Any CPU - {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B6694C5F-1BCF-460D-B9EA-39A49849737A}.Release|Any CPU.Build.0 = Release|Any CPU {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Debug|Any CPU.Build.0 = Debug|Any CPU {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -123,10 +115,6 @@ Global {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.ActiveCfg = Release|Any CPU {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.Build.0 = Release|Any CPU - {F6444C4B-6609-40E3-8D09-C52D871C5160}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F6444C4B-6609-40E3-8D09-C52D871C5160}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F6444C4B-6609-40E3-8D09-C52D871C5160}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F6444C4B-6609-40E3-8D09-C52D871C5160}.Release|Any CPU.Build.0 = Release|Any CPU {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Debug|Any CPU.Build.0 = Debug|Any CPU {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -187,6 +175,18 @@ Global {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Release|Any CPU.Build.0 = Release|Any CPU + {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}.Release|Any CPU.Build.0 = Release|Any CPU + {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Release|Any CPU.Build.0 = Release|Any CPU + {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -195,8 +195,6 @@ Global {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {2444FB9D-15D1-4193-BF04-83C4397369DA} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {91A212DC-1D96-43DD-B1A0-153ACB6980D5} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} - {40B4BB9F-DD1B-463F-B2D0-9CF804A2089C} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} - {B6694C5F-1BCF-460D-B9EA-39A49849737A} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} = {2444FB9D-15D1-4193-BF04-83C4397369DA} {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} = {2444FB9D-15D1-4193-BF04-83C4397369DA} {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} @@ -210,7 +208,6 @@ Global {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} {72C9C13F-BF8B-4649-B504-99E634FCDDE5} = {74BFDE19-E416-46A1-B9C2-878DA41B249A} {A4D904E8-5A38-4E00-8419-62CB1F24F94E} = {B918D713-0701-447C-B403-10DE0C769581} - {F6444C4B-6609-40E3-8D09-C52D871C5160} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} {8B091A42-5BE6-49A4-8086-C8761E0CE769} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} {421DB63D-B9E6-4069-8B79-6C956506F3C5} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} {DD87106B-71B2-484D-A2CA-6ADD69C69CC7} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} @@ -228,6 +225,9 @@ Global {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} {84D15870-8431-49D4-A075-9BA5D9B0CF0A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {2E731A85-ED5E-4826-93E0-239F012C7DC4} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} + {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} + {F30D2F25-88CE-416B-B958-0F07668EB3B7} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} + {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} From 1d735a77fc133e822d8bc78fbe5f42710a6882a5 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Mon, 21 Aug 2023 16:11:45 -0300 Subject: [PATCH 21/30] Release v0.5.2 * Change Core validation extensions * Move Validators to Service Project * Move Migration files to Infra.Data layer * Rename Core Service name to Application * Change Core Unit Tests project names * Change Core.Application, Core.Infra.Data and Core.WebApi Unit Tests name * Remove Infra.Migration project --- ...inancialHub.Core.Application.Tests.csproj} | 4 +- .../AccountBalanceServiceTests.create.cs | 2 +- .../AccountBalanceServiceTests.cs | 4 +- .../AccountBalanceServiceTests.delete.cs | 2 +- .../Accounts/AccountsServiceTests.create.cs | 2 +- .../Services/Accounts/AccountsServiceTests.cs | 6 +- .../Accounts/AccountsServiceTests.delete.cs | 2 +- .../Accounts/AccountsServiceTests.get.cs | 2 +- .../Accounts/AccountsServiceTests.update.cs | 2 +- .../Balances/BalancesServiceTests.create.cs | 2 +- .../Services/Balances/BalancesServiceTests.cs | 6 +- .../Balances/BalancesServiceTests.delete.cs | 2 +- .../Balances/BalancesServiceTests.get.cs | 2 +- .../Balances/BalancesServiceTests.update.cs | 2 +- .../BalancesServiceTests.updateamount.cs | 2 +- .../CategoriesServiceTests.create.cs | 2 +- .../Categories/CategoriesServiceTests.cs | 6 +- .../CategoriesServiceTests.delete.cs | 2 +- .../Categories/CategoriesServiceTests.get.cs | 2 +- .../CategoriesServiceTests.update.cs | 2 +- .../BaseTransactionBalanceTests.cs | 4 +- .../TransactionBalanceTests.create.cs | 2 +- .../TransactionBalanceTests.cs | 9 +++ .../TransactionBalanceTests.delete.cs | 2 +- .../TransactionBalanceTests.update.cs | 2 +- .../TransactionBalanceTests.updateamount.cs | 4 +- .../TransactionsServiceTests.create.cs | 2 +- .../Transactions/TransactionsServiceTests.cs | 6 +- .../TransactionsServiceTests.delete.cs | 2 +- .../TransactionsServiceTests.get.cs | 2 +- .../TransactionsServiceTests.update.cs | 2 +- .../Usings.cs | 0 .../Validators/AccountValidatorTests.cs | 4 +- .../Validators/BalanceValidatorTests.cs | 4 +- .../Validators/CategoryValidatorTests.cs | 4 +- .../Validators/TransactionValidatorTests.cs | 4 +- .../IServiceCollectionExtensions.cs | 50 ++++++++++++++ .../FinancialHub.Core.Application.csproj} | 16 +++++ .../Mappers/FinancialHubAutoMapperProfile.cs | 2 +- .../Mappers/FinancialHubMapperWrapper.cs | 2 +- .../Resources/ErrorMessages.Designer.cs | 4 +- .../Resources/ErrorMessages.resx | 0 .../Services/AccountBalanceService.cs | 2 +- .../Services/AccountsService.cs | 2 +- .../Services/BalancesService.cs | 2 +- .../Services/CategoriesService.cs | 2 +- .../Services/TransactionBalanceService.cs | 2 +- .../Services/TransactionsService.cs | 2 +- .../Usings.cs | 0 .../Validators/AccountValidator.cs | 4 +- .../Validators/BalanceValidator.cs | 4 +- .../Validators/CategoryValidator.cs | 4 +- .../Validators/TransactionValidator.cs | 4 +- ...FinancialHub.Core.Infra.Data.Tests.csproj} | 0 .../Accounts/AccountsRepositoryTests.cs | 4 +- .../BalancesRepositoryTests.amount.cs | 2 +- .../BalancesRepositoryTests.create.cs | 2 +- .../Balances/BalancesRepositoryTests.cs | 4 +- .../Base/BaseRepositoryTests.create.cs | 2 +- .../Repositories/Base/BaseRepositoryTests.cs | 2 +- .../Base/BaseRepositoryTests.delete.cs | 2 +- .../Base/BaseRepositoryTests.get.cs | 2 +- .../Base/BaseRepositoryTests.update.cs | 2 +- .../Categories/CategoriesRepositoryTests.cs | 4 +- .../TransactionsRepositoryTests.create.cs | 2 +- .../TransactionsRepositoryTests.cs | 4 +- .../TransactionsRepositoryTests.delete.cs | 2 +- .../TransactionsRepositoryTests.update.cs | 2 +- .../Usings.cs | 0 .../IServiceCollectionExtensions.cs | 4 +- .../20220407152032_v0.2.4.Designer.cs | 2 +- .../Migrations/20220407152032_v0.2.4.cs | 2 +- .../20220520163358_add-balance.Designer.cs | 2 +- .../Migrations/20220520163358_add-balance.cs | 2 +- ...117_add-balance-to-transaction.Designer.cs | 2 +- ...220520215117_add-balance-to-transaction.cs | 2 +- ...20520215501_add-balance-active.Designer.cs | 2 +- .../20220520215501_add-balance-active.cs | 2 +- .../FinancialHubContextModelSnapshot.cs | 2 +- .../FinancialHub.Core.Infra.Migrations.csproj | 18 ----- .../TransactionBalanceTests.cs | 9 --- .../IServiceCollectionExtensions.cs | 25 ------- .../AccountsControllerTests.create.cs | 2 +- .../Accounts/AccountsControllerTests.cs | 2 +- .../AccountsControllerTests.delete.cs | 2 +- .../Accounts/AccountsControllerTests.get.cs | 2 +- .../AccountsControllerTests.update.cs | 2 +- .../BalancesControllerTests.create.cs | 2 +- .../Balances/BalancesControllerTests.cs | 2 +- .../BalancesControllerTests.delete.cs | 2 +- .../BalancesControllerTests.update.cs | 2 +- .../CategoriesControllerTests.create.cs | 2 +- .../Categories/CategoriesControllerTests.cs | 2 +- .../CategoriesControllerTests.delete.cs | 2 +- .../CategoriesControllerTests.get.cs | 2 +- .../CategoriesControllerTests.update.cs | 2 +- .../TransactionsControllerTests.create.cs | 2 +- .../TransactionsControllerTests.cs | 2 +- .../TransactionsControllerTests.delete.cs | 2 +- .../TransactionsControllerTests.get.cs | 2 +- .../TransactionsControllerTests.update.cs | 2 +- .../FinancialHub.Core.WebApi.Tests.csproj} | 0 .../Usings.cs | 0 .../IServiceCollectionExtensions.cs | 6 +- .../FinancialHub.Core.WebApi.csproj | 17 +---- src/api/FinancialHub.Core.WebApi/Startup.cs | 5 +- src/api/FinancialHub.sln | 66 ++++++++----------- 107 files changed, 223 insertions(+), 230 deletions(-) rename src/api/{FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj => FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj} (83%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/AccountBalance/AccountBalanceServiceTests.create.cs (98%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/AccountBalance/AccountBalanceServiceTests.cs (90%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/AccountBalance/AccountBalanceServiceTests.delete.cs (98%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Accounts/AccountsServiceTests.create.cs (96%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Accounts/AccountsServiceTests.cs (91%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Accounts/AccountsServiceTests.delete.cs (92%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Accounts/AccountsServiceTests.get.cs (95%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Accounts/AccountsServiceTests.update.cs (97%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Balances/BalancesServiceTests.create.cs (98%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Balances/BalancesServiceTests.cs (93%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Balances/BalancesServiceTests.delete.cs (94%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Balances/BalancesServiceTests.get.cs (97%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Balances/BalancesServiceTests.update.cs (98%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Balances/BalancesServiceTests.updateamount.cs (98%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Categories/CategoriesServiceTests.create.cs (96%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Categories/CategoriesServiceTests.cs (91%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Categories/CategoriesServiceTests.delete.cs (92%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Categories/CategoriesServiceTests.get.cs (95%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Categories/CategoriesServiceTests.update.cs (97%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/TransactionBalance/BaseTransactionBalanceTests.cs (89%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/TransactionBalance/TransactionBalanceTests.create.cs (98%) create mode 100644 src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/TransactionBalance/TransactionBalanceTests.delete.cs (99%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/TransactionBalance/TransactionBalanceTests.update.cs (98%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs (99%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Transactions/TransactionsServiceTests.create.cs (98%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Transactions/TransactionsServiceTests.cs (94%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Transactions/TransactionsServiceTests.delete.cs (98%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Transactions/TransactionsServiceTests.get.cs (97%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Services/Transactions/TransactionsServiceTests.update.cs (98%) rename src/api/{FinancialHub.Core.Services.NUnitTests => FinancialHub.Core.Application.Tests}/Usings.cs (100%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.Application.Tests}/Validators/AccountValidatorTests.cs (95%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.Application.Tests}/Validators/BalanceValidatorTests.cs (95%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.Application.Tests}/Validators/CategoryValidatorTests.cs (95%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.Application.Tests}/Validators/TransactionValidatorTests.cs (96%) create mode 100644 src/api/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs rename src/api/{FinancialHub.Core.Services/FinancialHub.Core.Services.csproj => FinancialHub.Core.Application/FinancialHub.Core.Application.csproj} (55%) rename src/api/{FinancialHub.Core.Services => FinancialHub.Core.Application}/Mappers/FinancialHubAutoMapperProfile.cs (93%) rename src/api/{FinancialHub.Core.Services => FinancialHub.Core.Application}/Mappers/FinancialHubMapperWrapper.cs (91%) rename src/api/{FinancialHub.Core.WebApi => FinancialHub.Core.Application}/Resources/ErrorMessages.Designer.cs (97%) rename src/api/{FinancialHub.Core.WebApi => FinancialHub.Core.Application}/Resources/ErrorMessages.resx (100%) rename src/api/{FinancialHub.Core.Services => FinancialHub.Core.Application}/Services/AccountBalanceService.cs (97%) rename src/api/{FinancialHub.Core.Services => FinancialHub.Core.Application}/Services/AccountsService.cs (97%) rename src/api/{FinancialHub.Core.Services => FinancialHub.Core.Application}/Services/BalancesService.cs (98%) rename src/api/{FinancialHub.Core.Services => FinancialHub.Core.Application}/Services/CategoriesService.cs (96%) rename src/api/{FinancialHub.Core.Services => FinancialHub.Core.Application}/Services/TransactionBalanceService.cs (99%) rename src/api/{FinancialHub.Core.Services => FinancialHub.Core.Application}/Services/TransactionsService.cs (98%) rename src/api/{FinancialHub.Core.Services => FinancialHub.Core.Application}/Usings.cs (100%) rename src/api/{FinancialHub.Core.WebApi => FinancialHub.Core.Application}/Validators/AccountValidator.cs (83%) rename src/api/{FinancialHub.Core.WebApi => FinancialHub.Core.Application}/Validators/BalanceValidator.cs (83%) rename src/api/{FinancialHub.Core.WebApi => FinancialHub.Core.Application}/Validators/CategoryValidator.cs (83%) rename src/api/{FinancialHub.Core.WebApi => FinancialHub.Core.Application}/Validators/TransactionValidator.cs (86%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj => FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj} (100%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Accounts/AccountsRepositoryTests.cs (74%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Balances/BalancesRepositoryTests.amount.cs (98%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Balances/BalancesRepositoryTests.create.cs (89%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Balances/BalancesRepositoryTests.cs (85%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Base/BaseRepositoryTests.create.cs (96%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Base/BaseRepositoryTests.cs (97%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Base/BaseRepositoryTests.delete.cs (94%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Base/BaseRepositoryTests.get.cs (98%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Base/BaseRepositoryTests.update.cs (95%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Categories/CategoriesRepositoryTests.cs (74%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Transactions/TransactionsRepositoryTests.create.cs (99%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Transactions/TransactionsRepositoryTests.cs (94%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Transactions/TransactionsRepositoryTests.delete.cs (94%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Repositories/Transactions/TransactionsRepositoryTests.update.cs (98%) rename src/api/{FinancialHub.Core.Infra.Data.NUnitTests => FinancialHub.Core.Infra.Data.Tests}/Usings.cs (100%) rename src/api/{FinancialHub.Core.Infra.Migrations => FinancialHub.Core.Infra.Data}/Migrations/20220407152032_v0.2.4.Designer.cs (99%) rename src/api/{FinancialHub.Core.Infra.Migrations => FinancialHub.Core.Infra.Data}/Migrations/20220407152032_v0.2.4.cs (98%) rename src/api/{FinancialHub.Core.Infra.Migrations => FinancialHub.Core.Infra.Data}/Migrations/20220520163358_add-balance.Designer.cs (99%) rename src/api/{FinancialHub.Core.Infra.Migrations => FinancialHub.Core.Infra.Data}/Migrations/20220520163358_add-balance.cs (97%) rename src/api/{FinancialHub.Core.Infra.Migrations => FinancialHub.Core.Infra.Data}/Migrations/20220520215117_add-balance-to-transaction.Designer.cs (99%) rename src/api/{FinancialHub.Core.Infra.Migrations => FinancialHub.Core.Infra.Data}/Migrations/20220520215117_add-balance-to-transaction.cs (97%) rename src/api/{FinancialHub.Core.Infra.Migrations => FinancialHub.Core.Infra.Data}/Migrations/20220520215501_add-balance-active.Designer.cs (99%) rename src/api/{FinancialHub.Core.Infra.Migrations => FinancialHub.Core.Infra.Data}/Migrations/20220520215501_add-balance-active.cs (92%) rename src/api/{FinancialHub.Core.Infra.Migrations => FinancialHub.Core.Infra.Data}/Migrations/FinancialHubContextModelSnapshot.cs (99%) delete mode 100644 src/api/FinancialHub.Core.Infra.Migrations/FinancialHub.Core.Infra.Migrations.csproj delete mode 100644 src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs delete mode 100644 src/api/FinancialHub.Core.Services/Extensions/Configurations/IServiceCollectionExtensions.cs rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Accounts/AccountsControllerTests.create.cs (97%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Accounts/AccountsControllerTests.cs (93%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Accounts/AccountsControllerTests.delete.cs (89%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Accounts/AccountsControllerTests.get.cs (94%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Accounts/AccountsControllerTests.update.cs (97%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Balances/BalancesControllerTests.create.cs (97%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Balances/BalancesControllerTests.cs (92%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Balances/BalancesControllerTests.delete.cs (87%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Balances/BalancesControllerTests.update.cs (97%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Categories/CategoriesControllerTests.create.cs (97%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Categories/CategoriesControllerTests.cs (92%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Categories/CategoriesControllerTests.delete.cs (89%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Categories/CategoriesControllerTests.get.cs (94%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Categories/CategoriesControllerTests.update.cs (97%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Transactions/TransactionsControllerTests.create.cs (97%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Transactions/TransactionsControllerTests.cs (94%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Transactions/TransactionsControllerTests.delete.cs (89%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Transactions/TransactionsControllerTests.get.cs (95%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Controllers/Transactions/TransactionsControllerTests.update.cs (97%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests/FinancialHub.Core.WebApi.NUnitTests.csproj => FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj} (100%) rename src/api/{FinancialHub.Core.WebApi.NUnitTests => FinancialHub.Core.WebApi.Tests}/Usings.cs (100%) diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj b/src/api/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj similarity index 83% rename from src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj rename to src/api/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj index a3556b9..a4b802a 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/FinancialHub.Core.Services.NUnitTests.csproj +++ b/src/api/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -17,8 +17,8 @@ + - diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs b/src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs index ceab256..2d65c4a 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Tests.Assertions.Models; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class AccountBalanceServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs b/src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs similarity index 90% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs index b99169f..1e4d94e 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.Domain.Interfaces.Services; -using FinancialHub.Core.Services.Services; +using FinancialHub.Core.Application.Services; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class AccountBalanceServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs b/src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs index b236d07..f4ea8b5 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class AccountBalanceServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs similarity index 96% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs index e08e18a..753691b 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class AccountsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs similarity index 91% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs index 9f75f95..6ec249a 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs @@ -3,10 +3,10 @@ using FinancialHub.Core.Domain.Interfaces.Repositories; using FinancialHub.Core.Domain.Interfaces.Services; using FinancialHub.Core.Domain.Tests.Builders.Entities; -using FinancialHub.Core.Services.Mappers; -using FinancialHub.Core.Services.Services; +using FinancialHub.Core.Application.Mappers; +using FinancialHub.Core.Application.Services; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class AccountsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs similarity index 92% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs index cd36835..ead6140 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class AccountsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs similarity index 95% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs index 241c082..40621c5 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs @@ -1,6 +1,6 @@ using System.Linq; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class AccountsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs similarity index 97% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs index 61c1734..c3aee3e 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Accounts/AccountsServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class AccountsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs index 478a463..bd902db 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class BalancesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs similarity index 93% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs index e5e1e31..975ad0c 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs @@ -3,10 +3,10 @@ using FinancialHub.Core.Domain.Interfaces.Repositories; using FinancialHub.Core.Domain.Interfaces.Services; using FinancialHub.Core.Domain.Tests.Builders.Entities; -using FinancialHub.Core.Services.Mappers; -using FinancialHub.Core.Services.Services; +using FinancialHub.Core.Application.Mappers; +using FinancialHub.Core.Application.Services; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class BalancesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs similarity index 94% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs index 418c37c..efc29bb 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class BalancesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs similarity index 97% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs index 34ac1ba..baf00f1 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Tests.Assertions.Entities; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class BalancesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs index 9f72f42..1edef3a 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class BalancesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs index ad625b0..dac1633 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Balances/BalancesServiceTests.updateamount.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class BalancesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs similarity index 96% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs index 96fa1f4..aeaf6cd 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class CategoriesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs similarity index 91% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs index 68ad3bf..8a1c5c2 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs @@ -3,10 +3,10 @@ using FinancialHub.Core.Domain.Interfaces.Repositories; using FinancialHub.Core.Domain.Interfaces.Services; using FinancialHub.Core.Domain.Tests.Builders.Entities; -using FinancialHub.Core.Services.Mappers; -using FinancialHub.Core.Services.Services; +using FinancialHub.Core.Application.Mappers; +using FinancialHub.Core.Application.Services; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class CategoriesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs similarity index 92% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs index f2337d1..c0aadd9 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class CategoriesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs similarity index 95% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs index 96b90cb..019d346 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs @@ -1,6 +1,6 @@ using System.Linq; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class CategoriesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs similarity index 97% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs index 56d9745..7284ea0 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Categories/CategoriesServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class CategoriesServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs similarity index 89% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs index 94635c9..caa11c7 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/BaseTransactionBalanceTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.Domain.Interfaces.Services; -using FinancialHub.Core.Services.Services; +using FinancialHub.Core.Application.Services; -namespace FinancialHub.Core.Services.NUnitTests.Services.TransactionBalance +namespace FinancialHub.Core.Application.Tests.Services.TransactionBalance { public abstract class BaseTransactionBalanceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs index 227744a..81d99a1 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.create.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class TransactionBalanceTests { diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs new file mode 100644 index 0000000..f6d708e --- /dev/null +++ b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs @@ -0,0 +1,9 @@ +using FinancialHub.Core.Application.Tests.Services.TransactionBalance; + +namespace FinancialHub.Core.Application.Tests.Services +{ + public partial class TransactionBalanceTests : BaseTransactionBalanceTests + { + + } +} diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs similarity index 99% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs index e8df895..481e969 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.delete.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class TransactionBalanceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs index fa599d0..dd4a8d7 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.update.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class TransactionBalanceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs similarity index 99% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs index 04d318e..acf4b2f 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.Domain.Enums; -using FinancialHub.Core.Services.NUnitTests.Services.TransactionBalance; +using FinancialHub.Core.Application.Tests.Services.TransactionBalance; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { //TODO: fix UpdateAmount in test names //TOOD: maybe separate some testcases diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs index 7f81805..d83cc76 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.create.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class TransactionsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs similarity index 94% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs index 68138c2..d3ae8d8 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs @@ -3,10 +3,10 @@ using FinancialHub.Core.Domain.Interfaces.Repositories; using FinancialHub.Core.Domain.Interfaces.Services; using FinancialHub.Core.Domain.Tests.Builders.Entities; -using FinancialHub.Core.Services.Mappers; -using FinancialHub.Core.Services.Services; +using FinancialHub.Core.Application.Mappers; +using FinancialHub.Core.Application.Services; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class TransactionsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs index d01b710..fad29cb 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.delete.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class TransactionsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs similarity index 97% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs index d8d11d4..cee2983 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.get.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs @@ -2,7 +2,7 @@ using FinancialHub.Core.Domain.Filters; using FinancialHub.Core.Domain.Queries; -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class TransactionsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs similarity index 98% rename from src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs rename to src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs index c7b1b95..9ab2ddf 100644 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/Transactions/TransactionsServiceTests.update.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.NUnitTests.Services +namespace FinancialHub.Core.Application.Tests.Services { public partial class TransactionsServiceTests { diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Usings.cs b/src/api/FinancialHub.Core.Application.Tests/Usings.cs similarity index 100% rename from src/api/FinancialHub.Core.Services.NUnitTests/Usings.cs rename to src/api/FinancialHub.Core.Application.Tests/Usings.cs diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/AccountValidatorTests.cs b/src/api/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs similarity index 95% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/AccountValidatorTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs index e1de157..f2a6d54 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/AccountValidatorTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs @@ -1,6 +1,6 @@ -using FinancialHub.Core.WebApi.Validators; +using FinancialHub.Core.Application.Validators; -namespace FinancialHub.Core.WebApi.NUnitTests.Validators +namespace FinancialHub.Core.Application.Tests.Validators { public class AccountValidatorTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs b/src/api/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs similarity index 95% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs index 9a17143..01f39a6 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/BalanceValidatorTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs @@ -1,6 +1,6 @@ -using FinancialHub.Core.WebApi.Validators; +using FinancialHub.Core.Application.Validators; -namespace FinancialHub.Core.WebApi.NUnitTests.Validators +namespace FinancialHub.Core.Application.Tests.Validators { public class BalanceValidatorTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs b/src/api/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs similarity index 95% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs index 797e4c9..ddf3e2d 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/CategoryValidatorTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs @@ -1,6 +1,6 @@ -using FinancialHub.Core.WebApi.Validators; +using FinancialHub.Core.Application.Validators; -namespace FinancialHub.Core.WebApi.NUnitTests.Validators +namespace FinancialHub.Core.Application.Tests.Validators { public class CategoryValidatorTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs b/src/api/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs similarity index 96% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs rename to src/api/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs index be463a1..51f27a6 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Validators/TransactionValidatorTests.cs +++ b/src/api/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.Domain.Enums; -using FinancialHub.Core.WebApi.Validators; +using FinancialHub.Core.Application.Validators; -namespace FinancialHub.Core.WebApi.NUnitTests.Validators +namespace FinancialHub.Core.Application.Tests.Validators { public class TransactionValidatorTests { diff --git a/src/api/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..b2df365 --- /dev/null +++ b/src/api/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -0,0 +1,50 @@ +using Microsoft.Extensions.DependencyInjection; +using FinancialHub.Core.Application.Mappers; +using FinancialHub.Core.Application.Services; +using FinancialHub.Core.Application.Validators; +using FluentValidation; + +namespace FinancialHub.Core.Application.Extensions.Configurations +{ + public static class IServiceCollectionExtensions + { + public static IServiceCollection AddCoreServices(this IServiceCollection services) + { + services.AddMapper(); + services.AddServices(); + services.AddValidators(); + + return services; + } + + private static IServiceCollection AddServices(this IServiceCollection services) + { + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + + services.AddScoped(); + services.AddScoped(); + + return services; + } + + private static IServiceCollection AddMapper(this IServiceCollection services) + { + services.AddAutoMapper(typeof(FinancialHubAutoMapperProfile)); + services.AddScoped(); + + return services; + } + + private static IServiceCollection AddValidators(this IServiceCollection services) + { + services.AddScoped, AccountValidator>(); + services.AddScoped, CategoryValidator>(); + services.AddScoped, TransactionValidator>(); + + return services; + } + } +} diff --git a/src/api/FinancialHub.Core.Services/FinancialHub.Core.Services.csproj b/src/api/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj similarity index 55% rename from src/api/FinancialHub.Core.Services/FinancialHub.Core.Services.csproj rename to src/api/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj index d8ce9f5..eceb265 100644 --- a/src/api/FinancialHub.Core.Services/FinancialHub.Core.Services.csproj +++ b/src/api/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj @@ -8,6 +8,7 @@ + @@ -16,4 +17,19 @@ + + + ErrorMessages.resx + True + True + + + + + + ErrorMessages.Designer.cs + ResXFileCodeGenerator + + + diff --git a/src/api/FinancialHub.Core.Services/Mappers/FinancialHubAutoMapperProfile.cs b/src/api/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs similarity index 93% rename from src/api/FinancialHub.Core.Services/Mappers/FinancialHubAutoMapperProfile.cs rename to src/api/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs index fde1334..32eae87 100644 --- a/src/api/FinancialHub.Core.Services/Mappers/FinancialHubAutoMapperProfile.cs +++ b/src/api/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs @@ -2,7 +2,7 @@ using FinancialHub.Core.Domain.Filters; using FinancialHub.Core.Domain.Queries; -namespace FinancialHub.Core.Services.Mappers +namespace FinancialHub.Core.Application.Mappers { public class FinancialHubAutoMapperProfile : Profile { diff --git a/src/api/FinancialHub.Core.Services/Mappers/FinancialHubMapperWrapper.cs b/src/api/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs similarity index 91% rename from src/api/FinancialHub.Core.Services/Mappers/FinancialHubMapperWrapper.cs rename to src/api/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs index 165424e..c927016 100644 --- a/src/api/FinancialHub.Core.Services/Mappers/FinancialHubMapperWrapper.cs +++ b/src/api/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs @@ -1,7 +1,7 @@ using AutoMapper; using FinancialHub.Core.Domain.Interfaces.Mappers; -namespace FinancialHub.Core.Services.Mappers +namespace FinancialHub.Core.Application.Mappers { public class FinancialHubMapperWrapper : IMapperWrapper { diff --git a/src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.Designer.cs b/src/api/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs similarity index 97% rename from src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.Designer.cs rename to src/api/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs index 8c5db0f..b39e401 100644 --- a/src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.Designer.cs +++ b/src/api/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace FinancialHub.Core.WebApi.Resources { +namespace FinancialHub.Core.Application.Resources { using System; @@ -39,7 +39,7 @@ internal ErrorMessages() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.Core.WebApi.Resources.ErrorMessages", typeof(ErrorMessages).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.Core.Application.Resources.ErrorMessages", typeof(ErrorMessages).Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.resx b/src/api/FinancialHub.Core.Application/Resources/ErrorMessages.resx similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Resources/ErrorMessages.resx rename to src/api/FinancialHub.Core.Application/Resources/ErrorMessages.resx diff --git a/src/api/FinancialHub.Core.Services/Services/AccountBalanceService.cs b/src/api/FinancialHub.Core.Application/Services/AccountBalanceService.cs similarity index 97% rename from src/api/FinancialHub.Core.Services/Services/AccountBalanceService.cs rename to src/api/FinancialHub.Core.Application/Services/AccountBalanceService.cs index b9f9064..ad4e88d 100644 --- a/src/api/FinancialHub.Core.Services/Services/AccountBalanceService.cs +++ b/src/api/FinancialHub.Core.Application/Services/AccountBalanceService.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.Services +namespace FinancialHub.Core.Application.Services { public class AccountBalanceService : IAccountBalanceService { diff --git a/src/api/FinancialHub.Core.Services/Services/AccountsService.cs b/src/api/FinancialHub.Core.Application/Services/AccountsService.cs similarity index 97% rename from src/api/FinancialHub.Core.Services/Services/AccountsService.cs rename to src/api/FinancialHub.Core.Application/Services/AccountsService.cs index 5dbadf0..255e6a3 100644 --- a/src/api/FinancialHub.Core.Services/Services/AccountsService.cs +++ b/src/api/FinancialHub.Core.Application/Services/AccountsService.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.Services +namespace FinancialHub.Core.Application.Services { public class AccountsService : IAccountsService { diff --git a/src/api/FinancialHub.Core.Services/Services/BalancesService.cs b/src/api/FinancialHub.Core.Application/Services/BalancesService.cs similarity index 98% rename from src/api/FinancialHub.Core.Services/Services/BalancesService.cs rename to src/api/FinancialHub.Core.Application/Services/BalancesService.cs index 649b53e..ba7845c 100644 --- a/src/api/FinancialHub.Core.Services/Services/BalancesService.cs +++ b/src/api/FinancialHub.Core.Application/Services/BalancesService.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.Services +namespace FinancialHub.Core.Application.Services { public class BalancesService : IBalancesService { diff --git a/src/api/FinancialHub.Core.Services/Services/CategoriesService.cs b/src/api/FinancialHub.Core.Application/Services/CategoriesService.cs similarity index 96% rename from src/api/FinancialHub.Core.Services/Services/CategoriesService.cs rename to src/api/FinancialHub.Core.Application/Services/CategoriesService.cs index f543507..05336d2 100644 --- a/src/api/FinancialHub.Core.Services/Services/CategoriesService.cs +++ b/src/api/FinancialHub.Core.Application/Services/CategoriesService.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Services.Services +namespace FinancialHub.Core.Application.Services { public class CategoriesService : ICategoriesService { diff --git a/src/api/FinancialHub.Core.Services/Services/TransactionBalanceService.cs b/src/api/FinancialHub.Core.Application/Services/TransactionBalanceService.cs similarity index 99% rename from src/api/FinancialHub.Core.Services/Services/TransactionBalanceService.cs rename to src/api/FinancialHub.Core.Application/Services/TransactionBalanceService.cs index 9ede95a..2cb7e53 100644 --- a/src/api/FinancialHub.Core.Services/Services/TransactionBalanceService.cs +++ b/src/api/FinancialHub.Core.Application/Services/TransactionBalanceService.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Core.Services.Services +namespace FinancialHub.Core.Application.Services { public class TransactionBalanceService : ITransactionBalanceService { diff --git a/src/api/FinancialHub.Core.Services/Services/TransactionsService.cs b/src/api/FinancialHub.Core.Application/Services/TransactionsService.cs similarity index 98% rename from src/api/FinancialHub.Core.Services/Services/TransactionsService.cs rename to src/api/FinancialHub.Core.Application/Services/TransactionsService.cs index 4bff9d1..f21bf22 100644 --- a/src/api/FinancialHub.Core.Services/Services/TransactionsService.cs +++ b/src/api/FinancialHub.Core.Application/Services/TransactionsService.cs @@ -2,7 +2,7 @@ using FinancialHub.Core.Domain.Queries; using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Core.Services.Services +namespace FinancialHub.Core.Application.Services { public class TransactionsService : ITransactionsService { diff --git a/src/api/FinancialHub.Core.Services/Usings.cs b/src/api/FinancialHub.Core.Application/Usings.cs similarity index 100% rename from src/api/FinancialHub.Core.Services/Usings.cs rename to src/api/FinancialHub.Core.Application/Usings.cs diff --git a/src/api/FinancialHub.Core.WebApi/Validators/AccountValidator.cs b/src/api/FinancialHub.Core.Application/Validators/AccountValidator.cs similarity index 83% rename from src/api/FinancialHub.Core.WebApi/Validators/AccountValidator.cs rename to src/api/FinancialHub.Core.Application/Validators/AccountValidator.cs index 202bf49..9c752da 100644 --- a/src/api/FinancialHub.Core.WebApi/Validators/AccountValidator.cs +++ b/src/api/FinancialHub.Core.Application/Validators/AccountValidator.cs @@ -1,7 +1,7 @@ -using FinancialHub.Core.WebApi.Resources; +using FinancialHub.Core.Application.Resources; using FluentValidation; -namespace FinancialHub.Core.WebApi.Validators +namespace FinancialHub.Core.Application.Validators { public class AccountValidator : AbstractValidator { diff --git a/src/api/FinancialHub.Core.WebApi/Validators/BalanceValidator.cs b/src/api/FinancialHub.Core.Application/Validators/BalanceValidator.cs similarity index 83% rename from src/api/FinancialHub.Core.WebApi/Validators/BalanceValidator.cs rename to src/api/FinancialHub.Core.Application/Validators/BalanceValidator.cs index 9b21317..3eff9c0 100644 --- a/src/api/FinancialHub.Core.WebApi/Validators/BalanceValidator.cs +++ b/src/api/FinancialHub.Core.Application/Validators/BalanceValidator.cs @@ -1,7 +1,7 @@ -using FinancialHub.Core.WebApi.Resources; +using FinancialHub.Core.Application.Resources; using FluentValidation; -namespace FinancialHub.Core.WebApi.Validators +namespace FinancialHub.Core.Application.Validators { public class BalanceValidator : AbstractValidator { diff --git a/src/api/FinancialHub.Core.WebApi/Validators/CategoryValidator.cs b/src/api/FinancialHub.Core.Application/Validators/CategoryValidator.cs similarity index 83% rename from src/api/FinancialHub.Core.WebApi/Validators/CategoryValidator.cs rename to src/api/FinancialHub.Core.Application/Validators/CategoryValidator.cs index f62fb5d..c884109 100644 --- a/src/api/FinancialHub.Core.WebApi/Validators/CategoryValidator.cs +++ b/src/api/FinancialHub.Core.Application/Validators/CategoryValidator.cs @@ -1,7 +1,7 @@ -using FinancialHub.Core.WebApi.Resources; +using FinancialHub.Core.Application.Resources; using FluentValidation; -namespace FinancialHub.Core.WebApi.Validators +namespace FinancialHub.Core.Application.Validators { public class CategoryValidator : AbstractValidator { diff --git a/src/api/FinancialHub.Core.WebApi/Validators/TransactionValidator.cs b/src/api/FinancialHub.Core.Application/Validators/TransactionValidator.cs similarity index 86% rename from src/api/FinancialHub.Core.WebApi/Validators/TransactionValidator.cs rename to src/api/FinancialHub.Core.Application/Validators/TransactionValidator.cs index 4fab67e..401879d 100644 --- a/src/api/FinancialHub.Core.WebApi/Validators/TransactionValidator.cs +++ b/src/api/FinancialHub.Core.Application/Validators/TransactionValidator.cs @@ -1,7 +1,7 @@ -using FinancialHub.Core.WebApi.Resources; +using FinancialHub.Core.Application.Resources; using FluentValidation; -namespace FinancialHub.Core.WebApi.Validators +namespace FinancialHub.Core.Application.Validators { public class TransactionValidator : AbstractValidator { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj b/src/api/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/FinancialHub.Core.Infra.Data.NUnitTests.csproj rename to src/api/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs similarity index 74% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs index 6e73d77..ed00b72 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Accounts/AccountsRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.Infra.Data.Repositories; -using FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Core.Infra.Data.Tests.Repositories.Base; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.Tests.Repositories { public class AccountsRepositoryTests : BaseRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs similarity index 98% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs index a04669f..b1bda66 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.amount.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Enums; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.Tests.Repositories { public partial class BalancesRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs similarity index 89% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs index 812a790..260ae84 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.create.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.Tests.Repositories { public partial class BalancesRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs similarity index 85% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs index 46ed97c..7b7b10c 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Balances/BalancesRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.Infra.Data.Repositories; -using FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Core.Infra.Data.Tests.Repositories.Base; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.Tests.Repositories { public partial class BalancesRepositoryTests : BaseRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs similarity index 96% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs index 192a99f..bd5c473 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.create.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs @@ -1,6 +1,6 @@ using FinancialHub.Common.Entities; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base +namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs similarity index 97% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs index dbe09a0..1b38dac 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs @@ -6,7 +6,7 @@ using FinancialHub.Common.Interfaces.Repositories; using FinancialHub.Core.Infra.Data.Contexts; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base +namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs similarity index 94% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs index 2429fa8..f4f5e71 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.delete.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs @@ -1,6 +1,6 @@ using FinancialHub.Common.Entities; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base +namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs similarity index 98% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs index d5a260a..a5432cb 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.get.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using FinancialHub.Common.Entities; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base +namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs similarity index 95% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs index 73964e2..c4a23f9 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Base/BaseRepositoryTests.update.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs @@ -1,7 +1,7 @@ using FinancialHub.Common.Entities; using Microsoft.EntityFrameworkCore; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base +namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base { public abstract partial class BaseRepositoryTests where T : BaseEntity diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs similarity index 74% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs index 6a3d824..241908d 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Categories/CategoriesRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs @@ -1,7 +1,7 @@ -using FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Core.Infra.Data.Tests.Repositories.Base; using FinancialHub.Core.Infra.Data.Repositories; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.Tests.Repositories { public class CategoriesRepositoryTests : BaseRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs similarity index 99% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs index 95c9da9..da81620 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.create.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.Tests.Repositories { public partial class TransactionsRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs similarity index 94% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs index f87f81e..dc28940 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.Infra.Data.Repositories; -using FinancialHub.Core.Infra.Data.NUnitTests.Repositories.Base; +using FinancialHub.Core.Infra.Data.Tests.Repositories.Base; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.Tests.Repositories { public partial class TransactionsRepositoryTests : BaseRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs similarity index 94% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs index 591d414..c695a91 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.Tests.Repositories { public partial class TransactionsRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs similarity index 98% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs index 0a2c4d9..e4e7657 100644 --- a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Repositories/Transactions/TransactionsRepositoryTests.update.cs +++ b/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore; -namespace FinancialHub.Core.Infra.Data.NUnitTests.Repositories +namespace FinancialHub.Core.Infra.Data.Tests.Repositories { public partial class TransactionsRepositoryTests { diff --git a/src/api/FinancialHub.Core.Infra.Data.NUnitTests/Usings.cs b/src/api/FinancialHub.Core.Infra.Data.Tests/Usings.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.NUnitTests/Usings.cs rename to src/api/FinancialHub.Core.Infra.Data.Tests/Usings.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs index 6090f82..035949c 100644 --- a/src/api/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -13,9 +13,7 @@ public static IServiceCollection AddRepositories(this IServiceCollection service provider => provider.UseSqlServer( configuration.GetConnectionString("default"), - x => x - .MigrationsAssembly("FinancialHub.Infra.Migrations") - .MigrationsHistoryTable("migrations") + x => x.MigrationsHistoryTable("migrations") ) ); services.AddScoped(); diff --git a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs similarity index 99% rename from src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs rename to src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs index d53da4b..b41081a 100644 --- a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.Designer.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs @@ -9,7 +9,7 @@ #nullable disable -namespace FinancialHub.Core.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Data.Migrations { [DbContext(typeof(FinancialHubContext))] [Migration("20220407152032_v0.2.4")] diff --git a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs similarity index 98% rename from src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs rename to src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs index ae68db4..4da3f7e 100644 --- a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220407152032_v0.2.4.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs @@ -4,7 +4,7 @@ #nullable disable -namespace FinancialHub.Core.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Data.Migrations { [ExcludeFromCodeCoverage] public partial class v024 : Migration diff --git a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs similarity index 99% rename from src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs rename to src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs index 752eac2..3464a87 100644 --- a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.Designer.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs @@ -9,7 +9,7 @@ #nullable disable -namespace FinancialHub.Core.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Data.Migrations { [DbContext(typeof(FinancialHubContext))] [Migration("20220520163358_add-balance")] diff --git a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.cs b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs similarity index 97% rename from src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.cs rename to src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs index 451b14f..90aa347 100644 --- a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520163358_add-balance.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs @@ -4,7 +4,7 @@ #nullable disable -namespace FinancialHub.Core.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Data.Migrations { [ExcludeFromCodeCoverage] public partial class addbalance : Migration diff --git a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs similarity index 99% rename from src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs rename to src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs index 70bcdc9..3d7e5c1 100644 --- a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.Designer.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs @@ -9,7 +9,7 @@ #nullable disable -namespace FinancialHub.Core.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Data.Migrations { [DbContext(typeof(FinancialHubContext))] [Migration("20220520215117_add-balance-to-transaction")] diff --git a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs similarity index 97% rename from src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs rename to src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs index a28c753..6efae8e 100644 --- a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215117_add-balance-to-transaction.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs @@ -3,7 +3,7 @@ #nullable disable -namespace FinancialHub.Core.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Data.Migrations { [ExcludeFromCodeCoverage] public partial class addbalancetotransaction : Migration diff --git a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs similarity index 99% rename from src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs rename to src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs index 44d52c9..e49ccd4 100644 --- a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.Designer.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs @@ -9,7 +9,7 @@ #nullable disable -namespace FinancialHub.Core.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Data.Migrations { [DbContext(typeof(FinancialHubContext))] [Migration("20220520215501_add-balance-active")] diff --git a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs similarity index 92% rename from src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs rename to src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs index 155589a..740819c 100644 --- a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/20220520215501_add-balance-active.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs @@ -3,7 +3,7 @@ #nullable disable -namespace FinancialHub.Core.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Data.Migrations { [ExcludeFromCodeCoverage] public partial class addbalanceactive : Migration diff --git a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs b/src/api/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs similarity index 99% rename from src/api/FinancialHub.Core.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs rename to src/api/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs index 3b1244e..f3342c7 100644 --- a/src/api/FinancialHub.Core.Infra.Migrations/Migrations/FinancialHubContextModelSnapshot.cs +++ b/src/api/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs @@ -8,7 +8,7 @@ #nullable disable -namespace FinancialHub.Core.Infra.Migrations.Migrations +namespace FinancialHub.Core.Infra.Data.Migrations { [DbContext(typeof(FinancialHubContext))] partial class FinancialHubContextModelSnapshot : ModelSnapshot diff --git a/src/api/FinancialHub.Core.Infra.Migrations/FinancialHub.Core.Infra.Migrations.csproj b/src/api/FinancialHub.Core.Infra.Migrations/FinancialHub.Core.Infra.Migrations.csproj deleted file mode 100644 index 7d17912..0000000 --- a/src/api/FinancialHub.Core.Infra.Migrations/FinancialHub.Core.Infra.Migrations.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - - - - diff --git a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs b/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs deleted file mode 100644 index 482eb05..0000000 --- a/src/api/FinancialHub.Core.Services.NUnitTests/Services/TransactionBalance/TransactionBalanceTests.cs +++ /dev/null @@ -1,9 +0,0 @@ -using FinancialHub.Core.Services.NUnitTests.Services.TransactionBalance; - -namespace FinancialHub.Core.Services.NUnitTests.Services -{ - public partial class TransactionBalanceTests : BaseTransactionBalanceTests - { - - } -} diff --git a/src/api/FinancialHub.Core.Services/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Core.Services/Extensions/Configurations/IServiceCollectionExtensions.cs deleted file mode 100644 index b9f92f0..0000000 --- a/src/api/FinancialHub.Core.Services/Extensions/Configurations/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using FinancialHub.Core.Services.Mappers; -using FinancialHub.Core.Services.Services; - -namespace FinancialHub.Core.Services.Extensions.Configurations -{ - public static class IServiceCollectionExtensions - { - public static IServiceCollection AddServices(this IServiceCollection services) - { - services.AddAutoMapper(typeof(FinancialHubAutoMapperProfile)); - services.AddScoped(); - - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - - services.AddScoped(); - services.AddScoped(); - - return services; - } - } -} diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs similarity index 97% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs index a552e1b..e6041c6 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.create.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs similarity index 93% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs index 617f3e6..7045a5c 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.WebApi.Controllers; using FinancialHub.Core.Domain.Interfaces.Services; -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs similarity index 89% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs index b3775d5..40488ef 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.delete.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs similarity index 94% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs index 9311692..6a5d7ad 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.get.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs similarity index 97% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs index 8e5fe58..2c1ca6c 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Accounts/AccountsControllerTests.update.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class AccountsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs similarity index 97% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs index a46c24a..21c5b5a 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.create.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class BalancesControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs similarity index 92% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs index 5918410..c676348 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.WebApi.Controllers; using FinancialHub.Core.Domain.Interfaces.Services; -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class BalancesControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs similarity index 87% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs index bef6f4a..7fbcdbd 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.delete.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class BalancesControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs similarity index 97% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs index 574f564..ba814b4 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Balances/BalancesControllerTests.update.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class BalancesControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs similarity index 97% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs index 36c7ed4..5b06923 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.create.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs similarity index 92% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs index a73ed22..f2f3bee 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.WebApi.Controllers; using FinancialHub.Core.Domain.Interfaces.Services; -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs similarity index 89% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs index c32f932..c32fb45 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.delete.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs similarity index 94% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs index 9ff3da8..d5c41a8 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.get.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs similarity index 97% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs index 82e1ab4..985024f 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Categories/CategoriesControllerTests.update.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class CategoriesControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs similarity index 97% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs index 15feb97..3223e48 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.create.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs similarity index 94% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs index 6f19bb2..a62f90a 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs @@ -1,7 +1,7 @@ using FinancialHub.Core.WebApi.Controllers; using FinancialHub.Core.Domain.Interfaces.Services; -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs similarity index 89% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs index 4cb5779..0266e37 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.delete.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs similarity index 95% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs index 7ce085f..5feeb8b 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.get.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs @@ -1,6 +1,6 @@ using FinancialHub.Core.Domain.Filters; -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs similarity index 97% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs index 3cda960..5f45863 100644 --- a/src/api/FinancialHub.Core.WebApi.NUnitTests/Controllers/Transactions/TransactionsControllerTests.update.cs +++ b/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Core.WebApi.NUnitTests.Controllers +namespace FinancialHub.Core.WebApi.Tests.Controllers { public partial class TransactionsControllerTests { diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/FinancialHub.Core.WebApi.NUnitTests.csproj b/src/api/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj similarity index 100% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/FinancialHub.Core.WebApi.NUnitTests.csproj rename to src/api/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj diff --git a/src/api/FinancialHub.Core.WebApi.NUnitTests/Usings.cs b/src/api/FinancialHub.Core.WebApi.Tests/Usings.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.NUnitTests/Usings.cs rename to src/api/FinancialHub.Core.WebApi.Tests/Usings.cs diff --git a/src/api/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs index 3308141..d40054f 100644 --- a/src/api/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs +++ b/src/api/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs @@ -2,7 +2,6 @@ using FluentValidation; using FluentValidation.AspNetCore; using Microsoft.OpenApi.Models; -using FinancialHub.Core.WebApi.Validators; namespace FinancialHub.Core.WebApi.Extensions.Configurations { @@ -22,6 +21,7 @@ public static IServiceCollection AddApiConfigurations(this IServiceCollection se { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Financial Hub WebApi", Version = "v1" }); }); + return services; } @@ -32,9 +32,7 @@ public static IServiceCollection AddValidators(this IServiceCollection services) x.AutomaticValidationEnabled = true; x.DisableDataAnnotationsValidation = true; }); - services.AddScoped, AccountValidator>(); - services.AddScoped, CategoryValidator>(); - services.AddScoped, TransactionValidator>(); + return services; } } diff --git a/src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj b/src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj index 3caa213..f16d719 100644 --- a/src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj +++ b/src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj @@ -24,16 +24,8 @@ + - - - - - - True - True - ErrorMessages.resx - @@ -44,11 +36,4 @@ - - - ResXFileCodeGenerator - ErrorMessages.Designer.cs - - - diff --git a/src/api/FinancialHub.Core.WebApi/Startup.cs b/src/api/FinancialHub.Core.WebApi/Startup.cs index 00dbf7a..de08184 100644 --- a/src/api/FinancialHub.Core.WebApi/Startup.cs +++ b/src/api/FinancialHub.Core.WebApi/Startup.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Hosting; using FinancialHub.Core.WebApi.Extensions.Configurations; using FinancialHub.Core.Infra.Data.Extensions.Configurations; -using FinancialHub.Core.Services.Extensions.Configurations; +using FinancialHub.Core.Application.Extensions.Configurations; namespace FinancialHub.Core.WebApi { @@ -22,8 +22,7 @@ public void ConfigureServices(IServiceCollection services) { services.AddApiConfigurations(); - services.AddValidators(); - services.AddServices(); + services.AddCoreServices(); services.AddRepositories(Configuration); services.AddMvc().AddNewtonsoftJson(); diff --git a/src/api/FinancialHub.sln b/src/api/FinancialHub.sln index b14e779..a59ec75 100644 --- a/src/api/FinancialHub.sln +++ b/src/api/FinancialHub.sln @@ -7,12 +7,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{1F4F43 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{2444FB9D-15D1-4193-BF04-83C4397369DA}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{91A212DC-1D96-43DD-B1A0-153ACB6980D5}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{91A212DC-1D96-43DD-B1A0-153ACB6980D5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{8AFE509C-0DD0-4C85-8BEA-24FB599293D7}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Migrations", "Migrations", "{EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Auth", "Auth", "{7CF52440-3820-40A7-B0B0-55E56F4FFF35}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D}" @@ -63,14 +61,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentatio EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data", "FinancialHub.Core.Infra.Data\FinancialHub.Core.Infra.Data.csproj", "{4B4B713A-4134-4221-A62A-7597FE72694C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data.NUnitTests", "FinancialHub.Core.Infra.Data.NUnitTests\FinancialHub.Core.Infra.Data.NUnitTests.csproj", "{2ED0A937-8026-4CCF-820A-5C2D10401AFC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Migrations", "FinancialHub.Core.Infra.Migrations\FinancialHub.Core.Infra.Migrations.csproj", "{15162FAE-26C6-4335-9919-762278E53DEF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Services", "FinancialHub.Core.Services\FinancialHub.Core.Services.csproj", "{FBB12706-8963-46AF-A0B2-4095939BB007}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Services.NUnitTests", "FinancialHub.Core.Services.NUnitTests\FinancialHub.Core.Services.NUnitTests.csproj", "{9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain", "FinancialHub.Core.Domain\FinancialHub.Core.Domain.csproj", "{84D15870-8431-49D4-A075-9BA5D9B0CF0A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain.Tests", "FinancialHub.Core.Domain.Tests\FinancialHub.Core.Domain.Tests.csproj", "{2E731A85-ED5E-4826-93E0-239F012C7DC4}" @@ -79,7 +69,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Integrati EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi", "FinancialHub.Core.WebApi\FinancialHub.Core.WebApi.csproj", "{F30D2F25-88CE-416B-B958-0F07668EB3B7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi.NUnitTests", "FinancialHub.Core.WebApi.NUnitTests\FinancialHub.Core.WebApi.NUnitTests.csproj", "{CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application", "FinancialHub.Core.Application\FinancialHub.Core.Application.csproj", "{9674CB4B-0314-435E-8214-2A07CDD7A030}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application.Tests", "FinancialHub.Core.Application.Tests\FinancialHub.Core.Application.Tests.csproj", "{B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data.Tests", "FinancialHub.Core.Infra.Data.Tests\FinancialHub.Core.Infra.Data.Tests.csproj", "{9321AA8B-9138-4419-923C-86A1D0349277}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi.Tests", "FinancialHub.Core.WebApi.Tests\FinancialHub.Core.WebApi.Tests.csproj", "{3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -151,22 +147,6 @@ Global {4B4B713A-4134-4221-A62A-7597FE72694C}.Debug|Any CPU.Build.0 = Debug|Any CPU {4B4B713A-4134-4221-A62A-7597FE72694C}.Release|Any CPU.ActiveCfg = Release|Any CPU {4B4B713A-4134-4221-A62A-7597FE72694C}.Release|Any CPU.Build.0 = Release|Any CPU - {2ED0A937-8026-4CCF-820A-5C2D10401AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2ED0A937-8026-4CCF-820A-5C2D10401AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2ED0A937-8026-4CCF-820A-5C2D10401AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2ED0A937-8026-4CCF-820A-5C2D10401AFC}.Release|Any CPU.Build.0 = Release|Any CPU - {15162FAE-26C6-4335-9919-762278E53DEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {15162FAE-26C6-4335-9919-762278E53DEF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {15162FAE-26C6-4335-9919-762278E53DEF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {15162FAE-26C6-4335-9919-762278E53DEF}.Release|Any CPU.Build.0 = Release|Any CPU - {FBB12706-8963-46AF-A0B2-4095939BB007}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FBB12706-8963-46AF-A0B2-4095939BB007}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FBB12706-8963-46AF-A0B2-4095939BB007}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FBB12706-8963-46AF-A0B2-4095939BB007}.Release|Any CPU.Build.0 = Release|Any CPU - {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B}.Release|Any CPU.Build.0 = Release|Any CPU {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Debug|Any CPU.Build.0 = Debug|Any CPU {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -183,10 +163,22 @@ Global {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Release|Any CPU.Build.0 = Release|Any CPU - {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16}.Release|Any CPU.Build.0 = Release|Any CPU + {9674CB4B-0314-435E-8214-2A07CDD7A030}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9674CB4B-0314-435E-8214-2A07CDD7A030}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9674CB4B-0314-435E-8214-2A07CDD7A030}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9674CB4B-0314-435E-8214-2A07CDD7A030}.Release|Any CPU.Build.0 = Release|Any CPU + {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}.Release|Any CPU.Build.0 = Release|Any CPU + {9321AA8B-9138-4419-923C-86A1D0349277}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9321AA8B-9138-4419-923C-86A1D0349277}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9321AA8B-9138-4419-923C-86A1D0349277}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9321AA8B-9138-4419-923C-86A1D0349277}.Release|Any CPU.Build.0 = Release|Any CPU + {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -196,7 +188,6 @@ Global {2444FB9D-15D1-4193-BF04-83C4397369DA} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {91A212DC-1D96-43DD-B1A0-153ACB6980D5} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} = {2444FB9D-15D1-4193-BF04-83C4397369DA} - {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} = {2444FB9D-15D1-4193-BF04-83C4397369DA} {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} {B918D713-0701-447C-B403-10DE0C769581} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} {74BFDE19-E416-46A1-B9C2-878DA41B249A} = {B918D713-0701-447C-B403-10DE0C769581} @@ -219,15 +210,14 @@ Global {83866048-B248-4D23-9716-559AB5A5E860} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {4B4B713A-4134-4221-A62A-7597FE72694C} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} - {2ED0A937-8026-4CCF-820A-5C2D10401AFC} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} - {15162FAE-26C6-4335-9919-762278E53DEF} = {EBFABBC1-2D70-4CAE-8352-AB1989AE5D9E} - {FBB12706-8963-46AF-A0B2-4095939BB007} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} - {9D6D3AB5-F998-48C2-AA4F-C129A9E9F28B} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} {84D15870-8431-49D4-A075-9BA5D9B0CF0A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {2E731A85-ED5E-4826-93E0-239F012C7DC4} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} {F30D2F25-88CE-416B-B958-0F07668EB3B7} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} - {CAC76031-2C2D-4303-B7E1-EDEB8C1A4E16} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} + {9674CB4B-0314-435E-8214-2A07CDD7A030} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} + {9321AA8B-9138-4419-923C-86A1D0349277} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} + {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} From a5b5a8cb9471cad7c8cb272ad04972b09452f103 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Wed, 6 Sep 2023 14:35:48 -0300 Subject: [PATCH 22/30] Release v0.5.3 * Adds glogal .editorconfig * Add Full, Core and Auth Solution * Add matrix test for CI * Add Category "Unit" for unit test projects * Add Category "Integration" for integration test projects * Add .editorconfig in projects to prevent constructor code smell in test code * Separate Test Results in projects (auth and core) * Move tests to /tests folder * Move Migrations to Infra.Data * Change the whole project folder structure * Separate /api projects in contexts * Fix projects references * Fix test projects references * Remove Core.Infra.Migrations project --- .github/actions/cache-sonar/action.yml | 25 ++ .github/actions/run-tests/action.yml | 22 ++ .github/workflows/api_releases.yml | 2 +- .github/workflows/branch_main_ci.yml | 15 +- .github/workflows/branch_release_ci.yml | 15 +- .github/workflows/matrix_test_result.yml | 65 ++++ .github/workflows/test_result.yml | 16 +- src/api/.editorconfig | 231 +++++++++++- .../Usings.cs | 8 - .../FinancialHub.Auth.Infra.Migrations.csproj | 17 - src/api/FinancialHub.sln | 339 +++++++++--------- .../Configurations/TokenServiceSettings.cs | 0 .../IServiceCollectionExtensions.Auth.cs | 0 .../IServiceCollectionExtensions.Docs.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Auth.Application.csproj | 1 + .../Services/SigninService.cs | 0 .../Services/SignupService.cs | 0 .../Services/TokenService.cs | 0 .../Services/UserService.cs | 0 .../FinancialHub.Auth.Application/Usings.cs | 0 .../Rules/ValidatorRulesExtensions.cs | 0 .../Validators/SigninModelValidator.cs | 0 .../Validators/SignupModelValidator.cs | 0 .../Validators/UserValidator.cs | 0 .../Entities/CredentialEntity.cs | 0 .../Entities/UserEntity.cs | 0 .../FinancialHub.Auth.Domain.csproj | 2 +- .../Interfaces/Helpers/IPasswordHelper.cs | 0 .../Providers/ICredentialProvider.cs | 0 .../Interfaces/Providers/ISigninProvider.cs | 0 .../Interfaces/Providers/ISignupProvider.cs | 0 .../Interfaces/Providers/IUserProvider.cs | 0 .../Repositories/ICredentialRepository.cs | 0 .../Repositories/IUserRepository.cs | 0 .../Resources/IErrorMessageProvider.cs | 0 .../Interfaces/Services/ISigninService.cs | 0 .../Interfaces/Services/ISignupService.cs | 0 .../Interfaces/Services/ITokenService.cs | 0 .../Interfaces/Services/IUserService.cs | 0 .../Models/CredentialModel.cs | 0 .../Models/SigninModel.cs | 0 .../Models/SignupModel.cs | 0 .../Models/TokenModel.cs | 0 .../Models/UserModel.cs | 0 .../FinancialHub.Auth.Domain/Usings.cs | 0 .../Contexts/FinancialHubAuthContext.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Auth.Infra.Data.csproj | 0 .../Mapping/UserCredentialEntityMapping.cs | 0 .../Mapping/UserEntityMapping.cs | 0 ...20230503220050_Adds_User_Table.Designer.cs | 0 .../20230503220050_Adds_User_Table.cs | 0 ...615215715_Add_Credential_Table.Designer.cs | 0 .../20230615215715_Add_Credential_Table.cs | 0 .../FinancialHubAuthContextModelSnapshot.cs | 0 .../Repositories/CredentialRepository.cs | 0 .../Repositories/UserRepository.cs | 0 .../FinancialHub.Auth.Infra.Data/Usings.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Auth.Infra.csproj | 0 .../Helpers/PasswordHelper.cs | 0 .../FinancialHubAuthCredentialProfile.cs | 0 .../Mappers/FinancialHubAuthProfile.cs | 0 .../Providers/CredentialProvider.cs | 0 .../Providers/SigninProvider.cs | 0 .../Providers/SignupProvider.cs | 0 .../Providers/UserProvider.cs | 0 .../FinancialHub.Auth.Infra/Usings.cs | 0 .../.editorconfig | 0 .../Controllers/SigninController.cs | 0 .../Controllers/SignupController.cs | 0 .../Controllers/UsersController.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../Extensions/SwaggerExtensions.cs | 0 .../FinancialHub.Auth.Presentation.csproj | 0 .../FinancialHub.Auth.Presentation/Usings.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Auth.Resources.csproj | 0 .../Providers/ErrorMessageProvider.cs | 0 .../Errors/ErrorMessages.Designer.cs | 0 .../Resources/Errors/ErrorMessages.pt-BR.resx | 0 .../Resources/Errors/ErrorMessages.resx | 0 .../FinancialHub.Auth.WebApi.csproj | 0 .../FinancialHub.Auth.WebApi/Program.cs | 0 .../Properties/launchSettings.json | 0 .../appsettings.Development.json | 0 .../appsettings.Testing.json | 0 .../FinancialHub.Auth.WebApi/appsettings.json | 0 src/api/auth/FinancialHub.Auth.sln | 145 ++++++++ .../Entities/BaseEntity.cs | 0 .../FinancialHub.Common.csproj | 0 .../Repositories/IBaseRepository.cs | 0 .../FinancialHub.Common/Models/BaseModel.cs | 0 .../Responses/Errors/BaseErrorResponse.cs | 0 .../Responses/Errors/NotFoundErrorResponse.cs | 0 .../Errors/ValidationErrorResponse.cs | 0 .../Errors/ValidationsErrorResponse.cs | 0 .../Responses/Success/BaseResponse.cs | 0 .../Responses/Success/ItemResponse.cs | 0 .../Responses/Success/ListResponse.cs | 0 .../Success/PaginatedListResponse.cs | 0 .../Responses/Success/SaveResponse.cs | 0 .../Results/Errors/InvalidDataError.cs | 0 .../Results/Errors/NotFoundError.cs | 0 .../Results/Errors/ServiceError.cs | 0 .../Results/ServiceResult.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Core.Application.csproj | 1 - .../Mappers/FinancialHubAutoMapperProfile.cs | 0 .../Mappers/FinancialHubMapperWrapper.cs | 0 .../Resources/ErrorMessages.Designer.cs | 0 .../Resources/ErrorMessages.resx | 0 .../Services/AccountBalanceService.cs | 0 .../Services/AccountsService.cs | 0 .../Services/BalancesService.cs | 0 .../Services/CategoriesService.cs | 0 .../Services/TransactionBalanceService.cs | 0 .../Services/TransactionsService.cs | 0 .../FinancialHub.Core.Application/Usings.cs | 0 .../Validators/AccountValidator.cs | 0 .../Validators/BalanceValidator.cs | 0 .../Validators/CategoryValidator.cs | 0 .../Validators/TransactionValidator.cs | 0 .../Entities/AccountEntity.cs | 0 .../Entities/BalanceEntity.cs | 0 .../Entities/CategoryEntity.cs | 0 .../Entities/TransactionEntity.cs | 0 .../Enums/TransactionStatus.cs | 0 .../Enums/TransactionType.cs | 0 .../Filters/TransactionFilter.cs | 0 .../FinancialHub.Core.Domain.csproj | 2 +- .../Interfaces/Mappers/IMapperWrapper.cs | 0 .../Repositories/IAccountsRepository.cs | 0 .../Repositories/IBalancesRepository.cs | 0 .../Repositories/ICategoriesRepository.cs | 0 .../Repositories/ITransactionsRepository.cs | 0 .../Services/IAccountBalanceService.cs | 0 .../Interfaces/Services/IAccountsService.cs | 0 .../Interfaces/Services/IBalancesService.cs | 0 .../Interfaces/Services/ICategoriesService.cs | 0 .../Services/ITransactionBalanceService.cs | 0 .../Services/ITransactionsService.cs | 0 .../Models/AccountModel.cs | 0 .../Models/BalanceModel.cs | 0 .../Models/CategoryModel.cs | 0 .../Models/TransactionModel.cs | 0 .../Queries/TransactionQuery.cs | 0 .../FinancialHubConcepts.Designer.cs | 0 .../Resources/FinancialHubConcepts.resx | 0 .../FinancialHub.Core.Domain/Usings.cs | 0 .../Contexts/FinancialHubContext.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Core.Infra.Data.csproj | 0 .../Mappings/AccountEntityMapping.cs | 0 .../Mappings/BalanceEntityMapping.cs | 0 .../Mappings/CategoryEntityMapping.cs | 0 .../Mappings/TransactionEntityMapping.cs | 0 .../20220407152032_v0.2.4.Designer.cs | 0 .../Migrations/20220407152032_v0.2.4.cs | 0 .../20220520163358_add-balance.Designer.cs | 0 .../Migrations/20220520163358_add-balance.cs | 0 ...117_add-balance-to-transaction.Designer.cs | 0 ...220520215117_add-balance-to-transaction.cs | 0 ...20520215501_add-balance-active.Designer.cs | 0 .../20220520215501_add-balance-active.cs | 0 .../FinancialHubContextModelSnapshot.cs | 0 .../Repositories/AccountsRepository.cs | 0 .../Repositories/BalancesRepository.cs | 0 .../Repositories/BaseRepository.cs | 0 .../Repositories/CategoriesRepository.cs | 0 .../Repositories/TransactionsRepository.cs | 0 .../FinancialHub.Core.Infra.Data/Usings.cs | 0 .../Controllers/AccountsController.cs | 0 .../Controllers/BalancesController.cs | 0 .../Controllers/CategoriesController.cs | 0 .../Controllers/TransactionsController.cs | 0 .../IServiceCollectionExtensions.cs | 0 .../FinancialHub.Core.WebApi.csproj | 4 - .../FinancialHub.Core.WebApi/Program.cs | 0 .../Properties/launchSettings.json | 0 .../FinancialHub.Core.WebApi/Startup.cs | 0 .../FinancialHub.Core.WebApi/Usings.cs | 0 .../appsettings.Development.json | 0 .../appsettings.Testing.json | 0 .../FinancialHub.Core.WebApi/appsettings.json | 0 src/api/core/FinancialHub.Core.sln | 119 ++++++ tests/.editorconfig | 233 ++++++++++++ ...FinancialHub.Auth.Application.Tests.csproj | 6 +- .../Services/Signin/SigninServiceTests.cs | 0 .../Services/Signin/SigninServiceTests.get.cs | 0 .../Signup/SignupServiceTests.create.cs | 0 .../Services/Signup/SignupServiceTests.cs | 0 .../Services/Token/TokenServiceTests.cs | 0 .../Token/TokenServiceTests.generate.cs | 0 .../Services/Users/UserServiceTests.create.cs | 0 .../Services/Users/UserServiceTests.cs | 0 .../Services/Users/UserServiceTests.get.cs | 0 .../Services/Users/UserServiceTests.update.cs | 0 .../Usings.cs | 10 + .../Validators/SigninModelValidatorTests.cs | 0 .../Validators/SignupModelValidatorTests.cs | 0 .../Validators/UserValidatorTests.cs | 0 .../Assertions/EntityAssert.cs | 4 +- .../Assertions/ModelAssert.cs | 2 +- .../Entities/UserCredentialEntityBuilder.cs | 2 +- .../Builders/Entities/UserEntityBuilder.cs | 2 +- .../Builders/Models/SigninModelBuilder.cs | 2 +- .../Builders/Models/SignupModelBuilder.cs | 2 +- .../Builders/Models/TokenModelBuilder.cs | 2 +- .../Models/UserCredentialModelBuilder.cs | 2 +- .../Builders/Models/UserModelBuilder.cs | 2 +- .../FinancialHub.Auth.Common.Tests.csproj | 4 +- .../FinancialHub.Auth.Common.Tests}/Usings.cs | 0 .../Assertions/DbContextAssert.cs | 0 .../FinancialHub.Auth.Infra.Data.Tests.csproj | 5 +- .../Fixtures/DatabaseFixture.cs | 0 .../CredentialRepositoryTests.create.cs | 0 .../Credentials/CredentialRepositoryTests.cs | 0 .../CredentialRepositoryTests.get.cs | 0 .../Users/UserRepositoryTests.create.cs | 0 .../Repositories/Users/UserRepositoryTests.cs | 0 .../Users/UserRepositoryTests.get.cs | 0 .../Users/UserRepositoryTests.update.cs | 0 .../Usings.cs | 8 +- .../FinancialHub.Auth.Infra.Tests.csproj | 4 +- .../CredentialProviderTests.create.cs | 0 .../Credentials/CredentialProviderTests.cs | 0 .../CredentialProviderTests.get.cs | 0 .../Providers/Signin/SigninProviderTests.cs | 0 .../SigninProviderTests.get_accounts.cs | 0 .../SignupProviderTests.create_account.cs | 0 .../Providers/Signup/SignupProviderTests.cs | 0 .../Users/UserProviderTests.create.cs | 0 .../Providers/Users/UserProviderTests.cs | 0 .../Providers/Users/UserProviderTests.get.cs | 0 .../Users/UserProviderTests.update.cs | 0 .../FinancialHub.Auth.Infra.Tests/Usings.cs | 8 +- .../Base/BaseControllerTests.cs | 0 .../Controllers/SigninControllerTests.cs | 0 .../Controllers/SignupControllerTests.cs | 0 .../Controllers/UsersControllerTests.cs | 0 .../Extensions/HttpClientExtensions.cs | 0 .../Extensions/HttpContentExtensions.cs | 0 .../HttpResponseMessageExtensions.cs | 0 .../Utils/HttpClientExtensionsParameters.cs | 0 .../FinancialHub.Auth.IntegrationTests.csproj | 5 +- .../Setup/FinancialHubAuthApiFixture.auth.cs | 0 .../Setup/FinancialHubAuthApiFixture.cs | 0 .../FinancialHubAuthApiFixture.database.cs | 0 .../Usings.cs | 8 +- .../Asserts/ControllerResponseAssert.cs | 0 .../Signin/SigninControllerTests.cs | 0 .../Signin/SigninControllerTests.get.cs | 0 .../Signup/SignupControllerTests.create.cs | 0 .../Signup/SignupControllerTests.cs | 0 .../Users/UsersControllerTests.create.cs | 0 .../Controllers/Users/UsersControllerTests.cs | 0 .../Users/UsersControllerTests.get.cs | 0 .../Users/UsersControllerTests.update.cs | 0 ...inancialHub.Auth.Presentation.Tests.csproj | 4 +- .../Usings.cs | 8 +- .../Responses/BaseResponseAssert.cs | 0 .../Builders/Entities/BaseEntityBuilder.cs | 0 .../Builders/Models/BaseModelBuilder.cs | 0 .../FinancialHub.Common.Tests.csproj | 2 +- ...FinancialHub.Core.Application.Tests.csproj | 3 +- .../AccountBalanceServiceTests.create.cs | 0 .../AccountBalanceServiceTests.cs | 0 .../AccountBalanceServiceTests.delete.cs | 0 .../Accounts/AccountsServiceTests.create.cs | 0 .../Services/Accounts/AccountsServiceTests.cs | 0 .../Accounts/AccountsServiceTests.delete.cs | 0 .../Accounts/AccountsServiceTests.get.cs | 0 .../Accounts/AccountsServiceTests.update.cs | 0 .../Balances/BalancesServiceTests.create.cs | 0 .../Services/Balances/BalancesServiceTests.cs | 0 .../Balances/BalancesServiceTests.delete.cs | 0 .../Balances/BalancesServiceTests.get.cs | 0 .../Balances/BalancesServiceTests.update.cs | 0 .../BalancesServiceTests.updateamount.cs | 0 .../CategoriesServiceTests.create.cs | 0 .../Categories/CategoriesServiceTests.cs | 0 .../CategoriesServiceTests.delete.cs | 0 .../Categories/CategoriesServiceTests.get.cs | 0 .../CategoriesServiceTests.update.cs | 0 .../BaseTransactionBalanceTests.cs | 0 .../TransactionBalanceTests.create.cs | 0 .../TransactionBalanceTests.cs | 0 .../TransactionBalanceTests.delete.cs | 0 .../TransactionBalanceTests.update.cs | 0 .../TransactionBalanceTests.updateamount.cs | 0 .../TransactionsServiceTests.create.cs | 0 .../Transactions/TransactionsServiceTests.cs | 0 .../TransactionsServiceTests.delete.cs | 0 .../TransactionsServiceTests.get.cs | 0 .../TransactionsServiceTests.update.cs | 0 .../Usings.cs | 4 +- .../Validators/AccountValidatorTests.cs | 0 .../Validators/BalanceValidatorTests.cs | 0 .../Validators/CategoryValidatorTests.cs | 0 .../Validators/TransactionValidatorTests.cs | 0 .../Entities/BalanceEntityAssert.cs | 0 .../Assertions/Models/AccountModelAssert.cs | 0 .../Assertions/Models/BalanceModelAssert.cs | 0 .../Assertions/Models/CategoryModelAssert.cs | 0 .../Models/TransactionModelAssert.cs | 0 .../Builders/Entities/AccountEntityBuilder.cs | 0 .../Builders/Entities/BalanceEntityBuilder.cs | 0 .../Entities/CategoryEntityBuilder.cs | 0 .../Entities/TransactionEntityBuilder.cs | 0 .../Builders/Models/AccountModelBuilder.cs | 0 .../Builders/Models/BalanceModelBuilder.cs | 0 .../Builders/Models/CategoryModelBuilder.cs | 0 .../Models/TransactionModelBuilder.cs | 0 .../FinancialHub.Core.Domain.Tests.csproj | 4 +- .../Queries/TransactionQueryTests.cs | 0 .../FinancialHub.Core.Domain.Tests/Usings.cs | 4 +- .../FinancialHub.Core.Infra.Data.Tests.csproj | 2 +- .../Accounts/AccountsRepositoryTests.cs | 0 .../BalancesRepositoryTests.amount.cs | 0 .../BalancesRepositoryTests.create.cs | 0 .../Balances/BalancesRepositoryTests.cs | 5 +- .../Base/BaseRepositoryTests.create.cs | 0 .../Repositories/Base/BaseRepositoryTests.cs | 0 .../Base/BaseRepositoryTests.delete.cs | 0 .../Base/BaseRepositoryTests.get.cs | 0 .../Base/BaseRepositoryTests.update.cs | 0 .../Categories/CategoriesRepositoryTests.cs | 0 .../TransactionsRepositoryTests.create.cs | 0 .../TransactionsRepositoryTests.cs | 0 .../TransactionsRepositoryTests.delete.cs | 0 .../TransactionsRepositoryTests.update.cs | 0 .../Usings.cs | 4 +- .../Base/BaseControllerTests.cs | 0 .../Controllers/AccountsControllerTests.cs | 0 .../Controllers/BalancesControllerTests.cs | 0 .../Controllers/CategoriesControllerTests.cs | 0 .../TransactionsControllerTests.cs | 0 .../Extensions/HttpClientExtensions.cs | 0 .../HttpResponseMessageExtensions.cs | 0 .../FinancialHub.Core.IntegrationTests.csproj | 23 +- .../Setup/FinancialHubFixture.cs | 0 .../Usings.cs | 4 +- .../AccountsControllerTests.create.cs | 0 .../Accounts/AccountsControllerTests.cs | 0 .../AccountsControllerTests.delete.cs | 0 .../Accounts/AccountsControllerTests.get.cs | 0 .../AccountsControllerTests.update.cs | 0 .../BalancesControllerTests.create.cs | 0 .../Balances/BalancesControllerTests.cs | 0 .../BalancesControllerTests.delete.cs | 0 .../BalancesControllerTests.update.cs | 0 .../CategoriesControllerTests.create.cs | 0 .../Categories/CategoriesControllerTests.cs | 0 .../CategoriesControllerTests.delete.cs | 0 .../CategoriesControllerTests.get.cs | 0 .../CategoriesControllerTests.update.cs | 0 .../TransactionsControllerTests.create.cs | 0 .../TransactionsControllerTests.cs | 0 .../TransactionsControllerTests.delete.cs | 0 .../TransactionsControllerTests.get.cs | 0 .../TransactionsControllerTests.update.cs | 0 .../FinancialHub.Core.WebApi.Tests.csproj | 2 +- .../FinancialHub.Core.WebApi.Tests/Usings.cs | 4 +- 365 files changed, 1145 insertions(+), 268 deletions(-) create mode 100644 .github/actions/cache-sonar/action.yml create mode 100644 .github/actions/run-tests/action.yml create mode 100644 .github/workflows/matrix_test_result.yml delete mode 100644 src/api/FinancialHub.Auth.Application.Tests/Usings.cs delete mode 100644 src/api/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj rename src/api/{ => auth}/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj (92%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Services/SigninService.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Services/SignupService.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Services/TokenService.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Services/UserService.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Usings.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Application/Validators/UserValidator.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Entities/UserEntity.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj (71%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Models/CredentialModel.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Models/SigninModel.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Models/SignupModel.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Models/TokenModel.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Models/UserModel.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Domain/Usings.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra.Data/Usings.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/Providers/SigninProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/Providers/SignupProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/Providers/UserProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Infra/Usings.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Presentation/.editorconfig (100%) rename src/api/{ => auth}/FinancialHub.Auth.Presentation/Controllers/SigninController.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Presentation/Controllers/SignupController.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Presentation/Controllers/UsersController.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj (100%) rename src/api/{ => auth}/FinancialHub.Auth.Presentation/Usings.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj (100%) rename src/api/{ => auth}/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx (100%) rename src/api/{ => auth}/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx (100%) rename src/api/{ => auth}/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj (100%) rename src/api/{ => auth}/FinancialHub.Auth.WebApi/Program.cs (100%) rename src/api/{ => auth}/FinancialHub.Auth.WebApi/Properties/launchSettings.json (100%) rename src/api/{ => auth}/FinancialHub.Auth.WebApi/appsettings.Development.json (100%) rename src/api/{ => auth}/FinancialHub.Auth.WebApi/appsettings.Testing.json (100%) rename src/api/{ => auth}/FinancialHub.Auth.WebApi/appsettings.json (100%) create mode 100644 src/api/auth/FinancialHub.Auth.sln rename src/api/{ => common}/FinancialHub.Common/Entities/BaseEntity.cs (100%) rename src/api/{ => common}/FinancialHub.Common/FinancialHub.Common.csproj (100%) rename src/api/{ => common}/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Models/BaseModel.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Responses/Errors/BaseErrorResponse.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Responses/Errors/NotFoundErrorResponse.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Responses/Errors/ValidationErrorResponse.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Responses/Errors/ValidationsErrorResponse.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Responses/Success/BaseResponse.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Responses/Success/ItemResponse.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Responses/Success/ListResponse.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Responses/Success/PaginatedListResponse.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Responses/Success/SaveResponse.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Results/Errors/InvalidDataError.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Results/Errors/NotFoundError.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Results/Errors/ServiceError.cs (100%) rename src/api/{ => common}/FinancialHub.Common/Results/ServiceResult.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj (92%) rename src/api/{ => core}/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Resources/ErrorMessages.resx (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Services/AccountBalanceService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Services/AccountsService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Services/BalancesService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Services/CategoriesService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Services/TransactionBalanceService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Services/TransactionsService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Usings.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Validators/AccountValidator.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Validators/BalanceValidator.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Validators/CategoryValidator.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Application/Validators/TransactionValidator.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Entities/AccountEntity.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Entities/BalanceEntity.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Entities/CategoryEntity.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Entities/TransactionEntity.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Enums/TransactionStatus.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Enums/TransactionType.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Filters/TransactionFilter.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj (89%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Models/AccountModel.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Models/BalanceModel.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Models/CategoryModel.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Models/TransactionModel.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Queries/TransactionQuery.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx (100%) rename src/api/{ => core}/FinancialHub.Core.Domain/Usings.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs (100%) rename src/api/{ => core}/FinancialHub.Core.Infra.Data/Usings.cs (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/Controllers/AccountsController.cs (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/Controllers/BalancesController.cs (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj (94%) rename src/api/{ => core}/FinancialHub.Core.WebApi/Program.cs (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/Properties/launchSettings.json (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/Startup.cs (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/Usings.cs (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/appsettings.Development.json (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/appsettings.Testing.json (100%) rename src/api/{ => core}/FinancialHub.Core.WebApi/appsettings.json (100%) create mode 100644 src/api/core/FinancialHub.Core.sln create mode 100644 tests/.editorconfig rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj (65%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs (100%) create mode 100644 tests/auth/FinancialHub.Auth.Application.Tests/Usings.cs rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs (100%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Assertions/EntityAssert.cs (95%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Assertions/ModelAssert.cs (97%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Builders/Entities/UserCredentialEntityBuilder.cs (95%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Builders/Entities/UserEntityBuilder.cs (94%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Builders/Models/SigninModelBuilder.cs (90%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Builders/Models/SignupModelBuilder.cs (96%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Builders/Models/TokenModelBuilder.cs (81%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Builders/Models/UserCredentialModelBuilder.cs (92%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Builders/Models/UserModelBuilder.cs (94%) rename src/api/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj => tests/auth/FinancialHub.Auth.Common.Tests/FinancialHub.Auth.Common.Tests.csproj (63%) rename {src/api/FinancialHub.Auth.Tests.Common => tests/auth/FinancialHub.Auth.Common.Tests}/Usings.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj (72%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Data.Tests/Usings.cs (58%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj (76%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Infra.Tests/Usings.cs (63%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj (70%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.IntegrationTests/Usings.cs (66%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs (100%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj (74%) rename {src/api => tests/auth}/FinancialHub.Auth.Presentation.Tests/Usings.cs (65%) rename {src/api => tests/common}/FinancialHub.Common.Tests/Assertions/Responses/BaseResponseAssert.cs (100%) rename {src/api => tests/common}/FinancialHub.Common.Tests/Builders/Entities/BaseEntityBuilder.cs (100%) rename {src/api => tests/common}/FinancialHub.Common.Tests/Builders/Models/BaseModelBuilder.cs (100%) rename {src/api => tests/common}/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj (78%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj (76%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Usings.cs (86%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj (79%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Domain.Tests/Usings.cs (81%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj (87%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs (82%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.Infra.Data.Tests/Usings.cs (79%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj (65%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.IntegrationTests/Usings.cs (92%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs (100%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj (85%) rename {src/api => tests/core}/FinancialHub.Core.WebApi.Tests/Usings.cs (88%) diff --git a/.github/actions/cache-sonar/action.yml b/.github/actions/cache-sonar/action.yml new file mode 100644 index 0000000..ffebd46 --- /dev/null +++ b/.github/actions/cache-sonar/action.yml @@ -0,0 +1,25 @@ +name: Cache Sonar Package & Sonar Scanner +description: This is just to make + +inputs: + os: + description: 'operational system' + required: true + +runs: + using: "composite" + steps: + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~\sonar\cache + key: ${{ inputs.os }}-sonar + restore-keys: ${{ inputs.os }}-sonar + + - name: Cache SonarCloud scanner + id: cache-sonar-scanner + uses: actions/cache@v1 + with: + path: .\.sonar\scanner + key: ${{ inputs.os }}-sonar-scanner + restore-keys: ${{ inputs.os }}-sonar-scanner \ No newline at end of file diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml new file mode 100644 index 0000000..d872f8b --- /dev/null +++ b/.github/actions/run-tests/action.yml @@ -0,0 +1,22 @@ +name: Run Tests +description: This project run project that has an assemly with an specified Category + +inputs: + project-dir: + description: 'project directory' + required: true + category: + description: 'Type of the test (Unit or Integration)' + default: Unit + +runs: + using: "composite" + steps: + - name: Run Tests + shell: bash + continue-on-error: true + run: dotnet test ${{ inputs.project-dir }} + --filter TestCategory=${{ inputs.category }} + --logger:"trx;logfilename=Results.xml" + --configuration release + \ No newline at end of file diff --git a/.github/workflows/api_releases.yml b/.github/workflows/api_releases.yml index 6ad7ae9..ab698eb 100644 --- a/.github/workflows/api_releases.yml +++ b/.github/workflows/api_releases.yml @@ -20,9 +20,9 @@ jobs: - name: Get version run: echo "value=${BRANCH##*/}" >> $GITHUB_OUTPUT + id: version env: BRANCH: ${{ github.event.pull_request.base.ref }} - id: version - name: Create tag uses: actions/github-script@v5 diff --git a/.github/workflows/branch_main_ci.yml b/.github/workflows/branch_main_ci.yml index 9e4219c..e9519a3 100644 --- a/.github/workflows/branch_main_ci.yml +++ b/.github/workflows/branch_main_ci.yml @@ -20,7 +20,18 @@ permissions: jobs: tests: - uses: ./.github/workflows/tests_workflow.yml + name: Tests + uses: ./.github/workflows/matrix_test_result.yml + secrets: inherit with: dir: ./src/api/ - secrets: inherit \ No newline at end of file + dotnet-version: 6.0.x + + code_analysis: + name: Code Analysis + needs: tests + uses: ./.github/workflows/coverage_report.yml + secrets: inherit + with: + dir: ./src/api/ + dotnet-version: 6.0.x \ No newline at end of file diff --git a/.github/workflows/branch_release_ci.yml b/.github/workflows/branch_release_ci.yml index 2fd81e1..7c0c7d2 100644 --- a/.github/workflows/branch_release_ci.yml +++ b/.github/workflows/branch_release_ci.yml @@ -14,7 +14,18 @@ permissions: jobs: tests: - uses: ./.github/workflows/tests_workflow.yml + name: Tests + uses: ./.github/workflows/matrix_test_result.yml + secrets: inherit with: dir: ./src/api/ - secrets: inherit \ No newline at end of file + dotnet-version: 6.0.x + + code_analysis: + name: Code Analysis + needs: tests + uses: ./.github/workflows/coverage_report.yml + secrets: inherit + with: + dir: ./src/api/ + dotnet-version: 6.0.x \ No newline at end of file diff --git a/.github/workflows/matrix_test_result.yml b/.github/workflows/matrix_test_result.yml new file mode 100644 index 0000000..c3caf7e --- /dev/null +++ b/.github/workflows/matrix_test_result.yml @@ -0,0 +1,65 @@ +name: Api Test Result +on: + workflow_call: + inputs: + dir: + type: string + required: true + dotnet-version: + type: string + default: 6.0.x + +permissions: + checks: write + pull-requests: write + +jobs: + test_results: + name: Code Tests + runs-on: ubuntu-latest + + strategy: + matrix: + project: + - core + - auth + env: + project-dir: ${{ inputs.dir }}/${{ matrix.project }} + + services: + sql-database: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + SA_PASSWORD: "P@ssw0rd!" + ACCEPT_EULA: "Y" + ports: + - 1450:1433 + + steps: + - uses: actions/checkout@v2 + + - name: Setup Project + uses: ./.github/actions/build-dotnet-project + with: + project-dir: ${{ inputs.dir }} + dotnet-version: 6.0.x + + - name: Run Unit Tests + uses: ./.github/actions/run-tests + with: + project-dir: ${{ inputs.dir }} + category: Unit + + - name: Run Integration Tests + uses: ./.github/actions/run-tests + with: + project-dir: ${{ inputs.dir }} + category: Integration + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/composite@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + check_name: ${{ matrix.project }} project test results + action_fail: true + files: "./tests/${{ matrix.project }}/**/TestResults/Results.xml" \ No newline at end of file diff --git a/.github/workflows/test_result.yml b/.github/workflows/test_result.yml index 3e6038e..85c04df 100644 --- a/.github/workflows/test_result.yml +++ b/.github/workflows/test_result.yml @@ -40,11 +40,17 @@ jobs: project-dir: ${{ inputs.dir }} dotnet-version: ${{ inputs.dotnet-version }} - - name: Run Tests - continue-on-error: true - run: dotnet test - --logger:"trx;logfilename=Results.xml" - --configuration release + - name: Run Unit Tests + uses: ./.github/actions/run-tests + with: + project-dir: ${{ inputs.dir }} + category: Unit + + - name: Run Integration Tests + uses: ./.github/actions/run-tests + with: + project-dir: ${{ inputs.dir }} + category: Integration - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action/composite@v2 diff --git a/src/api/.editorconfig b/src/api/.editorconfig index d43247d..a560d2e 100644 --- a/src/api/.editorconfig +++ b/src/api/.editorconfig @@ -1,4 +1,233 @@ -[*.cs] +# Remova a linha abaixo se quiser herdar as configurações do .editorconfig de diretórios superiores +root = true + +# Arquivos C# +[*.cs] + +#### Opções Principais do EditorConfig #### + +# Recuo e espaçamento +indent_size = 4 +indent_style = space +tab_width = 4 + +# Preferências de nova linha +end_of_line = crlf +insert_final_newline = false + +#### Convenções de codificação .NET #### + +# Organizar Usos +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# Preferências +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Preferências de tipos BCL contra palavras-chave do idioma +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Preferências de parênteses +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Preferências de modificador +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Preferências de nível de expressão +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Preferências de campo +dotnet_style_readonly_field = true + +# Preferências de parâmetro +dotnet_code_quality_unused_parameters = all + +# Preferências de supressão +dotnet_remove_unnecessary_suppression_exclusions = none + +# Preferências de nova linha +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### Convenções de Codificação em C# #### + +# preferências de var +csharp_style_var_elsewhere = false +csharp_style_var_for_built_in_types = false +csharp_style_var_when_type_is_apparent = false + +# Membros aptos para expressão +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = false +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = false +csharp_style_expression_bodied_methods = false +csharp_style_expression_bodied_operators = false +csharp_style_expression_bodied_properties = true + +# Preferências de correspondência de padrões +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Preferências de verificação nula +csharp_style_conditional_delegate_call = true + +# Preferências de modificador +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true +csharp_style_prefer_readonly_struct_member = true + +# Preferências do bloco de código +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true +csharp_style_namespace_declarations = block_scoped +csharp_style_prefer_method_group_conversion = true +csharp_style_prefer_primary_constructors = true +csharp_style_prefer_top_level_statements = true + +# Preferências de nível de expressão +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# Preferências da diretiva 'using' +csharp_using_directive_placement = outside_namespace + +# Preferências de nova linha +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### Regras de Formatação de C# #### + +# Preferências de nova linha +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Preferências de recuo +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Preferências de espaço +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Preferências de quebra de linha +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Estilos de nomenclatura #### + +# Regras de nomenclatura + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Especificações de símbolo + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Estilos de nomenclatura + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case # CS8618: O campo não anulável precisa conter um valor não nulo ao sair do construtor. Considere declará-lo como anulável. dotnet_diagnostic.CS8618.severity = none diff --git a/src/api/FinancialHub.Auth.Application.Tests/Usings.cs b/src/api/FinancialHub.Auth.Application.Tests/Usings.cs deleted file mode 100644 index 3701c6a..0000000 --- a/src/api/FinancialHub.Auth.Application.Tests/Usings.cs +++ /dev/null @@ -1,8 +0,0 @@ -global using NUnit.Framework; -global using Moq; - -global using FinancialHub.Auth.Domain.Models; - -global using FinancialHub.Auth.Tests.Common.Assertions; - -global using FinancialHub.Auth.Tests.Common.Builders.Models; diff --git a/src/api/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj b/src/api/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj deleted file mode 100644 index e8cc180..0000000 --- a/src/api/FinancialHub.Auth.Infra.Migrations/FinancialHub.Auth.Infra.Migrations.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - - - diff --git a/src/api/FinancialHub.sln b/src/api/FinancialHub.sln index a59ec75..53400e0 100644 --- a/src/api/FinancialHub.sln +++ b/src/api/FinancialHub.sln @@ -3,79 +3,84 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{1F4F43B0-14F5-4C91-B98C-AEB8A5421258}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{B00013E6-DB9F-415A-B542-6D32DA258EB2}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{2444FB9D-15D1-4193-BF04-83C4397369DA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common", "common\FinancialHub.Common\FinancialHub.Common.csproj", "{C24C6373-0DB4-4ECC-A902-692267EBD922}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{91A212DC-1D96-43DD-B1A0-153ACB6980D5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common.Tests", "..\..\tests\common\FinancialHub.Common.Tests\FinancialHub.Common.Tests.csproj", "{785E774A-9D67-4EAB-AB71-D60EBE8144DD}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{8AFE509C-0DD0-4C85-8BEA-24FB599293D7}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{BEE32E30-21CF-489B-B208-3D053E4966A8}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Auth", "Auth", "{7CF52440-3820-40A7-B0B0-55E56F4FFF35}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{FB841C40-3211-443F-AC95-CD5796CF4FB3}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application.Tests", "..\..\tests\core\FinancialHub.Core.Application.Tests\FinancialHub.Core.Application.Tests.csproj", "{54A8A393-BE7E-4403-8F48-EC42060F128E}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{B918D713-0701-447C-B403-10DE0C769581}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain.Tests", "..\..\tests\core\FinancialHub.Core.Domain.Tests\FinancialHub.Core.Domain.Tests.csproj", "{3B8AF190-2B4D-4647-877C-2FDE681C2ED3}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{74BFDE19-E416-46A1-B9C2-878DA41B249A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{0F151C31-117F-438E-A5B5-9EE1D669BE27}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{1488D2AC-39E7-414A-9B0A-344EBDA0E4E9}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{3B96E644-4E1A-4C2F-8F3C-E4843C921B92}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{93E5303C-66C1-4BF6-8823-6CBA9C3751BE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi.Tests", "..\..\tests\core\FinancialHub.Core.WebApi.Tests\FinancialHub.Core.WebApi.Tests.csproj", "{0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Domain", "FinancialHub.Auth.Domain\FinancialHub.Auth.Domain.csproj", "{82C01B54-91F9-4296-B2C7-F3FA230462F1}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{15C0C14F-DA06-46BB-A8B0-4BA5D6372777}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.WebApi", "FinancialHub.Auth.WebApi\FinancialHub.Auth.WebApi.csproj", "{23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Data.Tests", "FinancialHub.Auth.Infra.Data.Tests\FinancialHub.Auth.Infra.Data.Tests.csproj", "{3975688B-BF51-4DEB-8E19-777322865E83}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data.Tests", "..\..\tests\core\FinancialHub.Core.Infra.Data.Tests\FinancialHub.Core.Infra.Data.Tests.csproj", "{180DB5AB-AF6F-49EF-B5C6-6566B8B88711}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra", "FinancialHub.Auth.Infra\FinancialHub.Auth.Infra.csproj", "{F32C1BDA-B655-4E56-96A6-F8BD335707C6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application", "core\FinancialHub.Core.Application\FinancialHub.Core.Application.csproj", "{921409C4-23D6-4D92-B62F-2908142749C9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Tests.Common", "FinancialHub.Auth.Tests.Common\FinancialHub.Auth.Tests.Common.csproj", "{5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain", "core\FinancialHub.Core.Domain\FinancialHub.Core.Domain.csproj", "{DFA4EC74-777A-4929-96C6-C29463B22D58}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Data", "FinancialHub.Auth.Infra.Data\FinancialHub.Auth.Infra.Data.csproj", "{72C9C13F-BF8B-4649-B504-99E634FCDDE5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data", "core\FinancialHub.Core.Infra.Data\FinancialHub.Core.Infra.Data.csproj", "{893D69AA-5483-44AE-AD8C-E9C6E6F0276A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Tests", "FinancialHub.Auth.Infra.Tests\FinancialHub.Auth.Infra.Tests.csproj", "{A4D904E8-5A38-4E00-8419-62CB1F24F94E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi", "core\FinancialHub.Core.WebApi\FinancialHub.Core.WebApi.csproj", "{CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Resources", "FinancialHub.Auth.Resources\FinancialHub.Auth.Resources.csproj", "{8B091A42-5BE6-49A4-8086-C8761E0CE769}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.IntegrationTests", "..\..\tests\core\FinancialHub.Core.IntegrationTests\FinancialHub.Core.IntegrationTests.csproj", "{AC293685-7094-4325-8D5B-4ED252C62942}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{421DB63D-B9E6-4069-8B79-6C956506F3C5}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Auth", "Auth", "{A93CC4E0-F468-49C7-8429-9384A124BB2D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.IntegrationTests", "FinancialHub.Auth.IntegrationTests\FinancialHub.Auth.IntegrationTests.csproj", "{DD87106B-71B2-484D-A2CA-6ADD69C69CC7}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{698C287C-20C9-45E1-A6B2-15141C74C3E2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Presentation", "FinancialHub.Auth.Presentation\FinancialHub.Auth.Presentation.csproj", "{10A8A033-1884-4CD4-A413-75A8C08296D0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{2F11BC84-BA3C-43A0-BAB8-FC65E6E4566C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Presentation.Tests", "FinancialHub.Auth.Presentation.Tests\FinancialHub.Auth.Presentation.Tests.csproj", "{F6C7E760-0264-425B-A935-35C19701B428}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{B7C0B348-3E2C-40BA-850D-BDA93FEA6B44}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application", "FinancialHub.Auth.Application\FinancialHub.Auth.Application.csproj", "{C36391AC-AC61-4165-9C00-0B2B4ED78C8D}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{022A9AE7-CA3B-4DD1-934B-FBBF680312B1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application.Tests", "FinancialHub.Auth.Application.Tests\FinancialHub.Auth.Application.Tests.csproj", "{22448D38-BA25-4FAE-9337-BEA884C7EC57}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{4C3B217C-32D6-4995-BC05-08BC7490FF89}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{B00013E6-DB9F-415A-B542-6D32DA258EB2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application.Tests", "..\..\tests\auth\FinancialHub.Auth.Application.Tests\FinancialHub.Auth.Application.Tests.csproj", "{CCADF7E9-2D5E-433C-8376-1C4F32BEDED4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Common.Tests", "..\..\tests\auth\FinancialHub.Auth.Common.Tests\FinancialHub.Auth.Common.Tests.csproj", "{37DC7DFC-2806-4E22-9A9B-9A690AD95091}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common.Tests", "FinancialHub.Common.Tests\FinancialHub.Common.Tests.csproj", "{AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Data.Tests", "..\..\tests\auth\FinancialHub.Auth.Infra.Data.Tests\FinancialHub.Auth.Infra.Data.Tests.csproj", "{E9266D91-AF86-49E5-A4CA-08721FE01DB0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common", "FinancialHub.Common\FinancialHub.Common.csproj", "{83866048-B248-4D23-9716-559AB5A5E860}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Tests", "..\..\tests\auth\FinancialHub.Auth.Infra.Tests\FinancialHub.Auth.Infra.Tests.csproj", "{21A094AE-3A26-4E37-B76E-C213C84BEAFC}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Presentation.Tests", "..\..\tests\auth\FinancialHub.Auth.Presentation.Tests\FinancialHub.Auth.Presentation.Tests.csproj", "{B8858D6E-FEDA-45CA-A895-4FCDD45C4856}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data", "FinancialHub.Core.Infra.Data\FinancialHub.Core.Infra.Data.csproj", "{4B4B713A-4134-4221-A62A-7597FE72694C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.IntegrationTests", "..\..\tests\auth\FinancialHub.Auth.IntegrationTests\FinancialHub.Auth.IntegrationTests.csproj", "{5CB8F10A-96A8-4854-A990-13818B034F24}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain", "FinancialHub.Core.Domain\FinancialHub.Core.Domain.csproj", "{84D15870-8431-49D4-A075-9BA5D9B0CF0A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Presentation", "auth\FinancialHub.Auth.Presentation\FinancialHub.Auth.Presentation.csproj", "{B63EB0FB-B23B-43EB-A700-46F2F9D9CB39}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain.Tests", "FinancialHub.Core.Domain.Tests\FinancialHub.Core.Domain.Tests.csproj", "{2E731A85-ED5E-4826-93E0-239F012C7DC4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application", "auth\FinancialHub.Auth.Application\FinancialHub.Auth.Application.csproj", "{84793402-7ED4-4390-B7C7-87C11475B342}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.IntegrationTests", "FinancialHub.Core.IntegrationTests\FinancialHub.Core.IntegrationTests.csproj", "{B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Domain", "auth\FinancialHub.Auth.Domain\FinancialHub.Auth.Domain.csproj", "{AAD9189B-299E-4492-9B3E-4073D177E5FF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi", "FinancialHub.Core.WebApi\FinancialHub.Core.WebApi.csproj", "{F30D2F25-88CE-416B-B958-0F07668EB3B7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra", "auth\FinancialHub.Auth.Infra\FinancialHub.Auth.Infra.csproj", "{8D1218F9-926A-4EAB-8C53-1A83A8AAFF8F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application", "FinancialHub.Core.Application\FinancialHub.Core.Application.csproj", "{9674CB4B-0314-435E-8214-2A07CDD7A030}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Data", "auth\FinancialHub.Auth.Infra.Data\FinancialHub.Auth.Infra.Data.csproj", "{551319E1-1415-449B-A9B7-B49AA182D6C4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application.Tests", "FinancialHub.Core.Application.Tests\FinancialHub.Core.Application.Tests.csproj", "{B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Resources", "auth\FinancialHub.Auth.Resources\FinancialHub.Auth.Resources.csproj", "{F24D2732-A777-4246-A5E2-633FB552B999}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data.Tests", "FinancialHub.Core.Infra.Data.Tests\FinancialHub.Core.Infra.Data.Tests.csproj", "{9321AA8B-9138-4419-923C-86A1D0349277}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.WebApi", "auth\FinancialHub.Auth.WebApi\FinancialHub.Auth.WebApi.csproj", "{A1CE8588-9FE3-4ADB-AEB9-E34680091A78}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi.Tests", "FinancialHub.Core.WebApi.Tests\FinancialHub.Core.WebApi.Tests.csproj", "{3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D36A889D-A7ED-45B4-91DD-0039FC4211FB}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -83,141 +88,141 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {82C01B54-91F9-4296-B2C7-F3FA230462F1}.Release|Any CPU.Build.0 = Release|Any CPU - {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Debug|Any CPU.Build.0 = Debug|Any CPU - {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Release|Any CPU.ActiveCfg = Release|Any CPU - {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68}.Release|Any CPU.Build.0 = Release|Any CPU - {3975688B-BF51-4DEB-8E19-777322865E83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3975688B-BF51-4DEB-8E19-777322865E83}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3975688B-BF51-4DEB-8E19-777322865E83}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3975688B-BF51-4DEB-8E19-777322865E83}.Release|Any CPU.Build.0 = Release|Any CPU - {F32C1BDA-B655-4E56-96A6-F8BD335707C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F32C1BDA-B655-4E56-96A6-F8BD335707C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F32C1BDA-B655-4E56-96A6-F8BD335707C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F32C1BDA-B655-4E56-96A6-F8BD335707C6}.Release|Any CPU.Build.0 = Release|Any CPU - {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6}.Release|Any CPU.Build.0 = Release|Any CPU - {72C9C13F-BF8B-4649-B504-99E634FCDDE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72C9C13F-BF8B-4649-B504-99E634FCDDE5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72C9C13F-BF8B-4649-B504-99E634FCDDE5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72C9C13F-BF8B-4649-B504-99E634FCDDE5}.Release|Any CPU.Build.0 = Release|Any CPU - {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A4D904E8-5A38-4E00-8419-62CB1F24F94E}.Release|Any CPU.Build.0 = Release|Any CPU - {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8B091A42-5BE6-49A4-8086-C8761E0CE769}.Release|Any CPU.Build.0 = Release|Any CPU - {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DD87106B-71B2-484D-A2CA-6ADD69C69CC7}.Release|Any CPU.Build.0 = Release|Any CPU - {10A8A033-1884-4CD4-A413-75A8C08296D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {10A8A033-1884-4CD4-A413-75A8C08296D0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {10A8A033-1884-4CD4-A413-75A8C08296D0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {10A8A033-1884-4CD4-A413-75A8C08296D0}.Release|Any CPU.Build.0 = Release|Any CPU - {F6C7E760-0264-425B-A935-35C19701B428}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F6C7E760-0264-425B-A935-35C19701B428}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F6C7E760-0264-425B-A935-35C19701B428}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F6C7E760-0264-425B-A935-35C19701B428}.Release|Any CPU.Build.0 = Release|Any CPU - {C36391AC-AC61-4165-9C00-0B2B4ED78C8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C36391AC-AC61-4165-9C00-0B2B4ED78C8D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C36391AC-AC61-4165-9C00-0B2B4ED78C8D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C36391AC-AC61-4165-9C00-0B2B4ED78C8D}.Release|Any CPU.Build.0 = Release|Any CPU - {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Debug|Any CPU.Build.0 = Debug|Any CPU - {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Release|Any CPU.ActiveCfg = Release|Any CPU - {22448D38-BA25-4FAE-9337-BEA884C7EC57}.Release|Any CPU.Build.0 = Release|Any CPU - {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE}.Release|Any CPU.Build.0 = Release|Any CPU - {83866048-B248-4D23-9716-559AB5A5E860}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {83866048-B248-4D23-9716-559AB5A5E860}.Debug|Any CPU.Build.0 = Debug|Any CPU - {83866048-B248-4D23-9716-559AB5A5E860}.Release|Any CPU.ActiveCfg = Release|Any CPU - {83866048-B248-4D23-9716-559AB5A5E860}.Release|Any CPU.Build.0 = Release|Any CPU - {4B4B713A-4134-4221-A62A-7597FE72694C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4B4B713A-4134-4221-A62A-7597FE72694C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4B4B713A-4134-4221-A62A-7597FE72694C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4B4B713A-4134-4221-A62A-7597FE72694C}.Release|Any CPU.Build.0 = Release|Any CPU - {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {84D15870-8431-49D4-A075-9BA5D9B0CF0A}.Release|Any CPU.Build.0 = Release|Any CPU - {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E731A85-ED5E-4826-93E0-239F012C7DC4}.Release|Any CPU.Build.0 = Release|Any CPU - {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5}.Release|Any CPU.Build.0 = Release|Any CPU - {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F30D2F25-88CE-416B-B958-0F07668EB3B7}.Release|Any CPU.Build.0 = Release|Any CPU - {9674CB4B-0314-435E-8214-2A07CDD7A030}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9674CB4B-0314-435E-8214-2A07CDD7A030}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9674CB4B-0314-435E-8214-2A07CDD7A030}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9674CB4B-0314-435E-8214-2A07CDD7A030}.Release|Any CPU.Build.0 = Release|Any CPU - {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F}.Release|Any CPU.Build.0 = Release|Any CPU - {9321AA8B-9138-4419-923C-86A1D0349277}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9321AA8B-9138-4419-923C-86A1D0349277}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9321AA8B-9138-4419-923C-86A1D0349277}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9321AA8B-9138-4419-923C-86A1D0349277}.Release|Any CPU.Build.0 = Release|Any CPU - {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3}.Release|Any CPU.Build.0 = Release|Any CPU + {C24C6373-0DB4-4ECC-A902-692267EBD922}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C24C6373-0DB4-4ECC-A902-692267EBD922}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C24C6373-0DB4-4ECC-A902-692267EBD922}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C24C6373-0DB4-4ECC-A902-692267EBD922}.Release|Any CPU.Build.0 = Release|Any CPU + {785E774A-9D67-4EAB-AB71-D60EBE8144DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {785E774A-9D67-4EAB-AB71-D60EBE8144DD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {785E774A-9D67-4EAB-AB71-D60EBE8144DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {785E774A-9D67-4EAB-AB71-D60EBE8144DD}.Release|Any CPU.Build.0 = Release|Any CPU + {54A8A393-BE7E-4403-8F48-EC42060F128E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54A8A393-BE7E-4403-8F48-EC42060F128E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54A8A393-BE7E-4403-8F48-EC42060F128E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54A8A393-BE7E-4403-8F48-EC42060F128E}.Release|Any CPU.Build.0 = Release|Any CPU + {3B8AF190-2B4D-4647-877C-2FDE681C2ED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B8AF190-2B4D-4647-877C-2FDE681C2ED3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B8AF190-2B4D-4647-877C-2FDE681C2ED3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B8AF190-2B4D-4647-877C-2FDE681C2ED3}.Release|Any CPU.Build.0 = Release|Any CPU + {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}.Release|Any CPU.Build.0 = Release|Any CPU + {180DB5AB-AF6F-49EF-B5C6-6566B8B88711}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {180DB5AB-AF6F-49EF-B5C6-6566B8B88711}.Debug|Any CPU.Build.0 = Debug|Any CPU + {180DB5AB-AF6F-49EF-B5C6-6566B8B88711}.Release|Any CPU.ActiveCfg = Release|Any CPU + {180DB5AB-AF6F-49EF-B5C6-6566B8B88711}.Release|Any CPU.Build.0 = Release|Any CPU + {921409C4-23D6-4D92-B62F-2908142749C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {921409C4-23D6-4D92-B62F-2908142749C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {921409C4-23D6-4D92-B62F-2908142749C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {921409C4-23D6-4D92-B62F-2908142749C9}.Release|Any CPU.Build.0 = Release|Any CPU + {DFA4EC74-777A-4929-96C6-C29463B22D58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFA4EC74-777A-4929-96C6-C29463B22D58}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFA4EC74-777A-4929-96C6-C29463B22D58}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFA4EC74-777A-4929-96C6-C29463B22D58}.Release|Any CPU.Build.0 = Release|Any CPU + {893D69AA-5483-44AE-AD8C-E9C6E6F0276A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {893D69AA-5483-44AE-AD8C-E9C6E6F0276A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {893D69AA-5483-44AE-AD8C-E9C6E6F0276A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {893D69AA-5483-44AE-AD8C-E9C6E6F0276A}.Release|Any CPU.Build.0 = Release|Any CPU + {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}.Release|Any CPU.Build.0 = Release|Any CPU + {AC293685-7094-4325-8D5B-4ED252C62942}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC293685-7094-4325-8D5B-4ED252C62942}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC293685-7094-4325-8D5B-4ED252C62942}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC293685-7094-4325-8D5B-4ED252C62942}.Release|Any CPU.Build.0 = Release|Any CPU + {CCADF7E9-2D5E-433C-8376-1C4F32BEDED4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CCADF7E9-2D5E-433C-8376-1C4F32BEDED4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CCADF7E9-2D5E-433C-8376-1C4F32BEDED4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CCADF7E9-2D5E-433C-8376-1C4F32BEDED4}.Release|Any CPU.Build.0 = Release|Any CPU + {37DC7DFC-2806-4E22-9A9B-9A690AD95091}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {37DC7DFC-2806-4E22-9A9B-9A690AD95091}.Debug|Any CPU.Build.0 = Debug|Any CPU + {37DC7DFC-2806-4E22-9A9B-9A690AD95091}.Release|Any CPU.ActiveCfg = Release|Any CPU + {37DC7DFC-2806-4E22-9A9B-9A690AD95091}.Release|Any CPU.Build.0 = Release|Any CPU + {E9266D91-AF86-49E5-A4CA-08721FE01DB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9266D91-AF86-49E5-A4CA-08721FE01DB0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9266D91-AF86-49E5-A4CA-08721FE01DB0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9266D91-AF86-49E5-A4CA-08721FE01DB0}.Release|Any CPU.Build.0 = Release|Any CPU + {21A094AE-3A26-4E37-B76E-C213C84BEAFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21A094AE-3A26-4E37-B76E-C213C84BEAFC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21A094AE-3A26-4E37-B76E-C213C84BEAFC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21A094AE-3A26-4E37-B76E-C213C84BEAFC}.Release|Any CPU.Build.0 = Release|Any CPU + {B8858D6E-FEDA-45CA-A895-4FCDD45C4856}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8858D6E-FEDA-45CA-A895-4FCDD45C4856}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8858D6E-FEDA-45CA-A895-4FCDD45C4856}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8858D6E-FEDA-45CA-A895-4FCDD45C4856}.Release|Any CPU.Build.0 = Release|Any CPU + {5CB8F10A-96A8-4854-A990-13818B034F24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5CB8F10A-96A8-4854-A990-13818B034F24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5CB8F10A-96A8-4854-A990-13818B034F24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5CB8F10A-96A8-4854-A990-13818B034F24}.Release|Any CPU.Build.0 = Release|Any CPU + {B63EB0FB-B23B-43EB-A700-46F2F9D9CB39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B63EB0FB-B23B-43EB-A700-46F2F9D9CB39}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B63EB0FB-B23B-43EB-A700-46F2F9D9CB39}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B63EB0FB-B23B-43EB-A700-46F2F9D9CB39}.Release|Any CPU.Build.0 = Release|Any CPU + {84793402-7ED4-4390-B7C7-87C11475B342}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84793402-7ED4-4390-B7C7-87C11475B342}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84793402-7ED4-4390-B7C7-87C11475B342}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84793402-7ED4-4390-B7C7-87C11475B342}.Release|Any CPU.Build.0 = Release|Any CPU + {AAD9189B-299E-4492-9B3E-4073D177E5FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AAD9189B-299E-4492-9B3E-4073D177E5FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AAD9189B-299E-4492-9B3E-4073D177E5FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AAD9189B-299E-4492-9B3E-4073D177E5FF}.Release|Any CPU.Build.0 = Release|Any CPU + {8D1218F9-926A-4EAB-8C53-1A83A8AAFF8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D1218F9-926A-4EAB-8C53-1A83A8AAFF8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D1218F9-926A-4EAB-8C53-1A83A8AAFF8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D1218F9-926A-4EAB-8C53-1A83A8AAFF8F}.Release|Any CPU.Build.0 = Release|Any CPU + {551319E1-1415-449B-A9B7-B49AA182D6C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {551319E1-1415-449B-A9B7-B49AA182D6C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {551319E1-1415-449B-A9B7-B49AA182D6C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {551319E1-1415-449B-A9B7-B49AA182D6C4}.Release|Any CPU.Build.0 = Release|Any CPU + {F24D2732-A777-4246-A5E2-633FB552B999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F24D2732-A777-4246-A5E2-633FB552B999}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F24D2732-A777-4246-A5E2-633FB552B999}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F24D2732-A777-4246-A5E2-633FB552B999}.Release|Any CPU.Build.0 = Release|Any CPU + {A1CE8588-9FE3-4ADB-AEB9-E34680091A78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1CE8588-9FE3-4ADB-AEB9-E34680091A78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1CE8588-9FE3-4ADB-AEB9-E34680091A78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1CE8588-9FE3-4ADB-AEB9-E34680091A78}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} - {2444FB9D-15D1-4193-BF04-83C4397369DA} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} - {91A212DC-1D96-43DD-B1A0-153ACB6980D5} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} - {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} = {2444FB9D-15D1-4193-BF04-83C4397369DA} - {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} - {B918D713-0701-447C-B403-10DE0C769581} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} - {74BFDE19-E416-46A1-B9C2-878DA41B249A} = {B918D713-0701-447C-B403-10DE0C769581} - {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} - {82C01B54-91F9-4296-B2C7-F3FA230462F1} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} - {23B8FA7D-EA45-4006-BA1A-18AAC68A9B68} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} - {3975688B-BF51-4DEB-8E19-777322865E83} = {74BFDE19-E416-46A1-B9C2-878DA41B249A} - {F32C1BDA-B655-4E56-96A6-F8BD335707C6} = {B918D713-0701-447C-B403-10DE0C769581} - {5B40F1F1-5172-49A5-BBC2-9CC472CD89D6} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} - {72C9C13F-BF8B-4649-B504-99E634FCDDE5} = {74BFDE19-E416-46A1-B9C2-878DA41B249A} - {A4D904E8-5A38-4E00-8419-62CB1F24F94E} = {B918D713-0701-447C-B403-10DE0C769581} - {8B091A42-5BE6-49A4-8086-C8761E0CE769} = {7F00D819-7B4C-4A71-B9DB-E56ED20ADA0D} - {421DB63D-B9E6-4069-8B79-6C956506F3C5} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} - {DD87106B-71B2-484D-A2CA-6ADD69C69CC7} = {7CF52440-3820-40A7-B0B0-55E56F4FFF35} - {10A8A033-1884-4CD4-A413-75A8C08296D0} = {421DB63D-B9E6-4069-8B79-6C956506F3C5} - {F6C7E760-0264-425B-A935-35C19701B428} = {421DB63D-B9E6-4069-8B79-6C956506F3C5} - {C36391AC-AC61-4165-9C00-0B2B4ED78C8D} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} - {22448D38-BA25-4FAE-9337-BEA884C7EC57} = {1488D2AC-39E7-414A-9B0A-344EBDA0E4E9} - {AAE2A6B8-2EAC-4C6E-9F55-52E409B12DCE} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} - {83866048-B248-4D23-9716-559AB5A5E860} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} - {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} - {4B4B713A-4134-4221-A62A-7597FE72694C} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} - {84D15870-8431-49D4-A075-9BA5D9B0CF0A} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} - {2E731A85-ED5E-4826-93E0-239F012C7DC4} = {1F4F43B0-14F5-4C91-B98C-AEB8A5421258} - {B30AF83C-5B94-47D3-90E4-1A637E6AB9C5} = {93E5303C-66C1-4BF6-8823-6CBA9C3751BE} - {F30D2F25-88CE-416B-B958-0F07668EB3B7} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} - {9674CB4B-0314-435E-8214-2A07CDD7A030} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} - {B7A0CBE1-ECCE-415F-AADA-C08B516BFF1F} = {91A212DC-1D96-43DD-B1A0-153ACB6980D5} - {9321AA8B-9138-4419-923C-86A1D0349277} = {8AFE509C-0DD0-4C85-8BEA-24FB599293D7} - {3C02FD3D-76DE-4B2E-BF19-2D79535DDCF3} = {9A4C3BCD-1DF9-4B7F-9BBD-D9FDFBDD3CF2} + {C24C6373-0DB4-4ECC-A902-692267EBD922} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} + {785E774A-9D67-4EAB-AB71-D60EBE8144DD} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} + {FB841C40-3211-443F-AC95-CD5796CF4FB3} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {54A8A393-BE7E-4403-8F48-EC42060F128E} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} + {3B8AF190-2B4D-4647-877C-2FDE681C2ED3} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} + {0F151C31-117F-438E-A5B5-9EE1D669BE27} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} + {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} = {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} + {180DB5AB-AF6F-49EF-B5C6-6566B8B88711} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} + {921409C4-23D6-4D92-B62F-2908142749C9} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} + {DFA4EC74-777A-4929-96C6-C29463B22D58} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} + {893D69AA-5483-44AE-AD8C-E9C6E6F0276A} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} + {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} + {AC293685-7094-4325-8D5B-4ED252C62942} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {698C287C-20C9-45E1-A6B2-15141C74C3E2} = {A93CC4E0-F468-49C7-8429-9384A124BB2D} + {2F11BC84-BA3C-43A0-BAB8-FC65E6E4566C} = {A93CC4E0-F468-49C7-8429-9384A124BB2D} + {B7C0B348-3E2C-40BA-850D-BDA93FEA6B44} = {A93CC4E0-F468-49C7-8429-9384A124BB2D} + {022A9AE7-CA3B-4DD1-934B-FBBF680312B1} = {B7C0B348-3E2C-40BA-850D-BDA93FEA6B44} + {4C3B217C-32D6-4995-BC05-08BC7490FF89} = {A93CC4E0-F468-49C7-8429-9384A124BB2D} + {CCADF7E9-2D5E-433C-8376-1C4F32BEDED4} = {698C287C-20C9-45E1-A6B2-15141C74C3E2} + {37DC7DFC-2806-4E22-9A9B-9A690AD95091} = {2F11BC84-BA3C-43A0-BAB8-FC65E6E4566C} + {E9266D91-AF86-49E5-A4CA-08721FE01DB0} = {022A9AE7-CA3B-4DD1-934B-FBBF680312B1} + {21A094AE-3A26-4E37-B76E-C213C84BEAFC} = {B7C0B348-3E2C-40BA-850D-BDA93FEA6B44} + {B8858D6E-FEDA-45CA-A895-4FCDD45C4856} = {4C3B217C-32D6-4995-BC05-08BC7490FF89} + {5CB8F10A-96A8-4854-A990-13818B034F24} = {A93CC4E0-F468-49C7-8429-9384A124BB2D} + {B63EB0FB-B23B-43EB-A700-46F2F9D9CB39} = {4C3B217C-32D6-4995-BC05-08BC7490FF89} + {84793402-7ED4-4390-B7C7-87C11475B342} = {698C287C-20C9-45E1-A6B2-15141C74C3E2} + {AAD9189B-299E-4492-9B3E-4073D177E5FF} = {2F11BC84-BA3C-43A0-BAB8-FC65E6E4566C} + {8D1218F9-926A-4EAB-8C53-1A83A8AAFF8F} = {B7C0B348-3E2C-40BA-850D-BDA93FEA6B44} + {551319E1-1415-449B-A9B7-B49AA182D6C4} = {022A9AE7-CA3B-4DD1-934B-FBBF680312B1} + {F24D2732-A777-4246-A5E2-633FB552B999} = {2F11BC84-BA3C-43A0-BAB8-FC65E6E4566C} + {A1CE8588-9FE3-4ADB-AEB9-E34680091A78} = {A93CC4E0-F468-49C7-8429-9384A124BB2D} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} diff --git a/src/api/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs b/src/api/auth/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs rename to src/api/auth/FinancialHub.Auth.Application/Configurations/TokenServiceSettings.cs diff --git a/src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs b/src/api/auth/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs rename to src/api/auth/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Auth.cs diff --git a/src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs b/src/api/auth/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs rename to src/api/auth/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.Docs.cs diff --git a/src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs b/src/api/auth/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs rename to src/api/auth/FinancialHub.Auth.Application/Extensions/IServiceCollectionExtensions.cs diff --git a/src/api/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj b/src/api/auth/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj similarity index 92% rename from src/api/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj rename to src/api/auth/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj index 05fa4af..968318d 100644 --- a/src/api/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj +++ b/src/api/auth/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj @@ -22,6 +22,7 @@ + diff --git a/src/api/FinancialHub.Auth.Application/Services/SigninService.cs b/src/api/auth/FinancialHub.Auth.Application/Services/SigninService.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Services/SigninService.cs rename to src/api/auth/FinancialHub.Auth.Application/Services/SigninService.cs diff --git a/src/api/FinancialHub.Auth.Application/Services/SignupService.cs b/src/api/auth/FinancialHub.Auth.Application/Services/SignupService.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Services/SignupService.cs rename to src/api/auth/FinancialHub.Auth.Application/Services/SignupService.cs diff --git a/src/api/FinancialHub.Auth.Application/Services/TokenService.cs b/src/api/auth/FinancialHub.Auth.Application/Services/TokenService.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Services/TokenService.cs rename to src/api/auth/FinancialHub.Auth.Application/Services/TokenService.cs diff --git a/src/api/FinancialHub.Auth.Application/Services/UserService.cs b/src/api/auth/FinancialHub.Auth.Application/Services/UserService.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Services/UserService.cs rename to src/api/auth/FinancialHub.Auth.Application/Services/UserService.cs diff --git a/src/api/FinancialHub.Auth.Application/Usings.cs b/src/api/auth/FinancialHub.Auth.Application/Usings.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Usings.cs rename to src/api/auth/FinancialHub.Auth.Application/Usings.cs diff --git a/src/api/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs b/src/api/auth/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs rename to src/api/auth/FinancialHub.Auth.Application/Validators/Rules/ValidatorRulesExtensions.cs diff --git a/src/api/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs b/src/api/auth/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs rename to src/api/auth/FinancialHub.Auth.Application/Validators/SigninModelValidator.cs diff --git a/src/api/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs b/src/api/auth/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs rename to src/api/auth/FinancialHub.Auth.Application/Validators/SignupModelValidator.cs diff --git a/src/api/FinancialHub.Auth.Application/Validators/UserValidator.cs b/src/api/auth/FinancialHub.Auth.Application/Validators/UserValidator.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application/Validators/UserValidator.cs rename to src/api/auth/FinancialHub.Auth.Application/Validators/UserValidator.cs diff --git a/src/api/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs b/src/api/auth/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs rename to src/api/auth/FinancialHub.Auth.Domain/Entities/CredentialEntity.cs diff --git a/src/api/FinancialHub.Auth.Domain/Entities/UserEntity.cs b/src/api/auth/FinancialHub.Auth.Domain/Entities/UserEntity.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Entities/UserEntity.cs rename to src/api/auth/FinancialHub.Auth.Domain/Entities/UserEntity.cs diff --git a/src/api/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj b/src/api/auth/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj similarity index 71% rename from src/api/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj rename to src/api/auth/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj index 9f8d43d..f378188 100644 --- a/src/api/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj +++ b/src/api/auth/FinancialHub.Auth.Domain/FinancialHub.Auth.Domain.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Helpers/IPasswordHelper.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Providers/ICredentialProvider.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Providers/ISigninProvider.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Providers/ISignupProvider.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Providers/IUserProvider.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Repositories/ICredentialRepository.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Repositories/IUserRepository.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Resources/IErrorMessageProvider.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Services/ISigninService.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Services/ISignupService.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Services/ITokenService.cs diff --git a/src/api/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs b/src/api/auth/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs rename to src/api/auth/FinancialHub.Auth.Domain/Interfaces/Services/IUserService.cs diff --git a/src/api/FinancialHub.Auth.Domain/Models/CredentialModel.cs b/src/api/auth/FinancialHub.Auth.Domain/Models/CredentialModel.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Models/CredentialModel.cs rename to src/api/auth/FinancialHub.Auth.Domain/Models/CredentialModel.cs diff --git a/src/api/FinancialHub.Auth.Domain/Models/SigninModel.cs b/src/api/auth/FinancialHub.Auth.Domain/Models/SigninModel.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Models/SigninModel.cs rename to src/api/auth/FinancialHub.Auth.Domain/Models/SigninModel.cs diff --git a/src/api/FinancialHub.Auth.Domain/Models/SignupModel.cs b/src/api/auth/FinancialHub.Auth.Domain/Models/SignupModel.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Models/SignupModel.cs rename to src/api/auth/FinancialHub.Auth.Domain/Models/SignupModel.cs diff --git a/src/api/FinancialHub.Auth.Domain/Models/TokenModel.cs b/src/api/auth/FinancialHub.Auth.Domain/Models/TokenModel.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Models/TokenModel.cs rename to src/api/auth/FinancialHub.Auth.Domain/Models/TokenModel.cs diff --git a/src/api/FinancialHub.Auth.Domain/Models/UserModel.cs b/src/api/auth/FinancialHub.Auth.Domain/Models/UserModel.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Models/UserModel.cs rename to src/api/auth/FinancialHub.Auth.Domain/Models/UserModel.cs diff --git a/src/api/FinancialHub.Auth.Domain/Usings.cs b/src/api/auth/FinancialHub.Auth.Domain/Usings.cs similarity index 100% rename from src/api/FinancialHub.Auth.Domain/Usings.cs rename to src/api/auth/FinancialHub.Auth.Domain/Usings.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Contexts/FinancialHubAuthContext.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Extensions/IServiceCollectionExtensions.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj b/src/api/auth/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj rename to src/api/auth/FinancialHub.Auth.Infra.Data/FinancialHub.Auth.Infra.Data.csproj diff --git a/src/api/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Mapping/UserCredentialEntityMapping.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Mapping/UserEntityMapping.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.Designer.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/20230503220050_Adds_User_Table.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.Designer.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/20230615215715_Add_Credential_Table.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Migrations/FinancialHubAuthContextModelSnapshot.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Repositories/CredentialRepository.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Repositories/UserRepository.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data/Usings.cs b/src/api/auth/FinancialHub.Auth.Infra.Data/Usings.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data/Usings.cs rename to src/api/auth/FinancialHub.Auth.Infra.Data/Usings.cs diff --git a/src/api/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs b/src/api/auth/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs rename to src/api/auth/FinancialHub.Auth.Infra/Extensions/IServiceCollectionExtensions.cs diff --git a/src/api/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj b/src/api/auth/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj similarity index 100% rename from src/api/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj rename to src/api/auth/FinancialHub.Auth.Infra/FinancialHub.Auth.Infra.csproj diff --git a/src/api/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs b/src/api/auth/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs rename to src/api/auth/FinancialHub.Auth.Infra/Helpers/PasswordHelper.cs diff --git a/src/api/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs b/src/api/auth/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs rename to src/api/auth/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthCredentialProfile.cs diff --git a/src/api/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs b/src/api/auth/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs rename to src/api/auth/FinancialHub.Auth.Infra/Mappers/FinancialHubAuthProfile.cs diff --git a/src/api/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs b/src/api/auth/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs rename to src/api/auth/FinancialHub.Auth.Infra/Providers/CredentialProvider.cs diff --git a/src/api/FinancialHub.Auth.Infra/Providers/SigninProvider.cs b/src/api/auth/FinancialHub.Auth.Infra/Providers/SigninProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra/Providers/SigninProvider.cs rename to src/api/auth/FinancialHub.Auth.Infra/Providers/SigninProvider.cs diff --git a/src/api/FinancialHub.Auth.Infra/Providers/SignupProvider.cs b/src/api/auth/FinancialHub.Auth.Infra/Providers/SignupProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra/Providers/SignupProvider.cs rename to src/api/auth/FinancialHub.Auth.Infra/Providers/SignupProvider.cs diff --git a/src/api/FinancialHub.Auth.Infra/Providers/UserProvider.cs b/src/api/auth/FinancialHub.Auth.Infra/Providers/UserProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra/Providers/UserProvider.cs rename to src/api/auth/FinancialHub.Auth.Infra/Providers/UserProvider.cs diff --git a/src/api/FinancialHub.Auth.Infra/Usings.cs b/src/api/auth/FinancialHub.Auth.Infra/Usings.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra/Usings.cs rename to src/api/auth/FinancialHub.Auth.Infra/Usings.cs diff --git a/src/api/FinancialHub.Auth.Presentation/.editorconfig b/src/api/auth/FinancialHub.Auth.Presentation/.editorconfig similarity index 100% rename from src/api/FinancialHub.Auth.Presentation/.editorconfig rename to src/api/auth/FinancialHub.Auth.Presentation/.editorconfig diff --git a/src/api/FinancialHub.Auth.Presentation/Controllers/SigninController.cs b/src/api/auth/FinancialHub.Auth.Presentation/Controllers/SigninController.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation/Controllers/SigninController.cs rename to src/api/auth/FinancialHub.Auth.Presentation/Controllers/SigninController.cs diff --git a/src/api/FinancialHub.Auth.Presentation/Controllers/SignupController.cs b/src/api/auth/FinancialHub.Auth.Presentation/Controllers/SignupController.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation/Controllers/SignupController.cs rename to src/api/auth/FinancialHub.Auth.Presentation/Controllers/SignupController.cs diff --git a/src/api/FinancialHub.Auth.Presentation/Controllers/UsersController.cs b/src/api/auth/FinancialHub.Auth.Presentation/Controllers/UsersController.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation/Controllers/UsersController.cs rename to src/api/auth/FinancialHub.Auth.Presentation/Controllers/UsersController.cs diff --git a/src/api/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs b/src/api/auth/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs rename to src/api/auth/FinancialHub.Auth.Presentation/Extensions/IServiceCollectionExtensions.cs diff --git a/src/api/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs b/src/api/auth/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs rename to src/api/auth/FinancialHub.Auth.Presentation/Extensions/SwaggerExtensions.cs diff --git a/src/api/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj b/src/api/auth/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj similarity index 100% rename from src/api/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj rename to src/api/auth/FinancialHub.Auth.Presentation/FinancialHub.Auth.Presentation.csproj diff --git a/src/api/FinancialHub.Auth.Presentation/Usings.cs b/src/api/auth/FinancialHub.Auth.Presentation/Usings.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation/Usings.cs rename to src/api/auth/FinancialHub.Auth.Presentation/Usings.cs diff --git a/src/api/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs b/src/api/auth/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs rename to src/api/auth/FinancialHub.Auth.Resources/Extensions/IServiceCollectionExtensions.cs diff --git a/src/api/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj b/src/api/auth/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj similarity index 100% rename from src/api/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj rename to src/api/auth/FinancialHub.Auth.Resources/FinancialHub.Auth.Resources.csproj diff --git a/src/api/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs b/src/api/auth/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs similarity index 100% rename from src/api/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs rename to src/api/auth/FinancialHub.Auth.Resources/Providers/ErrorMessageProvider.cs diff --git a/src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs b/src/api/auth/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs similarity index 100% rename from src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs rename to src/api/auth/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.Designer.cs diff --git a/src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx b/src/api/auth/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx similarity index 100% rename from src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx rename to src/api/auth/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.pt-BR.resx diff --git a/src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx b/src/api/auth/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx similarity index 100% rename from src/api/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx rename to src/api/auth/FinancialHub.Auth.Resources/Resources/Errors/ErrorMessages.resx diff --git a/src/api/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj b/src/api/auth/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj similarity index 100% rename from src/api/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj rename to src/api/auth/FinancialHub.Auth.WebApi/FinancialHub.Auth.WebApi.csproj diff --git a/src/api/FinancialHub.Auth.WebApi/Program.cs b/src/api/auth/FinancialHub.Auth.WebApi/Program.cs similarity index 100% rename from src/api/FinancialHub.Auth.WebApi/Program.cs rename to src/api/auth/FinancialHub.Auth.WebApi/Program.cs diff --git a/src/api/FinancialHub.Auth.WebApi/Properties/launchSettings.json b/src/api/auth/FinancialHub.Auth.WebApi/Properties/launchSettings.json similarity index 100% rename from src/api/FinancialHub.Auth.WebApi/Properties/launchSettings.json rename to src/api/auth/FinancialHub.Auth.WebApi/Properties/launchSettings.json diff --git a/src/api/FinancialHub.Auth.WebApi/appsettings.Development.json b/src/api/auth/FinancialHub.Auth.WebApi/appsettings.Development.json similarity index 100% rename from src/api/FinancialHub.Auth.WebApi/appsettings.Development.json rename to src/api/auth/FinancialHub.Auth.WebApi/appsettings.Development.json diff --git a/src/api/FinancialHub.Auth.WebApi/appsettings.Testing.json b/src/api/auth/FinancialHub.Auth.WebApi/appsettings.Testing.json similarity index 100% rename from src/api/FinancialHub.Auth.WebApi/appsettings.Testing.json rename to src/api/auth/FinancialHub.Auth.WebApi/appsettings.Testing.json diff --git a/src/api/FinancialHub.Auth.WebApi/appsettings.json b/src/api/auth/FinancialHub.Auth.WebApi/appsettings.json similarity index 100% rename from src/api/FinancialHub.Auth.WebApi/appsettings.json rename to src/api/auth/FinancialHub.Auth.WebApi/appsettings.json diff --git a/src/api/auth/FinancialHub.Auth.sln b/src/api/auth/FinancialHub.Auth.sln new file mode 100644 index 0000000..c18dcb9 --- /dev/null +++ b/src/api/auth/FinancialHub.Auth.sln @@ -0,0 +1,145 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31912.275 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{B00013E6-DB9F-415A-B542-6D32DA258EB2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Auth", "Auth", "{BEE32E30-21CF-489B-B208-3D053E4966A8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{FB841C40-3211-443F-AC95-CD5796CF4FB3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{0F151C31-117F-438E-A5B5-9EE1D669BE27}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{3B96E644-4E1A-4C2F-8F3C-E4843C921B92}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{15C0C14F-DA06-46BB-A8B0-4BA5D6372777}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common.Tests", "..\..\..\tests\common\FinancialHub.Common.Tests\FinancialHub.Common.Tests.csproj", "{EDB047FA-1B3C-4060-8327-EDA6EB3D201B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application.Tests", "..\..\..\tests\auth\FinancialHub.Auth.Application.Tests\FinancialHub.Auth.Application.Tests.csproj", "{B66A8B1B-4123-4FC1-A0A8-FAA0A9BAC7A9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Common.Tests", "..\..\..\tests\auth\FinancialHub.Auth.Common.Tests\FinancialHub.Auth.Common.Tests.csproj", "{C9329ED1-DACA-4DD2-9BB6-75C7083FF8B5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Data.Tests", "..\..\..\tests\auth\FinancialHub.Auth.Infra.Data.Tests\FinancialHub.Auth.Infra.Data.Tests.csproj", "{5F63B3FF-A42B-496E-A3C7-DC4EB601750F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Tests", "..\..\..\tests\auth\FinancialHub.Auth.Infra.Tests\FinancialHub.Auth.Infra.Tests.csproj", "{EF50702A-4F37-4467-9B23-CD52BE6E56BE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Presentation.Tests", "..\..\..\tests\auth\FinancialHub.Auth.Presentation.Tests\FinancialHub.Auth.Presentation.Tests.csproj", "{F93EE692-EFCD-4729-A98F-C832D927D914}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.IntegrationTests", "..\..\..\tests\auth\FinancialHub.Auth.IntegrationTests\FinancialHub.Auth.IntegrationTests.csproj", "{F87C32B0-8B5C-410C-9A07-2FF4C83CC657}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common", "..\common\FinancialHub.Common\FinancialHub.Common.csproj", "{7483C5F0-3F6F-4C2F-ADA0-B013CB9A502D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Application", "FinancialHub.Auth.Application\FinancialHub.Auth.Application.csproj", "{0084DFA0-A5BD-4F53-9652-C3EE50F0703D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Domain", "FinancialHub.Auth.Domain\FinancialHub.Auth.Domain.csproj", "{DFFD9C3A-E127-43C3-93C1-C8221E9E4B21}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra.Data", "FinancialHub.Auth.Infra.Data\FinancialHub.Auth.Infra.Data.csproj", "{FA8CC50A-AAD4-4F22-9FCD-A2151AC040A0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Infra", "FinancialHub.Auth.Infra\FinancialHub.Auth.Infra.csproj", "{0329A416-4B7E-4969-9844-32E45258F3D2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Presentation", "FinancialHub.Auth.Presentation\FinancialHub.Auth.Presentation.csproj", "{E7F77ED2-25CE-4F7D-8909-122076EAF5D2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.WebApi", "FinancialHub.Auth.WebApi\FinancialHub.Auth.WebApi.csproj", "{1D72A253-61A8-4AE4-9DD3-C3DA350CAAB7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Auth.Resources", "FinancialHub.Auth.Resources\FinancialHub.Auth.Resources.csproj", "{338427B6-0CD8-452B-BA8C-87AADB1F1757}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EDB047FA-1B3C-4060-8327-EDA6EB3D201B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EDB047FA-1B3C-4060-8327-EDA6EB3D201B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EDB047FA-1B3C-4060-8327-EDA6EB3D201B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EDB047FA-1B3C-4060-8327-EDA6EB3D201B}.Release|Any CPU.Build.0 = Release|Any CPU + {B66A8B1B-4123-4FC1-A0A8-FAA0A9BAC7A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B66A8B1B-4123-4FC1-A0A8-FAA0A9BAC7A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B66A8B1B-4123-4FC1-A0A8-FAA0A9BAC7A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B66A8B1B-4123-4FC1-A0A8-FAA0A9BAC7A9}.Release|Any CPU.Build.0 = Release|Any CPU + {C9329ED1-DACA-4DD2-9BB6-75C7083FF8B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9329ED1-DACA-4DD2-9BB6-75C7083FF8B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9329ED1-DACA-4DD2-9BB6-75C7083FF8B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9329ED1-DACA-4DD2-9BB6-75C7083FF8B5}.Release|Any CPU.Build.0 = Release|Any CPU + {5F63B3FF-A42B-496E-A3C7-DC4EB601750F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F63B3FF-A42B-496E-A3C7-DC4EB601750F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F63B3FF-A42B-496E-A3C7-DC4EB601750F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F63B3FF-A42B-496E-A3C7-DC4EB601750F}.Release|Any CPU.Build.0 = Release|Any CPU + {EF50702A-4F37-4467-9B23-CD52BE6E56BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF50702A-4F37-4467-9B23-CD52BE6E56BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF50702A-4F37-4467-9B23-CD52BE6E56BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF50702A-4F37-4467-9B23-CD52BE6E56BE}.Release|Any CPU.Build.0 = Release|Any CPU + {F93EE692-EFCD-4729-A98F-C832D927D914}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F93EE692-EFCD-4729-A98F-C832D927D914}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F93EE692-EFCD-4729-A98F-C832D927D914}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F93EE692-EFCD-4729-A98F-C832D927D914}.Release|Any CPU.Build.0 = Release|Any CPU + {F87C32B0-8B5C-410C-9A07-2FF4C83CC657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F87C32B0-8B5C-410C-9A07-2FF4C83CC657}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F87C32B0-8B5C-410C-9A07-2FF4C83CC657}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F87C32B0-8B5C-410C-9A07-2FF4C83CC657}.Release|Any CPU.Build.0 = Release|Any CPU + {7483C5F0-3F6F-4C2F-ADA0-B013CB9A502D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7483C5F0-3F6F-4C2F-ADA0-B013CB9A502D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7483C5F0-3F6F-4C2F-ADA0-B013CB9A502D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7483C5F0-3F6F-4C2F-ADA0-B013CB9A502D}.Release|Any CPU.Build.0 = Release|Any CPU + {0084DFA0-A5BD-4F53-9652-C3EE50F0703D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0084DFA0-A5BD-4F53-9652-C3EE50F0703D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0084DFA0-A5BD-4F53-9652-C3EE50F0703D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0084DFA0-A5BD-4F53-9652-C3EE50F0703D}.Release|Any CPU.Build.0 = Release|Any CPU + {DFFD9C3A-E127-43C3-93C1-C8221E9E4B21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFFD9C3A-E127-43C3-93C1-C8221E9E4B21}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFFD9C3A-E127-43C3-93C1-C8221E9E4B21}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFFD9C3A-E127-43C3-93C1-C8221E9E4B21}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8CC50A-AAD4-4F22-9FCD-A2151AC040A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8CC50A-AAD4-4F22-9FCD-A2151AC040A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8CC50A-AAD4-4F22-9FCD-A2151AC040A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8CC50A-AAD4-4F22-9FCD-A2151AC040A0}.Release|Any CPU.Build.0 = Release|Any CPU + {0329A416-4B7E-4969-9844-32E45258F3D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0329A416-4B7E-4969-9844-32E45258F3D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0329A416-4B7E-4969-9844-32E45258F3D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0329A416-4B7E-4969-9844-32E45258F3D2}.Release|Any CPU.Build.0 = Release|Any CPU + {E7F77ED2-25CE-4F7D-8909-122076EAF5D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E7F77ED2-25CE-4F7D-8909-122076EAF5D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E7F77ED2-25CE-4F7D-8909-122076EAF5D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E7F77ED2-25CE-4F7D-8909-122076EAF5D2}.Release|Any CPU.Build.0 = Release|Any CPU + {1D72A253-61A8-4AE4-9DD3-C3DA350CAAB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D72A253-61A8-4AE4-9DD3-C3DA350CAAB7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D72A253-61A8-4AE4-9DD3-C3DA350CAAB7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D72A253-61A8-4AE4-9DD3-C3DA350CAAB7}.Release|Any CPU.Build.0 = Release|Any CPU + {338427B6-0CD8-452B-BA8C-87AADB1F1757}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {338427B6-0CD8-452B-BA8C-87AADB1F1757}.Debug|Any CPU.Build.0 = Debug|Any CPU + {338427B6-0CD8-452B-BA8C-87AADB1F1757}.Release|Any CPU.ActiveCfg = Release|Any CPU + {338427B6-0CD8-452B-BA8C-87AADB1F1757}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {FB841C40-3211-443F-AC95-CD5796CF4FB3} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {0F151C31-117F-438E-A5B5-9EE1D669BE27} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} = {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} + {EDB047FA-1B3C-4060-8327-EDA6EB3D201B} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} + {B66A8B1B-4123-4FC1-A0A8-FAA0A9BAC7A9} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} + {C9329ED1-DACA-4DD2-9BB6-75C7083FF8B5} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} + {5F63B3FF-A42B-496E-A3C7-DC4EB601750F} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} + {EF50702A-4F37-4467-9B23-CD52BE6E56BE} = {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} + {F93EE692-EFCD-4729-A98F-C832D927D914} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} + {F87C32B0-8B5C-410C-9A07-2FF4C83CC657} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {7483C5F0-3F6F-4C2F-ADA0-B013CB9A502D} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} + {0084DFA0-A5BD-4F53-9652-C3EE50F0703D} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} + {DFFD9C3A-E127-43C3-93C1-C8221E9E4B21} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} + {FA8CC50A-AAD4-4F22-9FCD-A2151AC040A0} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} + {0329A416-4B7E-4969-9844-32E45258F3D2} = {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} + {E7F77ED2-25CE-4F7D-8909-122076EAF5D2} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} + {1D72A253-61A8-4AE4-9DD3-C3DA350CAAB7} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {338427B6-0CD8-452B-BA8C-87AADB1F1757} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} + EndGlobalSection +EndGlobal diff --git a/src/api/FinancialHub.Common/Entities/BaseEntity.cs b/src/api/common/FinancialHub.Common/Entities/BaseEntity.cs similarity index 100% rename from src/api/FinancialHub.Common/Entities/BaseEntity.cs rename to src/api/common/FinancialHub.Common/Entities/BaseEntity.cs diff --git a/src/api/FinancialHub.Common/FinancialHub.Common.csproj b/src/api/common/FinancialHub.Common/FinancialHub.Common.csproj similarity index 100% rename from src/api/FinancialHub.Common/FinancialHub.Common.csproj rename to src/api/common/FinancialHub.Common/FinancialHub.Common.csproj diff --git a/src/api/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs b/src/api/common/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs similarity index 100% rename from src/api/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs rename to src/api/common/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs diff --git a/src/api/FinancialHub.Common/Models/BaseModel.cs b/src/api/common/FinancialHub.Common/Models/BaseModel.cs similarity index 100% rename from src/api/FinancialHub.Common/Models/BaseModel.cs rename to src/api/common/FinancialHub.Common/Models/BaseModel.cs diff --git a/src/api/FinancialHub.Common/Responses/Errors/BaseErrorResponse.cs b/src/api/common/FinancialHub.Common/Responses/Errors/BaseErrorResponse.cs similarity index 100% rename from src/api/FinancialHub.Common/Responses/Errors/BaseErrorResponse.cs rename to src/api/common/FinancialHub.Common/Responses/Errors/BaseErrorResponse.cs diff --git a/src/api/FinancialHub.Common/Responses/Errors/NotFoundErrorResponse.cs b/src/api/common/FinancialHub.Common/Responses/Errors/NotFoundErrorResponse.cs similarity index 100% rename from src/api/FinancialHub.Common/Responses/Errors/NotFoundErrorResponse.cs rename to src/api/common/FinancialHub.Common/Responses/Errors/NotFoundErrorResponse.cs diff --git a/src/api/FinancialHub.Common/Responses/Errors/ValidationErrorResponse.cs b/src/api/common/FinancialHub.Common/Responses/Errors/ValidationErrorResponse.cs similarity index 100% rename from src/api/FinancialHub.Common/Responses/Errors/ValidationErrorResponse.cs rename to src/api/common/FinancialHub.Common/Responses/Errors/ValidationErrorResponse.cs diff --git a/src/api/FinancialHub.Common/Responses/Errors/ValidationsErrorResponse.cs b/src/api/common/FinancialHub.Common/Responses/Errors/ValidationsErrorResponse.cs similarity index 100% rename from src/api/FinancialHub.Common/Responses/Errors/ValidationsErrorResponse.cs rename to src/api/common/FinancialHub.Common/Responses/Errors/ValidationsErrorResponse.cs diff --git a/src/api/FinancialHub.Common/Responses/Success/BaseResponse.cs b/src/api/common/FinancialHub.Common/Responses/Success/BaseResponse.cs similarity index 100% rename from src/api/FinancialHub.Common/Responses/Success/BaseResponse.cs rename to src/api/common/FinancialHub.Common/Responses/Success/BaseResponse.cs diff --git a/src/api/FinancialHub.Common/Responses/Success/ItemResponse.cs b/src/api/common/FinancialHub.Common/Responses/Success/ItemResponse.cs similarity index 100% rename from src/api/FinancialHub.Common/Responses/Success/ItemResponse.cs rename to src/api/common/FinancialHub.Common/Responses/Success/ItemResponse.cs diff --git a/src/api/FinancialHub.Common/Responses/Success/ListResponse.cs b/src/api/common/FinancialHub.Common/Responses/Success/ListResponse.cs similarity index 100% rename from src/api/FinancialHub.Common/Responses/Success/ListResponse.cs rename to src/api/common/FinancialHub.Common/Responses/Success/ListResponse.cs diff --git a/src/api/FinancialHub.Common/Responses/Success/PaginatedListResponse.cs b/src/api/common/FinancialHub.Common/Responses/Success/PaginatedListResponse.cs similarity index 100% rename from src/api/FinancialHub.Common/Responses/Success/PaginatedListResponse.cs rename to src/api/common/FinancialHub.Common/Responses/Success/PaginatedListResponse.cs diff --git a/src/api/FinancialHub.Common/Responses/Success/SaveResponse.cs b/src/api/common/FinancialHub.Common/Responses/Success/SaveResponse.cs similarity index 100% rename from src/api/FinancialHub.Common/Responses/Success/SaveResponse.cs rename to src/api/common/FinancialHub.Common/Responses/Success/SaveResponse.cs diff --git a/src/api/FinancialHub.Common/Results/Errors/InvalidDataError.cs b/src/api/common/FinancialHub.Common/Results/Errors/InvalidDataError.cs similarity index 100% rename from src/api/FinancialHub.Common/Results/Errors/InvalidDataError.cs rename to src/api/common/FinancialHub.Common/Results/Errors/InvalidDataError.cs diff --git a/src/api/FinancialHub.Common/Results/Errors/NotFoundError.cs b/src/api/common/FinancialHub.Common/Results/Errors/NotFoundError.cs similarity index 100% rename from src/api/FinancialHub.Common/Results/Errors/NotFoundError.cs rename to src/api/common/FinancialHub.Common/Results/Errors/NotFoundError.cs diff --git a/src/api/FinancialHub.Common/Results/Errors/ServiceError.cs b/src/api/common/FinancialHub.Common/Results/Errors/ServiceError.cs similarity index 100% rename from src/api/FinancialHub.Common/Results/Errors/ServiceError.cs rename to src/api/common/FinancialHub.Common/Results/Errors/ServiceError.cs diff --git a/src/api/FinancialHub.Common/Results/ServiceResult.cs b/src/api/common/FinancialHub.Common/Results/ServiceResult.cs similarity index 100% rename from src/api/FinancialHub.Common/Results/ServiceResult.cs rename to src/api/common/FinancialHub.Common/Results/ServiceResult.cs diff --git a/src/api/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/core/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs rename to src/api/core/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs diff --git a/src/api/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj b/src/api/core/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj similarity index 92% rename from src/api/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj rename to src/api/core/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj index eceb265..f74aec1 100644 --- a/src/api/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj +++ b/src/api/core/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj @@ -13,7 +13,6 @@ - diff --git a/src/api/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs b/src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs rename to src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs diff --git a/src/api/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs b/src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs rename to src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs diff --git a/src/api/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs b/src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs rename to src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs diff --git a/src/api/FinancialHub.Core.Application/Resources/ErrorMessages.resx b/src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.resx similarity index 100% rename from src/api/FinancialHub.Core.Application/Resources/ErrorMessages.resx rename to src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.resx diff --git a/src/api/FinancialHub.Core.Application/Services/AccountBalanceService.cs b/src/api/core/FinancialHub.Core.Application/Services/AccountBalanceService.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Services/AccountBalanceService.cs rename to src/api/core/FinancialHub.Core.Application/Services/AccountBalanceService.cs diff --git a/src/api/FinancialHub.Core.Application/Services/AccountsService.cs b/src/api/core/FinancialHub.Core.Application/Services/AccountsService.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Services/AccountsService.cs rename to src/api/core/FinancialHub.Core.Application/Services/AccountsService.cs diff --git a/src/api/FinancialHub.Core.Application/Services/BalancesService.cs b/src/api/core/FinancialHub.Core.Application/Services/BalancesService.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Services/BalancesService.cs rename to src/api/core/FinancialHub.Core.Application/Services/BalancesService.cs diff --git a/src/api/FinancialHub.Core.Application/Services/CategoriesService.cs b/src/api/core/FinancialHub.Core.Application/Services/CategoriesService.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Services/CategoriesService.cs rename to src/api/core/FinancialHub.Core.Application/Services/CategoriesService.cs diff --git a/src/api/FinancialHub.Core.Application/Services/TransactionBalanceService.cs b/src/api/core/FinancialHub.Core.Application/Services/TransactionBalanceService.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Services/TransactionBalanceService.cs rename to src/api/core/FinancialHub.Core.Application/Services/TransactionBalanceService.cs diff --git a/src/api/FinancialHub.Core.Application/Services/TransactionsService.cs b/src/api/core/FinancialHub.Core.Application/Services/TransactionsService.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Services/TransactionsService.cs rename to src/api/core/FinancialHub.Core.Application/Services/TransactionsService.cs diff --git a/src/api/FinancialHub.Core.Application/Usings.cs b/src/api/core/FinancialHub.Core.Application/Usings.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Usings.cs rename to src/api/core/FinancialHub.Core.Application/Usings.cs diff --git a/src/api/FinancialHub.Core.Application/Validators/AccountValidator.cs b/src/api/core/FinancialHub.Core.Application/Validators/AccountValidator.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Validators/AccountValidator.cs rename to src/api/core/FinancialHub.Core.Application/Validators/AccountValidator.cs diff --git a/src/api/FinancialHub.Core.Application/Validators/BalanceValidator.cs b/src/api/core/FinancialHub.Core.Application/Validators/BalanceValidator.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Validators/BalanceValidator.cs rename to src/api/core/FinancialHub.Core.Application/Validators/BalanceValidator.cs diff --git a/src/api/FinancialHub.Core.Application/Validators/CategoryValidator.cs b/src/api/core/FinancialHub.Core.Application/Validators/CategoryValidator.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Validators/CategoryValidator.cs rename to src/api/core/FinancialHub.Core.Application/Validators/CategoryValidator.cs diff --git a/src/api/FinancialHub.Core.Application/Validators/TransactionValidator.cs b/src/api/core/FinancialHub.Core.Application/Validators/TransactionValidator.cs similarity index 100% rename from src/api/FinancialHub.Core.Application/Validators/TransactionValidator.cs rename to src/api/core/FinancialHub.Core.Application/Validators/TransactionValidator.cs diff --git a/src/api/FinancialHub.Core.Domain/Entities/AccountEntity.cs b/src/api/core/FinancialHub.Core.Domain/Entities/AccountEntity.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Entities/AccountEntity.cs rename to src/api/core/FinancialHub.Core.Domain/Entities/AccountEntity.cs diff --git a/src/api/FinancialHub.Core.Domain/Entities/BalanceEntity.cs b/src/api/core/FinancialHub.Core.Domain/Entities/BalanceEntity.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Entities/BalanceEntity.cs rename to src/api/core/FinancialHub.Core.Domain/Entities/BalanceEntity.cs diff --git a/src/api/FinancialHub.Core.Domain/Entities/CategoryEntity.cs b/src/api/core/FinancialHub.Core.Domain/Entities/CategoryEntity.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Entities/CategoryEntity.cs rename to src/api/core/FinancialHub.Core.Domain/Entities/CategoryEntity.cs diff --git a/src/api/FinancialHub.Core.Domain/Entities/TransactionEntity.cs b/src/api/core/FinancialHub.Core.Domain/Entities/TransactionEntity.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Entities/TransactionEntity.cs rename to src/api/core/FinancialHub.Core.Domain/Entities/TransactionEntity.cs diff --git a/src/api/FinancialHub.Core.Domain/Enums/TransactionStatus.cs b/src/api/core/FinancialHub.Core.Domain/Enums/TransactionStatus.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Enums/TransactionStatus.cs rename to src/api/core/FinancialHub.Core.Domain/Enums/TransactionStatus.cs diff --git a/src/api/FinancialHub.Core.Domain/Enums/TransactionType.cs b/src/api/core/FinancialHub.Core.Domain/Enums/TransactionType.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Enums/TransactionType.cs rename to src/api/core/FinancialHub.Core.Domain/Enums/TransactionType.cs diff --git a/src/api/FinancialHub.Core.Domain/Filters/TransactionFilter.cs b/src/api/core/FinancialHub.Core.Domain/Filters/TransactionFilter.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Filters/TransactionFilter.cs rename to src/api/core/FinancialHub.Core.Domain/Filters/TransactionFilter.cs diff --git a/src/api/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj b/src/api/core/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj similarity index 89% rename from src/api/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj rename to src/api/core/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj index 336bd9f..dcc132e 100644 --- a/src/api/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj +++ b/src/api/core/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs diff --git a/src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs rename to src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs diff --git a/src/api/FinancialHub.Core.Domain/Models/AccountModel.cs b/src/api/core/FinancialHub.Core.Domain/Models/AccountModel.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Models/AccountModel.cs rename to src/api/core/FinancialHub.Core.Domain/Models/AccountModel.cs diff --git a/src/api/FinancialHub.Core.Domain/Models/BalanceModel.cs b/src/api/core/FinancialHub.Core.Domain/Models/BalanceModel.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Models/BalanceModel.cs rename to src/api/core/FinancialHub.Core.Domain/Models/BalanceModel.cs diff --git a/src/api/FinancialHub.Core.Domain/Models/CategoryModel.cs b/src/api/core/FinancialHub.Core.Domain/Models/CategoryModel.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Models/CategoryModel.cs rename to src/api/core/FinancialHub.Core.Domain/Models/CategoryModel.cs diff --git a/src/api/FinancialHub.Core.Domain/Models/TransactionModel.cs b/src/api/core/FinancialHub.Core.Domain/Models/TransactionModel.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Models/TransactionModel.cs rename to src/api/core/FinancialHub.Core.Domain/Models/TransactionModel.cs diff --git a/src/api/FinancialHub.Core.Domain/Queries/TransactionQuery.cs b/src/api/core/FinancialHub.Core.Domain/Queries/TransactionQuery.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Queries/TransactionQuery.cs rename to src/api/core/FinancialHub.Core.Domain/Queries/TransactionQuery.cs diff --git a/src/api/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs b/src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs rename to src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs diff --git a/src/api/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx b/src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx similarity index 100% rename from src/api/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx rename to src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx diff --git a/src/api/FinancialHub.Core.Domain/Usings.cs b/src/api/core/FinancialHub.Core.Domain/Usings.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain/Usings.cs rename to src/api/core/FinancialHub.Core.Domain/Usings.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs b/src/api/core/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/core/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj b/src/api/core/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj rename to src/api/core/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj diff --git a/src/api/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs b/src/api/core/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs b/src/api/core/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs b/src/api/core/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs b/src/api/core/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs diff --git a/src/api/FinancialHub.Core.Infra.Data/Usings.cs b/src/api/core/FinancialHub.Core.Infra.Data/Usings.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data/Usings.cs rename to src/api/core/FinancialHub.Core.Infra.Data/Usings.cs diff --git a/src/api/FinancialHub.Core.WebApi/Controllers/AccountsController.cs b/src/api/core/FinancialHub.Core.WebApi/Controllers/AccountsController.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Controllers/AccountsController.cs rename to src/api/core/FinancialHub.Core.WebApi/Controllers/AccountsController.cs diff --git a/src/api/FinancialHub.Core.WebApi/Controllers/BalancesController.cs b/src/api/core/FinancialHub.Core.WebApi/Controllers/BalancesController.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Controllers/BalancesController.cs rename to src/api/core/FinancialHub.Core.WebApi/Controllers/BalancesController.cs diff --git a/src/api/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs b/src/api/core/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs rename to src/api/core/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs diff --git a/src/api/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs b/src/api/core/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs rename to src/api/core/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs diff --git a/src/api/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/core/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs rename to src/api/core/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs diff --git a/src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj b/src/api/core/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj similarity index 94% rename from src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj rename to src/api/core/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj index f16d719..eeb3583 100644 --- a/src/api/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj +++ b/src/api/core/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj @@ -4,10 +4,6 @@ net6.0 - - - - diff --git a/src/api/FinancialHub.Core.WebApi/Program.cs b/src/api/core/FinancialHub.Core.WebApi/Program.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Program.cs rename to src/api/core/FinancialHub.Core.WebApi/Program.cs diff --git a/src/api/FinancialHub.Core.WebApi/Properties/launchSettings.json b/src/api/core/FinancialHub.Core.WebApi/Properties/launchSettings.json similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Properties/launchSettings.json rename to src/api/core/FinancialHub.Core.WebApi/Properties/launchSettings.json diff --git a/src/api/FinancialHub.Core.WebApi/Startup.cs b/src/api/core/FinancialHub.Core.WebApi/Startup.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Startup.cs rename to src/api/core/FinancialHub.Core.WebApi/Startup.cs diff --git a/src/api/FinancialHub.Core.WebApi/Usings.cs b/src/api/core/FinancialHub.Core.WebApi/Usings.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi/Usings.cs rename to src/api/core/FinancialHub.Core.WebApi/Usings.cs diff --git a/src/api/FinancialHub.Core.WebApi/appsettings.Development.json b/src/api/core/FinancialHub.Core.WebApi/appsettings.Development.json similarity index 100% rename from src/api/FinancialHub.Core.WebApi/appsettings.Development.json rename to src/api/core/FinancialHub.Core.WebApi/appsettings.Development.json diff --git a/src/api/FinancialHub.Core.WebApi/appsettings.Testing.json b/src/api/core/FinancialHub.Core.WebApi/appsettings.Testing.json similarity index 100% rename from src/api/FinancialHub.Core.WebApi/appsettings.Testing.json rename to src/api/core/FinancialHub.Core.WebApi/appsettings.Testing.json diff --git a/src/api/FinancialHub.Core.WebApi/appsettings.json b/src/api/core/FinancialHub.Core.WebApi/appsettings.json similarity index 100% rename from src/api/FinancialHub.Core.WebApi/appsettings.json rename to src/api/core/FinancialHub.Core.WebApi/appsettings.json diff --git a/src/api/core/FinancialHub.Core.sln b/src/api/core/FinancialHub.Core.sln new file mode 100644 index 0000000..8681ce1 --- /dev/null +++ b/src/api/core/FinancialHub.Core.sln @@ -0,0 +1,119 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31912.275 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{B00013E6-DB9F-415A-B542-6D32DA258EB2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{BEE32E30-21CF-489B-B208-3D053E4966A8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{FB841C40-3211-443F-AC95-CD5796CF4FB3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{0F151C31-117F-438E-A5B5-9EE1D669BE27}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{3B96E644-4E1A-4C2F-8F3C-E4843C921B92}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{15C0C14F-DA06-46BB-A8B0-4BA5D6372777}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application", "FinancialHub.Core.Application\FinancialHub.Core.Application.csproj", "{962A60D1-2373-4086-9DF5-7C77C1335D7E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain", "FinancialHub.Core.Domain\FinancialHub.Core.Domain.csproj", "{D17C1B75-3E9D-4AE7-BAB1-336C00321846}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data", "FinancialHub.Core.Infra.Data\FinancialHub.Core.Infra.Data.csproj", "{632D8DE1-86E8-4668-B093-420CA2933B66}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi", "FinancialHub.Core.WebApi\FinancialHub.Core.WebApi.csproj", "{1766B5F3-D24F-41C2-AA2F-836E74464549}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common", "..\common\FinancialHub.Common\FinancialHub.Common.csproj", "{27BAF3E9-E2C2-4897-9398-96F4B3B9656E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common.Tests", "..\..\..\tests\common\FinancialHub.Common.Tests\FinancialHub.Common.Tests.csproj", "{67482F4E-58F2-46CC-A5EB-55C5077BFF46}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application.Tests", "..\..\..\tests\core\FinancialHub.Core.Application.Tests\FinancialHub.Core.Application.Tests.csproj", "{CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain.Tests", "..\..\..\tests\core\FinancialHub.Core.Domain.Tests\FinancialHub.Core.Domain.Tests.csproj", "{10742A75-DA97-47E8-A13E-E17C8DF56828}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data.Tests", "..\..\..\tests\core\FinancialHub.Core.Infra.Data.Tests\FinancialHub.Core.Infra.Data.Tests.csproj", "{C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi.Tests", "..\..\..\tests\core\FinancialHub.Core.WebApi.Tests\FinancialHub.Core.WebApi.Tests.csproj", "{61A63487-07EF-4713-A0F8-D5F3B1AD3033}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.IntegrationTests", "..\..\..\tests\core\FinancialHub.Core.IntegrationTests\FinancialHub.Core.IntegrationTests.csproj", "{E7839395-1741-4DE8-8CC3-6D7491786A25}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A6BF8521-37BF-4275-901D-9CF454CFFADC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {962A60D1-2373-4086-9DF5-7C77C1335D7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {962A60D1-2373-4086-9DF5-7C77C1335D7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {962A60D1-2373-4086-9DF5-7C77C1335D7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {962A60D1-2373-4086-9DF5-7C77C1335D7E}.Release|Any CPU.Build.0 = Release|Any CPU + {D17C1B75-3E9D-4AE7-BAB1-336C00321846}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D17C1B75-3E9D-4AE7-BAB1-336C00321846}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D17C1B75-3E9D-4AE7-BAB1-336C00321846}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D17C1B75-3E9D-4AE7-BAB1-336C00321846}.Release|Any CPU.Build.0 = Release|Any CPU + {632D8DE1-86E8-4668-B093-420CA2933B66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {632D8DE1-86E8-4668-B093-420CA2933B66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {632D8DE1-86E8-4668-B093-420CA2933B66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {632D8DE1-86E8-4668-B093-420CA2933B66}.Release|Any CPU.Build.0 = Release|Any CPU + {1766B5F3-D24F-41C2-AA2F-836E74464549}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1766B5F3-D24F-41C2-AA2F-836E74464549}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1766B5F3-D24F-41C2-AA2F-836E74464549}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1766B5F3-D24F-41C2-AA2F-836E74464549}.Release|Any CPU.Build.0 = Release|Any CPU + {27BAF3E9-E2C2-4897-9398-96F4B3B9656E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27BAF3E9-E2C2-4897-9398-96F4B3B9656E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27BAF3E9-E2C2-4897-9398-96F4B3B9656E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27BAF3E9-E2C2-4897-9398-96F4B3B9656E}.Release|Any CPU.Build.0 = Release|Any CPU + {67482F4E-58F2-46CC-A5EB-55C5077BFF46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67482F4E-58F2-46CC-A5EB-55C5077BFF46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67482F4E-58F2-46CC-A5EB-55C5077BFF46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67482F4E-58F2-46CC-A5EB-55C5077BFF46}.Release|Any CPU.Build.0 = Release|Any CPU + {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}.Release|Any CPU.Build.0 = Release|Any CPU + {10742A75-DA97-47E8-A13E-E17C8DF56828}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10742A75-DA97-47E8-A13E-E17C8DF56828}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10742A75-DA97-47E8-A13E-E17C8DF56828}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10742A75-DA97-47E8-A13E-E17C8DF56828}.Release|Any CPU.Build.0 = Release|Any CPU + {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}.Release|Any CPU.Build.0 = Release|Any CPU + {61A63487-07EF-4713-A0F8-D5F3B1AD3033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61A63487-07EF-4713-A0F8-D5F3B1AD3033}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61A63487-07EF-4713-A0F8-D5F3B1AD3033}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61A63487-07EF-4713-A0F8-D5F3B1AD3033}.Release|Any CPU.Build.0 = Release|Any CPU + {E7839395-1741-4DE8-8CC3-6D7491786A25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E7839395-1741-4DE8-8CC3-6D7491786A25}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E7839395-1741-4DE8-8CC3-6D7491786A25}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E7839395-1741-4DE8-8CC3-6D7491786A25}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {FB841C40-3211-443F-AC95-CD5796CF4FB3} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {0F151C31-117F-438E-A5B5-9EE1D669BE27} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} = {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} + {962A60D1-2373-4086-9DF5-7C77C1335D7E} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} + {D17C1B75-3E9D-4AE7-BAB1-336C00321846} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} + {632D8DE1-86E8-4668-B093-420CA2933B66} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} + {1766B5F3-D24F-41C2-AA2F-836E74464549} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} + {27BAF3E9-E2C2-4897-9398-96F4B3B9656E} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} + {67482F4E-58F2-46CC-A5EB-55C5077BFF46} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} + {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} + {10742A75-DA97-47E8-A13E-E17C8DF56828} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} + {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} + {61A63487-07EF-4713-A0F8-D5F3B1AD3033} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} + {E7839395-1741-4DE8-8CC3-6D7491786A25} = {BEE32E30-21CF-489B-B208-3D053E4966A8} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} + EndGlobalSection +EndGlobal diff --git a/tests/.editorconfig b/tests/.editorconfig new file mode 100644 index 0000000..a560d2e --- /dev/null +++ b/tests/.editorconfig @@ -0,0 +1,233 @@ +# Remova a linha abaixo se quiser herdar as configurações do .editorconfig de diretórios superiores +root = true + +# Arquivos C# +[*.cs] + +#### Opções Principais do EditorConfig #### + +# Recuo e espaçamento +indent_size = 4 +indent_style = space +tab_width = 4 + +# Preferências de nova linha +end_of_line = crlf +insert_final_newline = false + +#### Convenções de codificação .NET #### + +# Organizar Usos +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# Preferências +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Preferências de tipos BCL contra palavras-chave do idioma +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Preferências de parênteses +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Preferências de modificador +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Preferências de nível de expressão +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Preferências de campo +dotnet_style_readonly_field = true + +# Preferências de parâmetro +dotnet_code_quality_unused_parameters = all + +# Preferências de supressão +dotnet_remove_unnecessary_suppression_exclusions = none + +# Preferências de nova linha +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### Convenções de Codificação em C# #### + +# preferências de var +csharp_style_var_elsewhere = false +csharp_style_var_for_built_in_types = false +csharp_style_var_when_type_is_apparent = false + +# Membros aptos para expressão +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = false +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = false +csharp_style_expression_bodied_methods = false +csharp_style_expression_bodied_operators = false +csharp_style_expression_bodied_properties = true + +# Preferências de correspondência de padrões +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Preferências de verificação nula +csharp_style_conditional_delegate_call = true + +# Preferências de modificador +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true +csharp_style_prefer_readonly_struct_member = true + +# Preferências do bloco de código +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true +csharp_style_namespace_declarations = block_scoped +csharp_style_prefer_method_group_conversion = true +csharp_style_prefer_primary_constructors = true +csharp_style_prefer_top_level_statements = true + +# Preferências de nível de expressão +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# Preferências da diretiva 'using' +csharp_using_directive_placement = outside_namespace + +# Preferências de nova linha +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### Regras de Formatação de C# #### + +# Preferências de nova linha +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Preferências de recuo +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Preferências de espaço +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Preferências de quebra de linha +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Estilos de nomenclatura #### + +# Regras de nomenclatura + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Especificações de símbolo + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Estilos de nomenclatura + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +# CS8618: O campo não anulável precisa conter um valor não nulo ao sair do construtor. Considere declará-lo como anulável. +dotnet_diagnostic.CS8618.severity = none diff --git a/src/api/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj b/tests/auth/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj similarity index 65% rename from src/api/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj rename to tests/auth/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj index b54f157..32fd9da 100644 --- a/src/api/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj +++ b/tests/auth/FinancialHub.Auth.Application.Tests/FinancialHub.Auth.Application.Tests.csproj @@ -19,10 +19,8 @@ - - - - + + diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Token/TokenServiceTests.generate.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.create.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs diff --git a/tests/auth/FinancialHub.Auth.Application.Tests/Usings.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Usings.cs new file mode 100644 index 0000000..42a2b57 --- /dev/null +++ b/tests/auth/FinancialHub.Auth.Application.Tests/Usings.cs @@ -0,0 +1,10 @@ +global using NUnit.Framework; +global using Moq; + +global using FinancialHub.Auth.Domain.Models; + +global using FinancialHub.Auth.Common.Tests.Assertions; + +global using FinancialHub.Auth.Common.Tests.Builders.Models; + +[assembly: Category("Unit")] \ No newline at end of file diff --git a/src/api/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Validators/SigninModelValidatorTests.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Validators/SignupModelValidatorTests.cs diff --git a/src/api/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs rename to tests/auth/FinancialHub.Auth.Application.Tests/Validators/UserValidatorTests.cs diff --git a/src/api/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Assertions/EntityAssert.cs similarity index 95% rename from src/api/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Assertions/EntityAssert.cs index 6c7fcbc..8ce3667 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Assertions/EntityAssert.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Assertions/EntityAssert.cs @@ -1,6 +1,4 @@ -using NUnit.Framework; - -namespace FinancialHub.Auth.Tests.Common.Assertions +namespace FinancialHub.Auth.Common.Tests.Assertions { public static class EntityAssert { diff --git a/src/api/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Assertions/ModelAssert.cs similarity index 97% rename from src/api/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Assertions/ModelAssert.cs index 93e6ffa..799b7b8 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Assertions/ModelAssert.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Assertions/ModelAssert.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Tests.Common.Assertions +namespace FinancialHub.Auth.Common.Tests.Assertions { public static class ModelAssert { diff --git a/src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Entities/UserCredentialEntityBuilder.cs similarity index 95% rename from src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Builders/Entities/UserCredentialEntityBuilder.cs index df372a6..49c0cfc 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserCredentialEntityBuilder.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Entities/UserCredentialEntityBuilder.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Tests.Common.Builders.Entities +namespace FinancialHub.Auth.Common.Tests.Builders.Entities { public class UserCredentialEntityBuilder : BaseEntityBuilder { diff --git a/src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Entities/UserEntityBuilder.cs similarity index 94% rename from src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Builders/Entities/UserEntityBuilder.cs index d37d127..bb042f2 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Builders/Entities/UserEntityBuilder.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Entities/UserEntityBuilder.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Tests.Common.Builders.Entities +namespace FinancialHub.Auth.Common.Tests.Builders.Entities { public class UserEntityBuilder : BaseEntityBuilder { diff --git a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/SigninModelBuilder.cs similarity index 90% rename from src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/SigninModelBuilder.cs index c6c9977..ec31716 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SigninModelBuilder.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/SigninModelBuilder.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Tests.Common.Builders.Models +namespace FinancialHub.Auth.Common.Tests.Builders.Models { public class SigninModelBuilder : AutoFaker { diff --git a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/SignupModelBuilder.cs similarity index 96% rename from src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/SignupModelBuilder.cs index 1e84360..18f0da2 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/SignupModelBuilder.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/SignupModelBuilder.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Tests.Common.Builders.Models +namespace FinancialHub.Auth.Common.Tests.Builders.Models { public class SignupModelBuilder : AutoFaker { diff --git a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/TokenModelBuilder.cs similarity index 81% rename from src/api/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/TokenModelBuilder.cs index 77cb39b..6ab364e 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/TokenModelBuilder.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/TokenModelBuilder.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Tests.Common.Builders.Models +namespace FinancialHub.Auth.Common.Tests.Builders.Models { public class TokenModelBuilder : AutoFaker { diff --git a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/UserCredentialModelBuilder.cs similarity index 92% rename from src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/UserCredentialModelBuilder.cs index fe52bcb..c679282 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserCredentialModelBuilder.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/UserCredentialModelBuilder.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Tests.Common.Builders.Models +namespace FinancialHub.Auth.Common.Tests.Builders.Models { public class UserCredentialModelBuilder : AutoFaker { diff --git a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/UserModelBuilder.cs similarity index 94% rename from src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/UserModelBuilder.cs index 8bc022b..6246635 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/Builders/Models/UserModelBuilder.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Builders/Models/UserModelBuilder.cs @@ -1,4 +1,4 @@ -namespace FinancialHub.Auth.Tests.Common.Builders.Models +namespace FinancialHub.Auth.Common.Tests.Builders.Models { public class UserModelBuilder : BaseModelBuilder { diff --git a/src/api/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj b/tests/auth/FinancialHub.Auth.Common.Tests/FinancialHub.Auth.Common.Tests.csproj similarity index 63% rename from src/api/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj rename to tests/auth/FinancialHub.Auth.Common.Tests/FinancialHub.Auth.Common.Tests.csproj index 24c14b3..261d7c9 100644 --- a/src/api/FinancialHub.Auth.Tests.Common/FinancialHub.Auth.Tests.Common.csproj +++ b/tests/auth/FinancialHub.Auth.Common.Tests/FinancialHub.Auth.Common.Tests.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/src/api/FinancialHub.Auth.Tests.Common/Usings.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Usings.cs similarity index 100% rename from src/api/FinancialHub.Auth.Tests.Common/Usings.cs rename to tests/auth/FinancialHub.Auth.Common.Tests/Usings.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Assertions/DbContextAssert.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj similarity index 72% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj index 4baebae..8ddad64 100644 --- a/src/api/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj +++ b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/FinancialHub.Auth.Infra.Data.Tests.csproj @@ -19,9 +19,8 @@ - - - + + diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Fixtures/DatabaseFixture.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.create.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Credentials/CredentialRepositoryTests.get.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.create.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.get.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Repositories/Users/UserRepositoryTests.update.cs diff --git a/src/api/FinancialHub.Auth.Infra.Data.Tests/Usings.cs b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Usings.cs similarity index 58% rename from src/api/FinancialHub.Auth.Infra.Data.Tests/Usings.cs rename to tests/auth/FinancialHub.Auth.Infra.Data.Tests/Usings.cs index 5340753..0740575 100644 --- a/src/api/FinancialHub.Auth.Infra.Data.Tests/Usings.cs +++ b/tests/auth/FinancialHub.Auth.Infra.Data.Tests/Usings.cs @@ -3,12 +3,14 @@ global using FinancialHub.Common.Entities; -global using FinancialHub.Auth.Tests.Common.Assertions; -global using FinancialHub.Auth.Tests.Common.Builders.Entities; +global using FinancialHub.Auth.Common.Tests.Assertions; +global using FinancialHub.Auth.Common.Tests.Builders.Entities; global using FinancialHub.Auth.Domain.Interfaces.Repositories; global using FinancialHub.Auth.Infra.Data.Repositories; global using FinancialHub.Auth.Infra.Data.Tests.Fixtures; -global using FinancialHub.Auth.Infra.Data.Tests.Assertions; \ No newline at end of file +global using FinancialHub.Auth.Infra.Data.Tests.Assertions; + +[assembly: Category("Unit")] \ No newline at end of file diff --git a/src/api/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj b/tests/auth/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj similarity index 76% rename from src/api/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj rename to tests/auth/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj index de2e2f0..a638c99 100644 --- a/src/api/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj +++ b/tests/auth/FinancialHub.Auth.Infra.Tests/FinancialHub.Auth.Infra.Tests.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.create.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Credentials/CredentialProviderTests.get.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Signin/SigninProviderTests.get_accounts.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.create_account.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Signup/SignupProviderTests.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.create.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.get.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs similarity index 100% rename from src/api/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Providers/Users/UserProviderTests.update.cs diff --git a/src/api/FinancialHub.Auth.Infra.Tests/Usings.cs b/tests/auth/FinancialHub.Auth.Infra.Tests/Usings.cs similarity index 63% rename from src/api/FinancialHub.Auth.Infra.Tests/Usings.cs rename to tests/auth/FinancialHub.Auth.Infra.Tests/Usings.cs index e7a0dd6..2d251d0 100644 --- a/src/api/FinancialHub.Auth.Infra.Tests/Usings.cs +++ b/tests/auth/FinancialHub.Auth.Infra.Tests/Usings.cs @@ -3,8 +3,8 @@ global using Moq; global using NUnit.Framework; -global using FinancialHub.Auth.Tests.Common.Assertions; -global using FinancialHub.Auth.Tests.Common.Builders.Models; +global using FinancialHub.Auth.Common.Tests.Assertions; +global using FinancialHub.Auth.Common.Tests.Builders.Models; global using FinancialHub.Auth.Domain.Models; global using FinancialHub.Auth.Domain.Entities; @@ -13,4 +13,6 @@ global using FinancialHub.Auth.Domain.Interfaces.Repositories; global using FinancialHub.Auth.Infra.Mappers; -global using FinancialHub.Auth.Infra.Providers; \ No newline at end of file +global using FinancialHub.Auth.Infra.Providers; + +[assembly: Category("Unit")] \ No newline at end of file diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Base/BaseControllerTests.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Extensions/HttpClientExtensions.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Extensions/HttpContentExtensions.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Extensions/Utils/HttpClientExtensionsParameters.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj b/tests/auth/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj similarity index 70% rename from src/api/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj rename to tests/auth/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj index b263a00..6460faf 100644 --- a/src/api/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj +++ b/tests/auth/FinancialHub.Auth.IntegrationTests/FinancialHub.Auth.IntegrationTests.csproj @@ -18,9 +18,8 @@ - - - + + diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.auth.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs similarity index 100% rename from src/api/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Setup/FinancialHubAuthApiFixture.database.cs diff --git a/src/api/FinancialHub.Auth.IntegrationTests/Usings.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Usings.cs similarity index 66% rename from src/api/FinancialHub.Auth.IntegrationTests/Usings.cs rename to tests/auth/FinancialHub.Auth.IntegrationTests/Usings.cs index 901f182..a4aed74 100644 --- a/src/api/FinancialHub.Auth.IntegrationTests/Usings.cs +++ b/tests/auth/FinancialHub.Auth.IntegrationTests/Usings.cs @@ -12,6 +12,8 @@ global using FinancialHub.Auth.Domain.Entities; global using FinancialHub.Auth.Domain.Models; -global using FinancialHub.Auth.Tests.Common.Assertions; -global using FinancialHub.Auth.Tests.Common.Builders.Entities; -global using FinancialHub.Auth.Tests.Common.Builders.Models; \ No newline at end of file +global using FinancialHub.Auth.Common.Tests.Assertions; +global using FinancialHub.Auth.Common.Tests.Builders.Entities; +global using FinancialHub.Auth.Common.Tests.Builders.Models; + +[assembly: Category("Integration")] \ No newline at end of file diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Asserts/ControllerResponseAssert.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Signin/SigninControllerTests.get.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.create.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Signup/SignupControllerTests.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.create.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.get.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs similarity index 100% rename from src/api/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Controllers/Users/UsersControllerTests.update.cs diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj b/tests/auth/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj similarity index 74% rename from src/api/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj rename to tests/auth/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj index 65b6027..eda2eac 100644 --- a/src/api/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj +++ b/tests/auth/FinancialHub.Auth.Presentation.Tests/FinancialHub.Auth.Presentation.Tests.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/src/api/FinancialHub.Auth.Presentation.Tests/Usings.cs b/tests/auth/FinancialHub.Auth.Presentation.Tests/Usings.cs similarity index 65% rename from src/api/FinancialHub.Auth.Presentation.Tests/Usings.cs rename to tests/auth/FinancialHub.Auth.Presentation.Tests/Usings.cs index b1df58a..01e062c 100644 --- a/src/api/FinancialHub.Auth.Presentation.Tests/Usings.cs +++ b/tests/auth/FinancialHub.Auth.Presentation.Tests/Usings.cs @@ -3,8 +3,8 @@ global using Moq; global using NUnit.Framework; -global using FinancialHub.Auth.Tests.Common.Assertions; -global using FinancialHub.Auth.Tests.Common.Builders.Models; +global using FinancialHub.Auth.Common.Tests.Assertions; +global using FinancialHub.Auth.Common.Tests.Builders.Models; global using FinancialHub.Common.Responses.Success; global using FinancialHub.Common.Responses.Errors; @@ -16,4 +16,6 @@ global using FinancialHub.Auth.Domain.Interfaces.Services; -global using FinancialHub.Auth.Presentation.Controllers; \ No newline at end of file +global using FinancialHub.Auth.Presentation.Controllers; + +[assembly: Category("Unit")] \ No newline at end of file diff --git a/src/api/FinancialHub.Common.Tests/Assertions/Responses/BaseResponseAssert.cs b/tests/common/FinancialHub.Common.Tests/Assertions/Responses/BaseResponseAssert.cs similarity index 100% rename from src/api/FinancialHub.Common.Tests/Assertions/Responses/BaseResponseAssert.cs rename to tests/common/FinancialHub.Common.Tests/Assertions/Responses/BaseResponseAssert.cs diff --git a/src/api/FinancialHub.Common.Tests/Builders/Entities/BaseEntityBuilder.cs b/tests/common/FinancialHub.Common.Tests/Builders/Entities/BaseEntityBuilder.cs similarity index 100% rename from src/api/FinancialHub.Common.Tests/Builders/Entities/BaseEntityBuilder.cs rename to tests/common/FinancialHub.Common.Tests/Builders/Entities/BaseEntityBuilder.cs diff --git a/src/api/FinancialHub.Common.Tests/Builders/Models/BaseModelBuilder.cs b/tests/common/FinancialHub.Common.Tests/Builders/Models/BaseModelBuilder.cs similarity index 100% rename from src/api/FinancialHub.Common.Tests/Builders/Models/BaseModelBuilder.cs rename to tests/common/FinancialHub.Common.Tests/Builders/Models/BaseModelBuilder.cs diff --git a/src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj b/tests/common/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj similarity index 78% rename from src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj rename to tests/common/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj index d3b696a..ada9f94 100644 --- a/src/api/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj +++ b/tests/common/FinancialHub.Common.Tests/FinancialHub.Common.Tests.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/api/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj b/tests/core/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj similarity index 76% rename from src/api/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj rename to tests/core/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj index a4b802a..6e4abe6 100644 --- a/src/api/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj +++ b/tests/core/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj @@ -17,7 +17,8 @@ - + + diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs rename to tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Usings.cs b/tests/core/FinancialHub.Core.Application.Tests/Usings.cs similarity index 86% rename from src/api/FinancialHub.Core.Application.Tests/Usings.cs rename to tests/core/FinancialHub.Core.Application.Tests/Usings.cs index b9aa359..8fdc623 100644 --- a/src/api/FinancialHub.Core.Application.Tests/Usings.cs +++ b/tests/core/FinancialHub.Core.Application.Tests/Usings.cs @@ -16,4 +16,6 @@ // Domain Project namespaces global using FinancialHub.Core.Domain.Models; -global using FinancialHub.Core.Domain.Entities; \ No newline at end of file +global using FinancialHub.Core.Domain.Entities; + +[assembly: Category("Unit")] \ No newline at end of file diff --git a/src/api/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs diff --git a/src/api/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs rename to tests/core/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj b/tests/core/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj similarity index 79% rename from src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj rename to tests/core/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj index 2b38092..bd6b070 100644 --- a/src/api/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj +++ b/tests/core/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/src/api/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs b/tests/core/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs diff --git a/src/api/FinancialHub.Core.Domain.Tests/Usings.cs b/tests/core/FinancialHub.Core.Domain.Tests/Usings.cs similarity index 81% rename from src/api/FinancialHub.Core.Domain.Tests/Usings.cs rename to tests/core/FinancialHub.Core.Domain.Tests/Usings.cs index 75ac6bf..8cb909d 100644 --- a/src/api/FinancialHub.Core.Domain.Tests/Usings.cs +++ b/tests/core/FinancialHub.Core.Domain.Tests/Usings.cs @@ -10,4 +10,6 @@ // Domain Models namespaces global using FinancialHub.Core.Domain.Entities; -global using FinancialHub.Core.Domain.Models; \ No newline at end of file +global using FinancialHub.Core.Domain.Models; + +[assembly: Category("Unit")] \ No newline at end of file diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj b/tests/core/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj similarity index 87% rename from src/api/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj rename to tests/core/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj index 4757581..40a3373 100644 --- a/src/api/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj +++ b/tests/core/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj @@ -18,8 +18,8 @@ + - diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs similarity index 82% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs index 7b7b10c..35bf6e1 100644 --- a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs +++ b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs @@ -1,4 +1,5 @@ -using FinancialHub.Core.Infra.Data.Repositories; +using FinancialHub.Core.Domain.Interfaces.Repositories; +using FinancialHub.Core.Infra.Data.Repositories; using FinancialHub.Core.Infra.Data.Tests.Repositories.Base; namespace FinancialHub.Core.Infra.Data.Tests.Repositories @@ -6,7 +7,7 @@ namespace FinancialHub.Core.Infra.Data.Tests.Repositories public partial class BalancesRepositoryTests : BaseRepositoryTests { public TransactionEntityBuilder transactionBuilder; - public BalancesRepository balanceRepository; + public IBalancesRepository balanceRepository; public BalanceEntityBuilder balanceBuilder; [SetUp] diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs diff --git a/src/api/FinancialHub.Core.Infra.Data.Tests/Usings.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Usings.cs similarity index 79% rename from src/api/FinancialHub.Core.Infra.Data.Tests/Usings.cs rename to tests/core/FinancialHub.Core.Infra.Data.Tests/Usings.cs index 57502ee..f5b6e09 100644 --- a/src/api/FinancialHub.Core.Infra.Data.Tests/Usings.cs +++ b/tests/core/FinancialHub.Core.Infra.Data.Tests/Usings.cs @@ -10,4 +10,6 @@ global using FinancialHub.Core.Domain.Tests.Builders.Entities; // Domain Project namespaces -global using FinancialHub.Core.Domain.Entities; \ No newline at end of file +global using FinancialHub.Core.Domain.Entities; + +[assembly: Category("Unit")] \ No newline at end of file diff --git a/src/api/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs rename to tests/core/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs diff --git a/src/api/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs rename to tests/core/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs diff --git a/src/api/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs rename to tests/core/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs diff --git a/src/api/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs rename to tests/core/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs diff --git a/src/api/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs rename to tests/core/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs diff --git a/src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs b/tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs similarity index 100% rename from src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs rename to tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs diff --git a/src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs b/tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs similarity index 100% rename from src/api/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs rename to tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs diff --git a/src/api/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj b/tests/core/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj similarity index 65% rename from src/api/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj rename to tests/core/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj index 1bf1b11..0cdb39f 100644 --- a/src/api/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj +++ b/tests/core/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj @@ -7,21 +7,32 @@ false + - - - - + + + + + + + + + + - - + + + + + + diff --git a/src/api/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs b/tests/core/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs similarity index 100% rename from src/api/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs rename to tests/core/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs diff --git a/src/api/FinancialHub.Core.IntegrationTests/Usings.cs b/tests/core/FinancialHub.Core.IntegrationTests/Usings.cs similarity index 92% rename from src/api/FinancialHub.Core.IntegrationTests/Usings.cs rename to tests/core/FinancialHub.Core.IntegrationTests/Usings.cs index c6b3bf8..5a764cd 100644 --- a/src/api/FinancialHub.Core.IntegrationTests/Usings.cs +++ b/tests/core/FinancialHub.Core.IntegrationTests/Usings.cs @@ -34,4 +34,6 @@ // Integration Tests SetUp namespaces global using FinancialHub.Core.IntegrationTests.Base; global using FinancialHub.Core.IntegrationTests.Setup; -global using FinancialHub.Core.IntegrationTests.Extensions; \ No newline at end of file +global using FinancialHub.Core.IntegrationTests.Extensions; + +[assembly: Category("Integration")] \ No newline at end of file diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs similarity index 100% rename from src/api/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs diff --git a/src/api/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj b/tests/core/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj similarity index 85% rename from src/api/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj rename to tests/core/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj index e452af9..2213eb9 100644 --- a/src/api/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj +++ b/tests/core/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj @@ -16,8 +16,8 @@ + - diff --git a/src/api/FinancialHub.Core.WebApi.Tests/Usings.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Usings.cs similarity index 88% rename from src/api/FinancialHub.Core.WebApi.Tests/Usings.cs rename to tests/core/FinancialHub.Core.WebApi.Tests/Usings.cs index 3dbec46..eeb88a2 100644 --- a/src/api/FinancialHub.Core.WebApi.Tests/Usings.cs +++ b/tests/core/FinancialHub.Core.WebApi.Tests/Usings.cs @@ -22,4 +22,6 @@ // Common Response namespaces global using FinancialHub.Common.Responses.Errors; -global using FinancialHub.Common.Responses.Success; \ No newline at end of file +global using FinancialHub.Common.Responses.Success; + +[assembly: Category("Unit")] \ No newline at end of file From f1aa509b5fc7fb393b62cca354f76841abc3e7ca Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Wed, 6 Sep 2023 17:31:42 -0300 Subject: [PATCH 23/30] Release v0.5.4 * Adds filter test to code coverage * Fix CS8632 code smells in Core project * Fix all null-forgiving * Fix Collection Has.Count code smell --- .github/actions/run-tests/action.yml | 2 +- .github/workflows/coverage_report.yml | 1 + src/api/.editorconfig | 5 +++++ .../Interfaces/Repositories/IBaseRepository.cs | 2 +- .../Repositories/BaseRepository.cs | 4 +++- tests/.editorconfig | 5 +++++ .../Services/Signin/SigninServiceTests.get.cs | 2 +- .../Services/Signup/SignupServiceTests.create.cs | 4 ++-- .../Services/Users/UserServiceTests.get.cs | 2 +- .../Services/Users/UserServiceTests.update.cs | 2 +- .../Assertions/ModelAssert.cs | 13 +++++++------ .../Controllers/SigninControllerTests.cs | 2 +- .../Controllers/SignupControllerTests.cs | 2 +- .../Controllers/UsersControllerTests.cs | 4 ++-- .../Accounts/AccountsServiceTests.update.cs | 9 ++++++--- .../Balances/BalancesControllerTests.create.cs | 4 ++-- .../Balances/BalancesControllerTests.update.cs | 4 ++-- .../Categories/CategoriesControllerTests.create.cs | 4 ++-- .../Categories/CategoriesControllerTests.update.cs | 4 ++-- .../TransactionsControllerTests.create.cs | 4 ++-- .../TransactionsControllerTests.update.cs | 4 ++-- 21 files changed, 50 insertions(+), 33 deletions(-) diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index d872f8b..a89755d 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -16,7 +16,7 @@ runs: shell: bash continue-on-error: true run: dotnet test ${{ inputs.project-dir }} - --filter TestCategory=${{ inputs.category }} + --filter "TestCategory=${{ inputs.category }}" --logger:"trx;logfilename=Results.xml" --configuration release \ No newline at end of file diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 5e6a056..976a841 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -80,6 +80,7 @@ jobs: run: dotnet test --collect:"XPlat Code Coverage;Format=opencover" --results-directory TestResults/ + --filter "TestCategory=Unit|TestCategory=Integration" --configuration Release - name: Send Coverage Report diff --git a/src/api/.editorconfig b/src/api/.editorconfig index a560d2e..5e94c65 100644 --- a/src/api/.editorconfig +++ b/src/api/.editorconfig @@ -229,5 +229,10 @@ dotnet_naming_style.begins_with_i.required_suffix = dotnet_naming_style.begins_with_i.word_separator = dotnet_naming_style.begins_with_i.capitalization = pascal_case +# Code Smells + # CS8618: O campo não anulável precisa conter um valor não nulo ao sair do construtor. Considere declará-lo como anulável. dotnet_diagnostic.CS8618.severity = none + +# CS8632: A anotação para tipos de referência anuláveis deve ser usada apenas em código em um contexto de anotações '#nullable'. +dotnet_diagnostic.CS8632.severity = none diff --git a/src/api/common/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs b/src/api/common/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs index 407410d..4cbc2c7 100644 --- a/src/api/common/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs +++ b/src/api/common/FinancialHub.Common/Interfaces/Repositories/IBaseRepository.cs @@ -36,6 +36,6 @@ public interface IBaseRepository /// Gets an entity by id /// /// Id of the choosen entity - Task GetByIdAsync(Guid id); + Task GetByIdAsync(Guid id); } } diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs index a096ac4..218d808 100644 --- a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs +++ b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs @@ -57,12 +57,14 @@ public virtual async Task> GetAllAsync() return await context.Set().ToListAsync(); } +#pragma warning disable CS1998 // O método assíncrono não possui operadores 'await' e será executado de forma síncrona public virtual async Task> GetAsync(Func predicate) { return context.Set().Where(predicate).ToList(); } +#pragma warning restore CS1998 // O método assíncrono não possui operadores 'await' e será executado de forma síncrona - public virtual async Task GetByIdAsync(Guid id) + public virtual async Task GetByIdAsync(Guid id) { return await context.Set().AsNoTracking().FirstOrDefaultAsync(x => x.Id == id); } diff --git a/tests/.editorconfig b/tests/.editorconfig index a560d2e..5e94c65 100644 --- a/tests/.editorconfig +++ b/tests/.editorconfig @@ -229,5 +229,10 @@ dotnet_naming_style.begins_with_i.required_suffix = dotnet_naming_style.begins_with_i.word_separator = dotnet_naming_style.begins_with_i.capitalization = pascal_case +# Code Smells + # CS8618: O campo não anulável precisa conter um valor não nulo ao sair do construtor. Considere declará-lo como anulável. dotnet_diagnostic.CS8618.severity = none + +# CS8632: A anotação para tipos de referência anuláveis deve ser usada apenas em código em um contexto de anotações '#nullable'. +dotnet_diagnostic.CS8632.severity = none diff --git a/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs index 6817a07..aa62313 100644 --- a/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs +++ b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signin/SigninServiceTests.get.cs @@ -63,7 +63,7 @@ public async Task AuthenticateAsync_NotExistingUser_ReturnsNull() Assert.Multiple(() => { Assert.That(tokenResult.HasError, Is.True); - Assert.That(tokenResult.Error.Message, Is.EqualTo("Wrong e-mail or password")); + Assert.That(tokenResult.Error!.Message, Is.EqualTo("Wrong e-mail or password")); }); } } diff --git a/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs index 0b75a8d..4e1c97a 100644 --- a/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs +++ b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Signup/SignupServiceTests.create.cs @@ -49,7 +49,7 @@ public async Task CreateAccountAsync_ExistingCredential_ReturnsErrror() Assert.Multiple(() => { Assert.That(result.HasError, Is.True); - Assert.That(result.Error.Message, Is.EqualTo("Credential already exists")); + Assert.That(result.Error!.Message, Is.EqualTo("Credential already exists")); }); } @@ -71,7 +71,7 @@ public async Task CreateAccountAsync_FailedToCreateUser_ReturnsError() Assert.Multiple(() => { Assert.That(result.HasError, Is.True); - Assert.That(result.Error.Message, Is.EqualTo("Failed to create user")); + Assert.That(result.Error!.Message, Is.EqualTo("Failed to create user")); }); } } diff --git a/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs index 55b5844..9bf24b0 100644 --- a/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs +++ b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.get.cs @@ -34,7 +34,7 @@ public async Task GetAsync_NotExistingUser_ReturnsNotFoundUser() Assert.Multiple(() => { Assert.That(userResult.HasError, Is.True); - Assert.That(userResult.Error.Message, Is.EqualTo("User not found")); + Assert.That(userResult.Error!.Message, Is.EqualTo("User not found")); }); } diff --git a/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs index a6f2cba..879d956 100644 --- a/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs +++ b/tests/auth/FinancialHub.Auth.Application.Tests/Services/Users/UserServiceTests.update.cs @@ -39,7 +39,7 @@ public async Task UpdateAsync_NonExistingUser_ReturnsNotFoundServiceError() Assert.Multiple(() => { Assert.That(updatedUserResult.HasError, Is.True); - Assert.That(updatedUserResult.Error.Message, Is.EqualTo("User not found")); + Assert.That(updatedUserResult.Error!.Message, Is.EqualTo("User not found")); }); } } diff --git a/tests/auth/FinancialHub.Auth.Common.Tests/Assertions/ModelAssert.cs b/tests/auth/FinancialHub.Auth.Common.Tests/Assertions/ModelAssert.cs index 799b7b8..00f85ac 100644 --- a/tests/auth/FinancialHub.Auth.Common.Tests/Assertions/ModelAssert.cs +++ b/tests/auth/FinancialHub.Auth.Common.Tests/Assertions/ModelAssert.cs @@ -2,15 +2,16 @@ { public static class ModelAssert { - public static void Equal(UserModel expected, UserModel actual) + public static void Equal(UserModel expected, UserModel? actual) { Assert.Multiple(() => { - Assert.That(actual.Id, Is.EqualTo(expected.Id)); - Assert.That(actual.FirstName, Is.EqualTo(expected.FirstName)); - Assert.That(actual.LastName, Is.EqualTo(expected.LastName)); - Assert.That(actual.Email, Is.EqualTo(expected.Email)); - Assert.That(actual.BirthDate, Is.EqualTo(expected.BirthDate)); + Assert.That(actual, Is.Not.Null); + Assert.That(actual!.Id, Is.EqualTo(expected.Id)); + Assert.That(actual!.FirstName, Is.EqualTo(expected.FirstName)); + Assert.That(actual!.LastName, Is.EqualTo(expected.LastName)); + Assert.That(actual!.Email, Is.EqualTo(expected.Email)); + Assert.That(actual!.BirthDate, Is.EqualTo(expected.BirthDate)); }); } diff --git a/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs index ba72b48..a959850 100644 --- a/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs +++ b/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SigninControllerTests.cs @@ -86,7 +86,7 @@ public async Task Signin_ValidationError_ReturnsError() Assert.Multiple(() => { Assert.That(jsonResponse, Is.Not.Null); - Assert.That(jsonResponse?.Errors.Count, Is.EqualTo(2)); + Assert.That(jsonResponse?.Errors!.Count, Is.EqualTo(2)); }); } diff --git a/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs index f673cd8..f0b382b 100644 --- a/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs +++ b/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/SignupControllerTests.cs @@ -89,7 +89,7 @@ public async Task Signup_ValidationError_ReturnsError() { Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); Assert.That(jsonResponse, Is.Not.Null); - Assert.That(jsonResponse?.Errors.Count, Is.EqualTo(5)); + Assert.That(jsonResponse!.Errors!, Has.Count.EqualTo(5)); }); } diff --git a/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs b/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs index d2a8871..abe63f1 100644 --- a/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs +++ b/tests/auth/FinancialHub.Auth.IntegrationTests/Controllers/UsersControllerTests.cs @@ -85,7 +85,7 @@ public async Task CreateUser_InvalidUser_ReturnsValidationError() var response = await Client.PostAsync(baseEndpoint, data, token); var jsonResponse = await response.ReadContentAsync(); - Assert.That(jsonResponse?.Errors.Count, Is.EqualTo(4)); + Assert.That(jsonResponse!.Errors, Has.Count.EqualTo(4)); } [Test] @@ -238,7 +238,7 @@ public async Task UpdateUser_InvalidUser_ReturnsValidationError() var response = await Client.PatchAsync(baseEndpoint + $"/{id}", data, token); var jsonResponse = await response.ReadContentAsync(); - Assert.That(jsonResponse?.Errors.Count, Is.EqualTo(4)); + Assert.That(jsonResponse!.Errors, Has.Count.EqualTo(4)); } [Test] diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs index c3aee3e..6e1435a 100644 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs +++ b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs @@ -44,10 +44,13 @@ public async Task UpdateAsync_ValidAccountModel_ReturnsAccountModel() [TestCase(Description = "Update non existing account", Category = "Update")] public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() { - var model = this.accountModelBuilder.Generate(); + var id = Guid.NewGuid(); + var model = this.accountModelBuilder + .WithId(id) + .Generate(); this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) + .Setup(x => x.GetByIdAsync(id)) .ReturnsAsync(default(AccountEntity)) .Verifiable(); @@ -56,7 +59,7 @@ public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() .Returns(async (x) => await Task.FromResult(x)) .Verifiable(); - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); + var result = await this.service.UpdateAsync(id, model); Assert.IsInstanceOf>(result); Assert.IsTrue(result.HasError); diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs index 21c5b5a..cdc5303 100644 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs +++ b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs @@ -48,8 +48,8 @@ public async Task CreateBalance_ServiceError_ReturnsBadRequest() Assert.IsInstanceOf(result?.Value); var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); this.mockService.Verify(x => x.CreateAsync(body), Times.Once); } diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs index ba814b4..9a145bb 100644 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs +++ b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs @@ -49,8 +49,8 @@ public async Task UpdateBalance_Invalid_ReturnsBadRequest() Assert.IsInstanceOf(result?.Value); var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); } diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs index 5b06923..1c24772 100644 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs +++ b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs @@ -49,8 +49,8 @@ public async Task CreateCategory_Invalid_ReturnsBadRequest() Assert.IsInstanceOf(result?.Value); var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); this.mockService.Verify(x => x.CreateAsync(body), Times.Once); } diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs index 985024f..31e163b 100644 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs +++ b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs @@ -51,8 +51,8 @@ public async Task UpdateCategory_Invalid_ReturnsBadRequest() Assert.IsInstanceOf(result?.Value); var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); } diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs index 3223e48..86c48f8 100644 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs +++ b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs @@ -49,8 +49,8 @@ public async Task CreateTransaction_Invalid_ReturnsBadRequest() Assert.IsInstanceOf(result?.Value); var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); this.mockTransactionBalanceServiceService.Verify(x => x.CreateTransactionAsync(body), Times.Once); } diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs index 5f45863..767a634 100644 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs +++ b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs @@ -51,8 +51,8 @@ public async Task UpdateTransaction_Invalid_ReturnsBadRequest() Assert.IsInstanceOf(result?.Value); var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); + Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); + Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); } From 431698e7287dcff563f88caa9e9b06a7ef456bce Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Dantas Date: Fri, 8 Sep 2023 16:15:36 -0300 Subject: [PATCH 24/30] Release v0.5.4-1 * Adds Unit & integration tests result workaround to get both tests --- .github/actions/run-tests/action.yml | 2 +- .github/workflows/matrix_test_result.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index a89755d..0da0b12 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -17,6 +17,6 @@ runs: continue-on-error: true run: dotnet test ${{ inputs.project-dir }} --filter "TestCategory=${{ inputs.category }}" - --logger:"trx;logfilename=Results.xml" + --logger:"trx;logfilename=Results-${{ inputs.category }}.xml" --configuration release \ No newline at end of file diff --git a/.github/workflows/matrix_test_result.yml b/.github/workflows/matrix_test_result.yml index c3caf7e..eade0c3 100644 --- a/.github/workflows/matrix_test_result.yml +++ b/.github/workflows/matrix_test_result.yml @@ -62,4 +62,4 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} check_name: ${{ matrix.project }} project test results action_fail: true - files: "./tests/${{ matrix.project }}/**/TestResults/Results.xml" \ No newline at end of file + files: "./tests/${{ matrix.project }}/**/TestResults/Results-*.xml" \ No newline at end of file From fd9ff89aa14387ee3d02276a1c3bc6d31879b76f Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Date: Sat, 24 Feb 2024 01:14:13 -0300 Subject: [PATCH 25/30] Removes Core project --- src/api/FinancialHub.sln | 80 ------ .../IServiceCollectionExtensions.cs | 50 ---- .../FinancialHub.Core.Application.csproj | 34 --- .../Mappers/FinancialHubAutoMapperProfile.cs | 21 -- .../Mappers/FinancialHubMapperWrapper.cs | 25 -- .../Resources/ErrorMessages.Designer.cs | 99 ------- .../Resources/ErrorMessages.resx | 132 ---------- .../Services/AccountBalanceService.cs | 72 ----- .../Services/AccountsService.cs | 62 ----- .../Services/BalancesService.cs | 107 -------- .../Services/CategoriesService.cs | 53 ---- .../Services/TransactionBalanceService.cs | 207 --------------- .../Services/TransactionsService.cs | 123 --------- .../FinancialHub.Core.Application/Usings.cs | 12 - .../Validators/AccountValidator.cs | 21 -- .../Validators/BalanceValidator.cs | 21 -- .../Validators/CategoryValidator.cs | 21 -- .../Validators/TransactionValidator.cs | 27 -- .../Entities/AccountEntity.cs | 11 - .../Entities/BalanceEntity.cs | 15 -- .../Entities/CategoryEntity.cs | 11 - .../Entities/TransactionEntity.cs | 23 -- .../Enums/TransactionStatus.cs | 10 - .../Enums/TransactionType.cs | 8 - .../Filters/TransactionFilter.cs | 16 -- .../FinancialHub.Core.Domain.csproj | 32 --- .../Interfaces/Mappers/IMapperWrapper.cs | 11 - .../Repositories/IAccountsRepository.cs | 10 - .../Repositories/IBalancesRepository.cs | 12 - .../Repositories/ICategoriesRepository.cs | 9 - .../Repositories/ITransactionsRepository.cs | 9 - .../Services/IAccountBalanceService.cs | 12 - .../Interfaces/Services/IAccountsService.cs | 18 -- .../Interfaces/Services/IBalancesService.cs | 20 -- .../Interfaces/Services/ICategoriesService.cs | 16 -- .../Services/ITransactionBalanceService.cs | 13 - .../Services/ITransactionsService.cs | 19 -- .../Models/AccountModel.cs | 11 - .../Models/BalanceModel.cs | 15 -- .../Models/CategoryModel.cs | 11 - .../Models/TransactionModel.cs | 30 --- .../Queries/TransactionQuery.cs | 64 ----- .../FinancialHubConcepts.Designer.cs | 90 ------- .../Resources/FinancialHubConcepts.resx | 129 --------- .../core/FinancialHub.Core.Domain/Usings.cs | 8 - .../Contexts/FinancialHubContext.cs | 22 -- .../IServiceCollectionExtensions.cs | 27 -- .../FinancialHub.Core.Infra.Data.csproj | 17 -- .../Mappings/AccountEntityMapping.cs | 25 -- .../Mappings/BalanceEntityMapping.cs | 38 --- .../Mappings/CategoryEntityMapping.cs | 25 -- .../Mappings/TransactionEntityMapping.cs | 57 ---- .../20220407152032_v0.2.4.Designer.cs | 189 -------------- .../Migrations/20220407152032_v0.2.4.cs | 110 -------- .../20220520163358_add-balance.Designer.cs | 236 ----------------- .../Migrations/20220520163358_add-balance.cs | 59 ----- ...117_add-balance-to-transaction.Designer.cs | 242 ----------------- ...220520215117_add-balance-to-transaction.cs | 71 ----- ...20520215501_add-balance-active.Designer.cs | 246 ------------------ .../20220520215501_add-balance-active.cs | 28 -- .../FinancialHubContextModelSnapshot.cs | 244 ----------------- .../Repositories/AccountsRepository.cs | 11 - .../Repositories/BalancesRepository.cs | 61 ----- .../Repositories/BaseRepository.cs | 72 ----- .../Repositories/CategoriesRepository.cs | 11 - .../Repositories/TransactionsRepository.cs | 31 --- .../FinancialHub.Core.Infra.Data/Usings.cs | 13 - .../Controllers/AccountsController.cs | 97 ------- .../Controllers/BalancesController.cs | 61 ----- .../Controllers/CategoriesController.cs | 83 ------ .../Controllers/TransactionsController.cs | 87 ------- .../IServiceCollectionExtensions.cs | 39 --- .../FinancialHub.Core.WebApi.csproj | 35 --- .../core/FinancialHub.Core.WebApi/Program.cs | 20 -- .../Properties/launchSettings.json | 31 --- .../core/FinancialHub.Core.WebApi/Startup.cs | 48 ---- .../core/FinancialHub.Core.WebApi/Usings.cs | 16 -- .../appsettings.Development.json | 13 - .../appsettings.Testing.json | 13 - .../FinancialHub.Core.WebApi/appsettings.json | 13 - src/api/core/FinancialHub.Core.sln | 119 --------- 81 files changed, 4310 deletions(-) delete mode 100644 src/api/core/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj delete mode 100644 src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.resx delete mode 100644 src/api/core/FinancialHub.Core.Application/Services/AccountBalanceService.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Services/AccountsService.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Services/BalancesService.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Services/CategoriesService.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Services/TransactionBalanceService.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Services/TransactionsService.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Usings.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Validators/AccountValidator.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Validators/BalanceValidator.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Validators/CategoryValidator.cs delete mode 100644 src/api/core/FinancialHub.Core.Application/Validators/TransactionValidator.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Entities/AccountEntity.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Entities/BalanceEntity.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Entities/CategoryEntity.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Entities/TransactionEntity.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Enums/TransactionStatus.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Enums/TransactionType.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Filters/TransactionFilter.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Models/AccountModel.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Models/BalanceModel.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Models/CategoryModel.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Models/TransactionModel.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Queries/TransactionQuery.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs delete mode 100644 src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx delete mode 100644 src/api/core/FinancialHub.Core.Domain/Usings.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs delete mode 100644 src/api/core/FinancialHub.Core.Infra.Data/Usings.cs delete mode 100644 src/api/core/FinancialHub.Core.WebApi/Controllers/AccountsController.cs delete mode 100644 src/api/core/FinancialHub.Core.WebApi/Controllers/BalancesController.cs delete mode 100644 src/api/core/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs delete mode 100644 src/api/core/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs delete mode 100644 src/api/core/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs delete mode 100644 src/api/core/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj delete mode 100644 src/api/core/FinancialHub.Core.WebApi/Program.cs delete mode 100644 src/api/core/FinancialHub.Core.WebApi/Properties/launchSettings.json delete mode 100644 src/api/core/FinancialHub.Core.WebApi/Startup.cs delete mode 100644 src/api/core/FinancialHub.Core.WebApi/Usings.cs delete mode 100644 src/api/core/FinancialHub.Core.WebApi/appsettings.Development.json delete mode 100644 src/api/core/FinancialHub.Core.WebApi/appsettings.Testing.json delete mode 100644 src/api/core/FinancialHub.Core.WebApi/appsettings.json delete mode 100644 src/api/core/FinancialHub.Core.sln diff --git a/src/api/FinancialHub.sln b/src/api/FinancialHub.sln index 53400e0..78556da 100644 --- a/src/api/FinancialHub.sln +++ b/src/api/FinancialHub.sln @@ -9,36 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common", "comm EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common.Tests", "..\..\tests\common\FinancialHub.Common.Tests\FinancialHub.Common.Tests.csproj", "{785E774A-9D67-4EAB-AB71-D60EBE8144DD}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{BEE32E30-21CF-489B-B208-3D053E4966A8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{FB841C40-3211-443F-AC95-CD5796CF4FB3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application.Tests", "..\..\tests\core\FinancialHub.Core.Application.Tests\FinancialHub.Core.Application.Tests.csproj", "{54A8A393-BE7E-4403-8F48-EC42060F128E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain.Tests", "..\..\tests\core\FinancialHub.Core.Domain.Tests\FinancialHub.Core.Domain.Tests.csproj", "{3B8AF190-2B4D-4647-877C-2FDE681C2ED3}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{0F151C31-117F-438E-A5B5-9EE1D669BE27}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{3B96E644-4E1A-4C2F-8F3C-E4843C921B92}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi.Tests", "..\..\tests\core\FinancialHub.Core.WebApi.Tests\FinancialHub.Core.WebApi.Tests.csproj", "{0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{15C0C14F-DA06-46BB-A8B0-4BA5D6372777}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data.Tests", "..\..\tests\core\FinancialHub.Core.Infra.Data.Tests\FinancialHub.Core.Infra.Data.Tests.csproj", "{180DB5AB-AF6F-49EF-B5C6-6566B8B88711}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application", "core\FinancialHub.Core.Application\FinancialHub.Core.Application.csproj", "{921409C4-23D6-4D92-B62F-2908142749C9}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain", "core\FinancialHub.Core.Domain\FinancialHub.Core.Domain.csproj", "{DFA4EC74-777A-4929-96C6-C29463B22D58}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data", "core\FinancialHub.Core.Infra.Data\FinancialHub.Core.Infra.Data.csproj", "{893D69AA-5483-44AE-AD8C-E9C6E6F0276A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi", "core\FinancialHub.Core.WebApi\FinancialHub.Core.WebApi.csproj", "{CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.IntegrationTests", "..\..\tests\core\FinancialHub.Core.IntegrationTests\FinancialHub.Core.IntegrationTests.csproj", "{AC293685-7094-4325-8D5B-4ED252C62942}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Auth", "Auth", "{A93CC4E0-F468-49C7-8429-9384A124BB2D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{698C287C-20C9-45E1-A6B2-15141C74C3E2}" @@ -96,42 +66,6 @@ Global {785E774A-9D67-4EAB-AB71-D60EBE8144DD}.Debug|Any CPU.Build.0 = Debug|Any CPU {785E774A-9D67-4EAB-AB71-D60EBE8144DD}.Release|Any CPU.ActiveCfg = Release|Any CPU {785E774A-9D67-4EAB-AB71-D60EBE8144DD}.Release|Any CPU.Build.0 = Release|Any CPU - {54A8A393-BE7E-4403-8F48-EC42060F128E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {54A8A393-BE7E-4403-8F48-EC42060F128E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {54A8A393-BE7E-4403-8F48-EC42060F128E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {54A8A393-BE7E-4403-8F48-EC42060F128E}.Release|Any CPU.Build.0 = Release|Any CPU - {3B8AF190-2B4D-4647-877C-2FDE681C2ED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B8AF190-2B4D-4647-877C-2FDE681C2ED3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B8AF190-2B4D-4647-877C-2FDE681C2ED3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B8AF190-2B4D-4647-877C-2FDE681C2ED3}.Release|Any CPU.Build.0 = Release|Any CPU - {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28}.Release|Any CPU.Build.0 = Release|Any CPU - {180DB5AB-AF6F-49EF-B5C6-6566B8B88711}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {180DB5AB-AF6F-49EF-B5C6-6566B8B88711}.Debug|Any CPU.Build.0 = Debug|Any CPU - {180DB5AB-AF6F-49EF-B5C6-6566B8B88711}.Release|Any CPU.ActiveCfg = Release|Any CPU - {180DB5AB-AF6F-49EF-B5C6-6566B8B88711}.Release|Any CPU.Build.0 = Release|Any CPU - {921409C4-23D6-4D92-B62F-2908142749C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {921409C4-23D6-4D92-B62F-2908142749C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {921409C4-23D6-4D92-B62F-2908142749C9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {921409C4-23D6-4D92-B62F-2908142749C9}.Release|Any CPU.Build.0 = Release|Any CPU - {DFA4EC74-777A-4929-96C6-C29463B22D58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DFA4EC74-777A-4929-96C6-C29463B22D58}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DFA4EC74-777A-4929-96C6-C29463B22D58}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DFA4EC74-777A-4929-96C6-C29463B22D58}.Release|Any CPU.Build.0 = Release|Any CPU - {893D69AA-5483-44AE-AD8C-E9C6E6F0276A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {893D69AA-5483-44AE-AD8C-E9C6E6F0276A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {893D69AA-5483-44AE-AD8C-E9C6E6F0276A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {893D69AA-5483-44AE-AD8C-E9C6E6F0276A}.Release|Any CPU.Build.0 = Release|Any CPU - {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503}.Release|Any CPU.Build.0 = Release|Any CPU - {AC293685-7094-4325-8D5B-4ED252C62942}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AC293685-7094-4325-8D5B-4ED252C62942}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AC293685-7094-4325-8D5B-4ED252C62942}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AC293685-7094-4325-8D5B-4ED252C62942}.Release|Any CPU.Build.0 = Release|Any CPU {CCADF7E9-2D5E-433C-8376-1C4F32BEDED4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CCADF7E9-2D5E-433C-8376-1C4F32BEDED4}.Debug|Any CPU.Build.0 = Debug|Any CPU {CCADF7E9-2D5E-433C-8376-1C4F32BEDED4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -191,20 +125,6 @@ Global GlobalSection(NestedProjects) = preSolution {C24C6373-0DB4-4ECC-A902-692267EBD922} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} {785E774A-9D67-4EAB-AB71-D60EBE8144DD} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} - {FB841C40-3211-443F-AC95-CD5796CF4FB3} = {BEE32E30-21CF-489B-B208-3D053E4966A8} - {54A8A393-BE7E-4403-8F48-EC42060F128E} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} - {3B8AF190-2B4D-4647-877C-2FDE681C2ED3} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} - {0F151C31-117F-438E-A5B5-9EE1D669BE27} = {BEE32E30-21CF-489B-B208-3D053E4966A8} - {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} = {BEE32E30-21CF-489B-B208-3D053E4966A8} - {0DBB37A5-96EE-4B6D-8DE8-AAA6FE603F28} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} - {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} = {BEE32E30-21CF-489B-B208-3D053E4966A8} - {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} = {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} - {180DB5AB-AF6F-49EF-B5C6-6566B8B88711} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} - {921409C4-23D6-4D92-B62F-2908142749C9} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} - {DFA4EC74-777A-4929-96C6-C29463B22D58} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} - {893D69AA-5483-44AE-AD8C-E9C6E6F0276A} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} - {CBA72DA9-5F87-4AE1-8B79-DD29F7A2C503} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} - {AC293685-7094-4325-8D5B-4ED252C62942} = {BEE32E30-21CF-489B-B208-3D053E4966A8} {698C287C-20C9-45E1-A6B2-15141C74C3E2} = {A93CC4E0-F468-49C7-8429-9384A124BB2D} {2F11BC84-BA3C-43A0-BAB8-FC65E6E4566C} = {A93CC4E0-F468-49C7-8429-9384A124BB2D} {B7C0B348-3E2C-40BA-850D-BDA93FEA6B44} = {A93CC4E0-F468-49C7-8429-9384A124BB2D} diff --git a/src/api/core/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/core/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs deleted file mode 100644 index b2df365..0000000 --- a/src/api/core/FinancialHub.Core.Application/Extensions/Configurations/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using FinancialHub.Core.Application.Mappers; -using FinancialHub.Core.Application.Services; -using FinancialHub.Core.Application.Validators; -using FluentValidation; - -namespace FinancialHub.Core.Application.Extensions.Configurations -{ - public static class IServiceCollectionExtensions - { - public static IServiceCollection AddCoreServices(this IServiceCollection services) - { - services.AddMapper(); - services.AddServices(); - services.AddValidators(); - - return services; - } - - private static IServiceCollection AddServices(this IServiceCollection services) - { - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - - services.AddScoped(); - services.AddScoped(); - - return services; - } - - private static IServiceCollection AddMapper(this IServiceCollection services) - { - services.AddAutoMapper(typeof(FinancialHubAutoMapperProfile)); - services.AddScoped(); - - return services; - } - - private static IServiceCollection AddValidators(this IServiceCollection services) - { - services.AddScoped, AccountValidator>(); - services.AddScoped, CategoryValidator>(); - services.AddScoped, TransactionValidator>(); - - return services; - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj b/src/api/core/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj deleted file mode 100644 index f74aec1..0000000 --- a/src/api/core/FinancialHub.Core.Application/FinancialHub.Core.Application.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - - - - - - - ErrorMessages.resx - True - True - - - - - - ErrorMessages.Designer.cs - ResXFileCodeGenerator - - - - diff --git a/src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs b/src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs deleted file mode 100644 index 32eae87..0000000 --- a/src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubAutoMapperProfile.cs +++ /dev/null @@ -1,21 +0,0 @@ -using AutoMapper; -using FinancialHub.Core.Domain.Filters; -using FinancialHub.Core.Domain.Queries; - -namespace FinancialHub.Core.Application.Mappers -{ - public class FinancialHubAutoMapperProfile : Profile - { - public FinancialHubAutoMapperProfile() - { - //Entities - CreateMap().ReverseMap(); - CreateMap().ReverseMap(); - CreateMap().ReverseMap(); - CreateMap().ReverseMap(); - - //Queries - CreateMap().ReverseMap(); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs b/src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs deleted file mode 100644 index c927016..0000000 --- a/src/api/core/FinancialHub.Core.Application/Mappers/FinancialHubMapperWrapper.cs +++ /dev/null @@ -1,25 +0,0 @@ -using AutoMapper; -using FinancialHub.Core.Domain.Interfaces.Mappers; - -namespace FinancialHub.Core.Application.Mappers -{ - public class FinancialHubMapperWrapper : IMapperWrapper - { - private readonly IMapper mapper; - - public FinancialHubMapperWrapper(IMapper mapper) - { - this.mapper = mapper; - } - - public Y Map(T ent) - { - return this.mapper.Map(ent); - } - - public Y Map(object ent) - { - return this.mapper.Map(ent); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs b/src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs deleted file mode 100644 index b39e401..0000000 --- a/src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.Designer.cs +++ /dev/null @@ -1,99 +0,0 @@ -//------------------------------------------------------------------------------ -// -// O código foi gerado por uma ferramenta. -// Versão de Tempo de Execução:4.0.30319.42000 -// -// As alterações ao arquivo poderão causar comportamento incorreto e serão perdidas se -// o código for gerado novamente. -// -//------------------------------------------------------------------------------ - -namespace FinancialHub.Core.Application.Resources { - using System; - - - /// - /// Uma classe de recurso de tipo de alta segurança, para pesquisar cadeias de caracteres localizadas etc. - /// - // Essa classe foi gerada automaticamente pela classe StronglyTypedResourceBuilder - // através de uma ferramenta como ResGen ou Visual Studio. - // Para adicionar ou remover um associado, edite o arquivo .ResX e execute ResGen novamente - // com a opção /str, ou recrie o projeto do VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class ErrorMessages { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal ErrorMessages() { - } - - /// - /// Retorna a instância de ResourceManager armazenada em cache usada por essa classe. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.Core.Application.Resources.ErrorMessages", typeof(ErrorMessages).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Substitui a propriedade CurrentUICulture do thread atual para todas as - /// pesquisas de recursos que usam essa classe de recurso de tipo de alta segurança. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} exceeds the max length of {MaxLength}. - /// - internal static string ExceedMaxLength { - get { - return ResourceManager.GetString("ExceedMaxLength", resourceCulture); - } - } - - /// - /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} must be greater than {ComparisonValue}. - /// - internal static string GreaterThan { - get { - return ResourceManager.GetString("GreaterThan", resourceCulture); - } - } - - /// - /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} has a range of values which does not include '{PropertyValue}'. - /// - internal static string OutOfEnum { - get { - return ResourceManager.GetString("OutOfEnum", resourceCulture); - } - } - - /// - /// Consulta uma cadeia de caracteres localizada semelhante a {PropertyName} is required. - /// - internal static string Required { - get { - return ResourceManager.GetString("Required", resourceCulture); - } - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.resx b/src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.resx deleted file mode 100644 index cb3d55b..0000000 --- a/src/api/core/FinancialHub.Core.Application/Resources/ErrorMessages.resx +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - {PropertyName} exceeds the max length of {MaxLength} - - - {PropertyName} must be greater than {ComparisonValue} - - - {PropertyName} has a range of values which does not include '{PropertyValue}' - - - {PropertyName} is required - - \ No newline at end of file diff --git a/src/api/core/FinancialHub.Core.Application/Services/AccountBalanceService.cs b/src/api/core/FinancialHub.Core.Application/Services/AccountBalanceService.cs deleted file mode 100644 index ad4e88d..0000000 --- a/src/api/core/FinancialHub.Core.Application/Services/AccountBalanceService.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace FinancialHub.Core.Application.Services -{ - public class AccountBalanceService : IAccountBalanceService - { - private readonly IBalancesService balancesService; - private readonly IAccountsService accountsService; - - public AccountBalanceService(IBalancesService balancesService,IAccountsService accountsService) - { - this.balancesService = balancesService; - this.accountsService = accountsService; - } - - public async Task> CreateAsync(AccountModel account) - { - var createdAccount = await this.accountsService.CreateAsync(account); - - if(createdAccount.HasError) - { - return createdAccount.Error; - } - - var balance = new BalanceModel() - { - Name = $"{createdAccount.Data!.Name} Default Balance", - AccountId = createdAccount.Data.Id.GetValueOrDefault(), - IsActive = createdAccount.Data.IsActive - }; - var createdBalance = await this.balancesService.CreateAsync(balance); - - if (createdBalance.HasError) - { - return createdBalance.Error; - } - - return createdAccount; - } - - public async Task> DeleteAsync(Guid accountId) - { - int removedLines = 0; - - var balances = await this.balancesService.GetAllByAccountAsync(accountId); - - foreach (var balance in balances.Data!) - { - var balanceResult = await this.balancesService.DeleteAsync(balance.Id.GetValueOrDefault()); - if (balanceResult.HasError) - { - return balanceResult.Error; - } - - removedLines += balanceResult.Data; - } - - var accountResult = await this.accountsService.DeleteAsync(accountId); - if (accountResult.HasError) - { - return accountResult.Error; - } - - removedLines += accountResult.Data; - - return removedLines; - } - - public async Task>> GetBalancesByAccountAsync(Guid accountId) - { - return await this.balancesService.GetAllByAccountAsync(accountId); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Services/AccountsService.cs b/src/api/core/FinancialHub.Core.Application/Services/AccountsService.cs deleted file mode 100644 index 255e6a3..0000000 --- a/src/api/core/FinancialHub.Core.Application/Services/AccountsService.cs +++ /dev/null @@ -1,62 +0,0 @@ -namespace FinancialHub.Core.Application.Services -{ - public class AccountsService : IAccountsService - { - private readonly IMapperWrapper mapper; - private readonly IAccountsRepository repository; - - public AccountsService(IMapperWrapper mapper,IAccountsRepository repository) - { - this.mapper = mapper; - this.repository = repository; - } - - public async Task> CreateAsync(AccountModel account) - { - var entity = mapper.Map(account); - - entity = await this.repository.CreateAsync(entity); - - return mapper.Map(entity); - } - - public async Task> DeleteAsync(Guid id) - { - var count = await this.repository.DeleteAsync(id); - - return new ServiceResult(count); - } - - public async Task>> GetAllByUserAsync(string userId) - { - var entities = await this.repository.GetAllAsync(); - - var list = this.mapper.Map>(entities); - - return list.ToArray(); - } - - public async Task> GetByIdAsync(Guid id) - { - var entity = await this.repository.GetByIdAsync(id); - - return this.mapper.Map(entity); - } - - public async Task> UpdateAsync(Guid id, AccountModel account) - { - var entity = await this.repository.GetByIdAsync(id); - - if (entity == null) - { - return new NotFoundError($"Not found account with id {id}"); - } - - entity = this.mapper.Map(account); - - entity = await this.repository.UpdateAsync(entity); - - return mapper.Map(entity); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Services/BalancesService.cs b/src/api/core/FinancialHub.Core.Application/Services/BalancesService.cs deleted file mode 100644 index ba7845c..0000000 --- a/src/api/core/FinancialHub.Core.Application/Services/BalancesService.cs +++ /dev/null @@ -1,107 +0,0 @@ -namespace FinancialHub.Core.Application.Services -{ - public class BalancesService : IBalancesService - { - private readonly IMapperWrapper mapper; - private readonly IBalancesRepository repository; - private readonly IAccountsRepository accountsRepository; - - public BalancesService(IMapperWrapper mapper, - IBalancesRepository repository, IAccountsRepository accountsRepository - ) - { - this.mapper = mapper; - this.repository = repository; - this.accountsRepository = accountsRepository; - } - - private async Task ValidateAccountAsync(BalanceEntity balance) - { - var accountResult = await this.accountsRepository.GetByIdAsync(balance.AccountId); - - if(accountResult == null) - { - return new NotFoundError($"Not found Account with id {balance.AccountId}"); - } - - return new ServiceResult(); - } - - public async Task> CreateAsync(BalanceModel balance) - { - var entity = this.mapper.Map(balance); - entity.Amount = 0; - - var validationResult = await this.ValidateAccountAsync(entity); - if (validationResult.HasError) - { - return validationResult.Error; - } - - entity = await this.repository.CreateAsync(entity); - - return mapper.Map(entity); - } - - public async Task> DeleteAsync(Guid id) - { - var count = await this.repository.DeleteAsync(id); - - return new ServiceResult(count); - } - - public async Task> GetByIdAsync(Guid id) - { - var entity = await this.repository.GetByIdAsync(id); - - if(entity == null) - { - return new NotFoundError($"Not found Balance with id {id}"); - } - - return this.mapper.Map(entity); - } - - public async Task>> GetAllByAccountAsync(Guid accountId) - { - var entities = await this.repository.GetAsync(x => x.AccountId == accountId); - - return this.mapper.Map>(entities).ToArray(); - } - - public async Task> UpdateAsync(Guid id, BalanceModel balance) - { - var entityResult = await this.GetByIdAsync(id); - if (entityResult.HasError) - { - return entityResult.Error; - } - - var entity = this.mapper.Map(balance); - entity.Id = id; - - var validationResult = await this.ValidateAccountAsync(entity); - if (validationResult.HasError) - { - return validationResult.Error; - } - - entity = await this.repository.UpdateAsync(entity); - - return mapper.Map(entity); - } - - public async Task> UpdateAmountAsync(Guid id, decimal newAmount) - { - var balanceResult = await this.GetByIdAsync(id); - if (balanceResult.HasError) - { - return balanceResult.Error; - } - - var newBalance = await repository.ChangeAmountAsync(id, newAmount); - - return mapper.Map(newBalance); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Services/CategoriesService.cs b/src/api/core/FinancialHub.Core.Application/Services/CategoriesService.cs deleted file mode 100644 index 05336d2..0000000 --- a/src/api/core/FinancialHub.Core.Application/Services/CategoriesService.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace FinancialHub.Core.Application.Services -{ - public class CategoriesService : ICategoriesService - { - private readonly IMapperWrapper mapper; - private readonly ICategoriesRepository repository; - - public CategoriesService(IMapperWrapper mapper, ICategoriesRepository repository) - { - this.mapper = mapper; - this.repository = repository; - } - - public async Task> CreateAsync(CategoryModel category) - { - var entity = mapper.Map(category); - - entity = await this.repository.CreateAsync(entity); - - return mapper.Map(entity); - } - - public async Task> DeleteAsync(Guid id) - { - return await this.repository.DeleteAsync(id); - } - - public async Task>> GetAllByUserAsync(string userId) - { - var entities = await this.repository.GetAllAsync(); - - var list = this.mapper.Map>(entities); - - return list.ToArray(); - } - - public async Task> UpdateAsync(Guid id, CategoryModel category) - { - var entity = await this.repository.GetByIdAsync(id); - - if (entity == null) - { - return new NotFoundError($"Not found category with id {id}"); - } - entity.Id = id; - - entity = this.mapper.Map(category); - entity = await this.repository.UpdateAsync(entity); - - return mapper.Map(entity); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Services/TransactionBalanceService.cs b/src/api/core/FinancialHub.Core.Application/Services/TransactionBalanceService.cs deleted file mode 100644 index 2cb7e53..0000000 --- a/src/api/core/FinancialHub.Core.Application/Services/TransactionBalanceService.cs +++ /dev/null @@ -1,207 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Application.Services -{ - public class TransactionBalanceService : ITransactionBalanceService - { - private readonly ITransactionsService transactionsService; - private readonly IBalancesService balancesService; - - public TransactionBalanceService(ITransactionsService transactionsService, IBalancesService balancesService) - { - this.transactionsService = transactionsService; - this.balancesService = balancesService; - } - - private static (decimal oldAmount, decimal newAmount) UpdateAmountDifferentBalances(TransactionModel oldTransaction, TransactionModel newTransaction) - { - var oldAmount = oldTransaction.Balance.Amount; - var newAmount = newTransaction.Balance.Amount; - - if (oldTransaction.IsPaid) - { - oldAmount = - oldTransaction.Type == TransactionType.Earn ? - oldAmount - oldTransaction.Amount : - oldAmount + oldTransaction.Amount; - } - - if (newTransaction.IsPaid) - { - newAmount = - newTransaction.Type == TransactionType.Earn ? - newAmount + newTransaction.Amount : - newAmount - newTransaction.Amount; - } - - return (oldAmount, newAmount); - } - - private static decimal UpdateAmountDifferentStatus(TransactionModel newTransaction) - { - var newAmount = newTransaction.Balance.Amount; - - if (newTransaction.IsPaid) - { - if (newTransaction.Type == TransactionType.Earn) - return newAmount + newTransaction.Amount; - else - return newAmount - newTransaction.Amount; - } - else - { - if (newTransaction.Type == TransactionType.Earn) - return newAmount - newTransaction.Amount; - else - return newAmount + newTransaction.Amount; - } - } - - private static decimal UpdateAmountSameStatus(TransactionModel oldTransaction, TransactionModel newTransaction) - { - var newAmount = newTransaction.Balance.Amount; - - if (newTransaction.Type == oldTransaction.Type) - { - decimal difference; - if (oldTransaction.Type == TransactionType.Earn) - difference = newTransaction.Amount - oldTransaction.Amount; - else - difference = oldTransaction.Amount - newTransaction.Amount; - - return newAmount + difference; - } - else - { - var difference = oldTransaction.Amount + newTransaction.Amount; - if (oldTransaction.Type == TransactionType.Earn) - return newAmount - difference; - else - return newAmount + difference; - } - } - - private static decimal UpdateAmountSameBalance(TransactionModel oldTransaction, TransactionModel newTransaction) - { - var newAmount = newTransaction.Balance.Amount; - if (oldTransaction.IsPaid != newTransaction.IsPaid) - { - return UpdateAmountDifferentStatus(newTransaction); - } - else if (oldTransaction.IsPaid && newTransaction.IsPaid) - { - return UpdateAmountSameStatus(oldTransaction, newTransaction); - } - return newAmount; - } - - public async Task UpdateAmountAsync(TransactionModel oldTransaction, TransactionModel newTransaction) - { - if(oldTransaction.IsPaid || newTransaction.IsPaid) - { - if (oldTransaction.BalanceId != newTransaction.BalanceId) - { - var (oldAmount, newAmount) = UpdateAmountDifferentBalances(oldTransaction, newTransaction); - - if (oldAmount != oldTransaction.Balance.Amount) - await this.balancesService.UpdateAmountAsync(oldTransaction.BalanceId, oldAmount); - if (newAmount != newTransaction.Balance.Amount) - await this.balancesService.UpdateAmountAsync(newTransaction.BalanceId, newAmount); - } - else - { - var newAmount = UpdateAmountSameBalance(oldTransaction, newTransaction); - - if(newAmount != newTransaction.Balance.Amount) - { - await this.balancesService.UpdateAmountAsync(newTransaction.BalanceId, newAmount); - } - } - } - } - - public async Task> CreateTransactionAsync(TransactionModel transaction) - { - var transactionResult = await transactionsService.CreateAsync(transaction); - - if(transactionResult.HasError) { - return transactionResult; - } - - if(transactionResult.Data!.IsPaid) - { - var balanceResult = await balancesService.GetByIdAsync(transaction.BalanceId); - if(balanceResult.HasError) { - return balanceResult.Error; - } - - if (transaction.Type == TransactionType.Earn) - { - await balancesService.UpdateAmountAsync(transaction.BalanceId, balanceResult.Data!.Amount + transaction.Amount); - } - else - { - await balancesService.UpdateAmountAsync(transaction.BalanceId, balanceResult.Data!.Amount - transaction.Amount); - } - } - - return transactionResult; - } - - public async Task> UpdateTransactionAsync(Guid id, TransactionModel transaction) - { - var oldTransactionResult = await transactionsService.GetByIdAsync(id); - - var transactionResult = await transactionsService.UpdateAsync(id, transaction); - if (transactionResult.HasError) - { - return transactionResult; - } - - var oldTransaction = oldTransactionResult.Data!; - var newTransaction = transactionResult.Data!; - var balanceResult = await balancesService.GetByIdAsync(newTransaction.BalanceId); - - if (newTransaction.BalanceId == oldTransaction.BalanceId) - { - oldTransaction.Balance = balanceResult.Data; - newTransaction.Balance = balanceResult.Data; - } - else - { - var oldBalanceResult = await balancesService.GetByIdAsync(oldTransaction.BalanceId); - - oldTransaction.Balance = oldBalanceResult.Data; - newTransaction.Balance = balanceResult.Data; - } - await this.UpdateAmountAsync(oldTransaction, newTransaction); - - return transactionResult; - } - - public async Task> DeleteTransactionAsync(Guid id) - { - var oldTransaction = await this.transactionsService.GetByIdAsync(id); - - var deleted = await this.transactionsService.DeleteAsync(id); - - if (deleted.HasError) - return deleted.Error; - if (deleted.Data == 0) - return false; - - var transaction = oldTransaction.Data!; - if (transaction.IsPaid) - { - var amount = transaction.Balance.Amount; - amount = transaction.Type == TransactionType.Earn? - amount - transaction.Amount: - amount + transaction.Amount; - - await this.balancesService.UpdateAmountAsync(transaction.BalanceId, amount); - } - - return true; - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Services/TransactionsService.cs b/src/api/core/FinancialHub.Core.Application/Services/TransactionsService.cs deleted file mode 100644 index f21bf22..0000000 --- a/src/api/core/FinancialHub.Core.Application/Services/TransactionsService.cs +++ /dev/null @@ -1,123 +0,0 @@ -using FinancialHub.Core.Domain.Filters; -using FinancialHub.Core.Domain.Queries; -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Application.Services -{ - public class TransactionsService : ITransactionsService - { - private readonly IMapperWrapper mapper; - private readonly ITransactionsRepository repository; - private readonly IBalancesRepository balancesRepository; - private readonly ICategoriesRepository categoriesRepository; - - public TransactionsService( - IMapperWrapper mapper, - ITransactionsRepository repository, - IBalancesRepository balancesRepository, ICategoriesRepository categoriesRepository - ) - { - this.mapper = mapper; - this.repository = repository; - this.balancesRepository = balancesRepository; - this.categoriesRepository = categoriesRepository; - } - - private async Task> ValidateTransaction(TransactionEntity transaction) - { - var balance = await this.balancesRepository.GetByIdAsync(transaction.BalanceId); - if (balance == null) - { - return new NotFoundError($"Not found Balance with id {transaction.BalanceId}"); - } - - var category = await this.categoriesRepository.GetByIdAsync(transaction.CategoryId); - if (category == null) - { - return new NotFoundError($"Not found Category with id {transaction.CategoryId}"); - } - - return true; - } - - public async Task> CreateAsync(TransactionModel transaction) - { - var entity = mapper.Map(transaction); - - var validation = await this.ValidateTransaction(entity); - if (validation.HasError) - { - return new ServiceResult(error: validation.Error); - } - - entity = await this.repository.CreateAsync(entity); - /* - if (entity.Status == TransactionStatus.Committed && entity.IsActive) - { - await this.balancesRepository.ChangeAmountAsync(entity.BalanceId,entity.Amount,entity.Type); - }*/ - - return mapper.Map(entity); - } - - public async Task> DeleteAsync(Guid id) - { - var transactionResult = await this.GetByIdAsync(id); - if (transactionResult.HasError) - { - return transactionResult.Error; - } - var transaction = transactionResult.Data!; - - if (transaction.Status == TransactionStatus.Committed && transaction.IsActive) - { - await this.balancesRepository.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type,true); - } - - return await this.repository.DeleteAsync(id); - } - - public async Task>> GetAllByUserAsync(string userId, TransactionFilter filter) - { - var query = mapper.Map(filter); - //query.UserId = userId; - - var entities = await this.repository.GetAsync(query.Query()); - - var models = mapper.Map>(entities); - - return models.ToArray(); - } - - public async Task> UpdateAsync(Guid id, TransactionModel transaction) - { - var oldTransactionResult = await this.GetByIdAsync(id); - if (oldTransactionResult.HasError) - { - return oldTransactionResult.Error; - } - var newTransaction = this.mapper.Map(transaction); - - var validation = await this.ValidateTransaction(newTransaction); - if (validation.HasError) - { - return new ServiceResult(error: validation.Error); - } - - newTransaction = await this.repository.UpdateAsync(newTransaction); - - return mapper.Map(newTransaction); - } - - public async Task> GetByIdAsync(Guid id) - { - var transaction = await this.repository.GetByIdAsync(id); - if (transaction == null) - { - return new NotFoundError($"Not found Transaction with id {id}"); - } - - return mapper.Map(transaction); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Usings.cs b/src/api/core/FinancialHub.Core.Application/Usings.cs deleted file mode 100644 index 3cc3e53..0000000 --- a/src/api/core/FinancialHub.Core.Application/Usings.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Domain Project interfaces namespaces -global using FinancialHub.Core.Domain.Interfaces.Repositories; -global using FinancialHub.Core.Domain.Interfaces.Services; -global using FinancialHub.Core.Domain.Interfaces.Mappers; - -// Common Project namespaces -global using FinancialHub.Common.Results; -global using FinancialHub.Common.Results.Errors; - -// Domain Project entities & models namespaces -global using FinancialHub.Core.Domain.Entities; -global using FinancialHub.Core.Domain.Models; \ No newline at end of file diff --git a/src/api/core/FinancialHub.Core.Application/Validators/AccountValidator.cs b/src/api/core/FinancialHub.Core.Application/Validators/AccountValidator.cs deleted file mode 100644 index 9c752da..0000000 --- a/src/api/core/FinancialHub.Core.Application/Validators/AccountValidator.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FinancialHub.Core.Application.Resources; -using FluentValidation; - -namespace FinancialHub.Core.Application.Validators -{ - public class AccountValidator : AbstractValidator - { - public AccountValidator() - { - RuleFor(x => x.Name) - .NotEmpty() - .WithMessage(ErrorMessages.Required) - .Length(0,200) - .WithMessage(ErrorMessages.ExceedMaxLength); - - RuleFor(x => x.Description) - .Length(0, 500) - .WithMessage(ErrorMessages.ExceedMaxLength); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Validators/BalanceValidator.cs b/src/api/core/FinancialHub.Core.Application/Validators/BalanceValidator.cs deleted file mode 100644 index 3eff9c0..0000000 --- a/src/api/core/FinancialHub.Core.Application/Validators/BalanceValidator.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FinancialHub.Core.Application.Resources; -using FluentValidation; - -namespace FinancialHub.Core.Application.Validators -{ - public class BalanceValidator : AbstractValidator - { - public BalanceValidator() : base() - { - RuleFor(x => x.Name) - .NotEmpty() - .WithMessage(ErrorMessages.Required) - .Length(0, 200) - .WithMessage(ErrorMessages.ExceedMaxLength); - - RuleFor(x => x.AccountId) - .NotEmpty() - .WithMessage(ErrorMessages.Required); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Validators/CategoryValidator.cs b/src/api/core/FinancialHub.Core.Application/Validators/CategoryValidator.cs deleted file mode 100644 index c884109..0000000 --- a/src/api/core/FinancialHub.Core.Application/Validators/CategoryValidator.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FinancialHub.Core.Application.Resources; -using FluentValidation; - -namespace FinancialHub.Core.Application.Validators -{ - public class CategoryValidator : AbstractValidator - { - public CategoryValidator() - { - RuleFor(x => x.Name) - .NotEmpty() - .WithMessage(ErrorMessages.Required) - .Length(0,200) - .WithMessage(ErrorMessages.ExceedMaxLength); - - RuleFor(x => x.Description) - .Length(0,500) - .WithMessage(ErrorMessages.ExceedMaxLength); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Application/Validators/TransactionValidator.cs b/src/api/core/FinancialHub.Core.Application/Validators/TransactionValidator.cs deleted file mode 100644 index 401879d..0000000 --- a/src/api/core/FinancialHub.Core.Application/Validators/TransactionValidator.cs +++ /dev/null @@ -1,27 +0,0 @@ -using FinancialHub.Core.Application.Resources; -using FluentValidation; - -namespace FinancialHub.Core.Application.Validators -{ - public class TransactionValidator : AbstractValidator - { - public TransactionValidator() - { - RuleFor(x => x.Description) - .Length(0, 500) - .WithMessage(ErrorMessages.ExceedMaxLength); - - RuleFor(x => x.Amount) - .GreaterThan(0) - .WithMessage(ErrorMessages.GreaterThan); - - RuleFor(x => x.Status) - .IsInEnum() - .WithMessage(ErrorMessages.OutOfEnum); - - RuleFor(x => x.Type) - .IsInEnum() - .WithMessage(ErrorMessages.OutOfEnum); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Entities/AccountEntity.cs b/src/api/core/FinancialHub.Core.Domain/Entities/AccountEntity.cs deleted file mode 100644 index b15c010..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Entities/AccountEntity.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FinancialHub.Core.Domain.Entities -{ - public class AccountEntity : BaseEntity - { - public string Name { get; set; } - public string Description { get; set; } - public bool IsActive { get; set; } - - public ICollection Balances { get; set; } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Entities/BalanceEntity.cs b/src/api/core/FinancialHub.Core.Domain/Entities/BalanceEntity.cs deleted file mode 100644 index 57252dc..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Entities/BalanceEntity.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace FinancialHub.Core.Domain.Entities -{ - public class BalanceEntity : BaseEntity - { - public string Name { get; set; } - public string Currency { get; set; } - public decimal Amount { get; set; } - public bool IsActive { get; set; } - - public Guid AccountId { get; set; } - public AccountEntity Account { get; set; } - - public ICollection Transactions { get; set; } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Entities/CategoryEntity.cs b/src/api/core/FinancialHub.Core.Domain/Entities/CategoryEntity.cs deleted file mode 100644 index 57504ee..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Entities/CategoryEntity.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FinancialHub.Core.Domain.Entities -{ - public class CategoryEntity : BaseEntity - { - public string Name { get; set; } - public string Description { get; set; } - public bool IsActive { get; set; } - - public ICollection Transactions { get; set; } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Entities/TransactionEntity.cs b/src/api/core/FinancialHub.Core.Domain/Entities/TransactionEntity.cs deleted file mode 100644 index 3289b42..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Entities/TransactionEntity.cs +++ /dev/null @@ -1,23 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Domain.Entities -{ - public class TransactionEntity : BaseEntity - { - public string Description { get; set; } - public decimal Amount { get; set; } - - public DateTimeOffset TargetDate { get; set; } - public DateTimeOffset FinishDate { get; set; } - - public Guid BalanceId { get; set; } - public BalanceEntity Balance { get; set; } - - public Guid CategoryId { get; set; } - public CategoryEntity Category { get; set; } - - public bool IsActive { get; set; } - public TransactionStatus Status { get; set; } - public TransactionType Type { get; set; } - } -} \ No newline at end of file diff --git a/src/api/core/FinancialHub.Core.Domain/Enums/TransactionStatus.cs b/src/api/core/FinancialHub.Core.Domain/Enums/TransactionStatus.cs deleted file mode 100644 index 8ca5480..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Enums/TransactionStatus.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace FinancialHub.Core.Domain.Enums -{ - public enum TransactionStatus - { - NotCommitted = 0, - Committed = 1, - //Aborted = 2, - //Rollback = 3 - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Enums/TransactionType.cs b/src/api/core/FinancialHub.Core.Domain/Enums/TransactionType.cs deleted file mode 100644 index adf04aa..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Enums/TransactionType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace FinancialHub.Core.Domain.Enums -{ - public enum TransactionType - { - Earn = 1, - Expense = 2 - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Filters/TransactionFilter.cs b/src/api/core/FinancialHub.Core.Domain/Filters/TransactionFilter.cs deleted file mode 100644 index 04f1e85..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Filters/TransactionFilter.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Domain.Filters -{ - public class TransactionFilter - { - public DateTime? StartDate { get; set; } - public DateTime? EndDate { get; set; } - - public TransactionType[] Types { get; set; } - public TransactionStatus[] Status { get; set; } - - public Guid[] Accounts { get; set; } - public Guid[] Categories { get; set; } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj b/src/api/core/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj deleted file mode 100644 index dcc132e..0000000 --- a/src/api/core/FinancialHub.Core.Domain/FinancialHub.Core.Domain.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - net6.0 - - - - - - - - - - - - - - - True - True - FinancialHubConcepts.resx - - - - - - PublicResXFileCodeGenerator - FinancialHubConcepts.Designer.cs - - - - diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs deleted file mode 100644 index 642a07e..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Mappers/IMapperWrapper.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FinancialHub.Core.Domain.Interfaces.Mappers -{ - /// - /// Wrapper interface for Mapper Classes - /// - public interface IMapperWrapper - { - Y Map(T ent); - Y Map(object ent); - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs deleted file mode 100644 index 149df61..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IAccountsRepository.cs +++ /dev/null @@ -1,10 +0,0 @@ -using FinancialHub.Common.Interfaces.Repositories; -using FinancialHub.Core.Domain.Entities; - -namespace FinancialHub.Core.Domain.Interfaces.Repositories -{ - public interface IAccountsRepository : IBaseRepository - { - //Task> GetByUserId(string userId); - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs deleted file mode 100644 index b0e2070..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/IBalancesRepository.cs +++ /dev/null @@ -1,12 +0,0 @@ -using FinancialHub.Common.Interfaces.Repositories; -using FinancialHub.Core.Domain.Entities; -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Domain.Interfaces.Repositories -{ - public interface IBalancesRepository : IBaseRepository - { - Task ChangeAmountAsync(Guid balanceId,decimal value, TransactionType transactionType, bool removed = false); - Task ChangeAmountAsync(Guid balanceId,decimal value); - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs deleted file mode 100644 index 419f558..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ICategoriesRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -using FinancialHub.Common.Interfaces.Repositories; -using FinancialHub.Core.Domain.Entities; - -namespace FinancialHub.Core.Domain.Interfaces.Repositories -{ - public interface ICategoriesRepository : IBaseRepository - { - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs deleted file mode 100644 index 96d267b..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Repositories/ITransactionsRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -using FinancialHub.Common.Interfaces.Repositories; -using FinancialHub.Core.Domain.Entities; - -namespace FinancialHub.Core.Domain.Interfaces.Repositories -{ - public interface ITransactionsRepository : IBaseRepository - { - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs deleted file mode 100644 index 136c775..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountBalanceService.cs +++ /dev/null @@ -1,12 +0,0 @@ -using FinancialHub.Common.Results; -using FinancialHub.Core.Domain.Models; - -namespace FinancialHub.Core.Domain.Interfaces.Services -{ - public interface IAccountBalanceService - { - Task>> GetBalancesByAccountAsync(Guid accountId); - Task> CreateAsync(AccountModel account); - Task> DeleteAsync(Guid accountId); - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs deleted file mode 100644 index 956fa77..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IAccountsService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using FinancialHub.Common.Results; -using FinancialHub.Core.Domain.Models; - -namespace FinancialHub.Core.Domain.Interfaces.Services -{ - public interface IAccountsService - { - Task>> GetAllByUserAsync(string userId); - - Task> GetByIdAsync(Guid id); - - Task> CreateAsync(AccountModel account); - - Task> UpdateAsync(Guid id,AccountModel account); - - Task> DeleteAsync(Guid id); - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs deleted file mode 100644 index 71c84bf..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/IBalancesService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FinancialHub.Common.Results; -using FinancialHub.Core.Domain.Models; - -namespace FinancialHub.Core.Domain.Interfaces.Services -{ - public interface IBalancesService - { - Task> GetByIdAsync(Guid id); - - Task>> GetAllByAccountAsync(Guid accountId); - - Task> CreateAsync(BalanceModel balance); - - Task> UpdateAsync(Guid id, BalanceModel balance); - - Task> UpdateAmountAsync(Guid id, decimal newAmount); - - Task> DeleteAsync(Guid id); - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs deleted file mode 100644 index 76e2c6e..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ICategoriesService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FinancialHub.Common.Results; -using FinancialHub.Core.Domain.Models; - -namespace FinancialHub.Core.Domain.Interfaces.Services -{ - public interface ICategoriesService - { - Task>> GetAllByUserAsync(string userId); - - Task> CreateAsync(CategoryModel category); - - Task> UpdateAsync(Guid id, CategoryModel category); - - Task> DeleteAsync(Guid id); - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs deleted file mode 100644 index fabd299..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionBalanceService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using FinancialHub.Common.Results; -using FinancialHub.Core.Domain.Models; - -namespace FinancialHub.Core.Domain.Interfaces.Services -{ - public interface ITransactionBalanceService - { - Task> CreateTransactionAsync(TransactionModel transaction); - Task> UpdateTransactionAsync(Guid id,TransactionModel transaction); - Task UpdateAmountAsync(TransactionModel oldTransaction, TransactionModel newTransaction); - Task> DeleteTransactionAsync(Guid id); - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs b/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs deleted file mode 100644 index 653660c..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Interfaces/Services/ITransactionsService.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FinancialHub.Common.Results; -using FinancialHub.Core.Domain.Models; -using FinancialHub.Core.Domain.Filters; - -namespace FinancialHub.Core.Domain.Interfaces.Services -{ - public interface ITransactionsService - { - Task>> GetAllByUserAsync(string userId, TransactionFilter filter); - - Task> GetByIdAsync(Guid id); - - Task> CreateAsync(TransactionModel transaction); - - Task> UpdateAsync(Guid id, TransactionModel transaction); - - Task> DeleteAsync(Guid id); - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Models/AccountModel.cs b/src/api/core/FinancialHub.Core.Domain/Models/AccountModel.cs deleted file mode 100644 index a588e2b..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Models/AccountModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using FinancialHub.Common.Models; - -namespace FinancialHub.Core.Domain.Models -{ - public class AccountModel : BaseModel - { - public string Name { get; set; } - public string Description { get; set; } - public bool IsActive { get; set; } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Models/BalanceModel.cs b/src/api/core/FinancialHub.Core.Domain/Models/BalanceModel.cs deleted file mode 100644 index 3b3f20d..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Models/BalanceModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FinancialHub.Common.Models; -using System; - -namespace FinancialHub.Core.Domain.Models -{ - public class BalanceModel : BaseModel - { - public string Name { get; set; } - public string Currency { get; set; } - public decimal Amount { get; set; } - public Guid AccountId { get; set; } - public AccountModel Account { get; set; } - public bool IsActive { get; set; } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Models/CategoryModel.cs b/src/api/core/FinancialHub.Core.Domain/Models/CategoryModel.cs deleted file mode 100644 index 1c60446..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Models/CategoryModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using FinancialHub.Common.Models; - -namespace FinancialHub.Core.Domain.Models -{ - public class CategoryModel : BaseModel - { - public string Name { get; set; } - public string Description { get; set; } - public bool IsActive { get; set; } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Models/TransactionModel.cs b/src/api/core/FinancialHub.Core.Domain/Models/TransactionModel.cs deleted file mode 100644 index 771f0e0..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Models/TransactionModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Text.Json.Serialization; -using FinancialHub.Common.Models; -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Domain.Models -{ - public class TransactionModel : BaseModel - { - public string Description { get; set; } - public decimal Amount { get; set; } - - public DateTimeOffset TargetDate { get; set; } - public DateTimeOffset FinishDate { get; set; } - - public Guid BalanceId { get; set; } - public BalanceModel Balance { get; set; } - - public Guid CategoryId { get; set; } - public CategoryModel Category { get; set; } - - public bool IsActive { get; set; } - - public TransactionStatus Status { get; set; } - public TransactionType Type { get ; set ;} - - [JsonIgnore] - public bool IsPaid => this.IsActive && this.Status == TransactionStatus.Committed; - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Queries/TransactionQuery.cs b/src/api/core/FinancialHub.Core.Domain/Queries/TransactionQuery.cs deleted file mode 100644 index 3438ec2..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Queries/TransactionQuery.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Linq; -using FinancialHub.Core.Domain.Entities; -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Domain.Queries -{ - public class TransactionQuery - { - public DateTime? StartDate { get; set; } - public DateTime? EndDate { get; set; } - - public Guid[] Balances { get; set; } - public Guid[] Categories { get; set; } - - public TransactionType[] Types { get; set; } - public TransactionStatus[] Status { get; set; } - - public Func Query() - { - //TODO: compare performance - return this.QueryFuncs(); - } - - private Func QueryFuncs() - { - var queries = new List> - { - (ent) => ent.IsActive - }; - - if (StartDate != null) - { - if (EndDate == null) - { - StartDate = new DateTime(StartDate.Value.Year, StartDate.Value.Month,1); - EndDate = StartDate.Value.AddMonths(1).AddSeconds(-1); - } - queries.Add((ent) => ent.TargetDate >= StartDate && ent.TargetDate <= EndDate); - } - - if (Balances?.Length > 0) - { - queries.Add((ent) => Balances.Contains(ent.BalanceId)); - } - - if (Categories?.Length > 0) - { - queries.Add((ent) => Categories.Contains(ent.CategoryId)); - } - - if (Types?.Length > 0) - { - queries.Add((ent) => Types.Contains(ent.Type)); - } - - if (Status?.Length > 0) - { - queries.Add((ent) => Status.Contains(ent.Status)); - } - - return (ent) => queries.All(query => query(ent)); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs b/src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs deleted file mode 100644 index f2a30f6..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.Designer.cs +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------ -// -// O código foi gerado por uma ferramenta. -// Versão de Tempo de Execução:4.0.30319.42000 -// -// As alterações ao arquivo poderão causar comportamento incorreto e serão perdidas se -// o código for gerado novamente. -// -//------------------------------------------------------------------------------ - -namespace FinancialHub.Core.Domain.Resources { - using System; - - - /// - /// Uma classe de recurso de tipo de alta segurança, para pesquisar cadeias de caracteres localizadas etc. - /// - // Essa classe foi gerada automaticamente pela classe StronglyTypedResourceBuilder - // através de uma ferramenta como ResGen ou Visual Studio. - // Para adicionar ou remover um associado, edite o arquivo .ResX e execute ResGen novamente - // com a opção /str, ou recrie o projeto do VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class FinancialHubConcepts { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal FinancialHubConcepts() { - } - - /// - /// Retorna a instância de ResourceManager armazenada em cache usada por essa classe. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FinancialHub.Core.Domain.Resources.FinancialHubConcepts", typeof(FinancialHubConcepts).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Substitui a propriedade CurrentUICulture do thread atual para todas as - /// pesquisas de recursos que usam essa classe de recurso de tipo de alta segurança. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Consulta uma cadeia de caracteres localizada semelhante a Account. - /// - public static string Account { - get { - return ResourceManager.GetString("Account", resourceCulture); - } - } - - /// - /// Consulta uma cadeia de caracteres localizada semelhante a Category. - /// - public static string Category { - get { - return ResourceManager.GetString("Category", resourceCulture); - } - } - - /// - /// Consulta uma cadeia de caracteres localizada semelhante a Transaction. - /// - public static string Transaction { - get { - return ResourceManager.GetString("Transaction", resourceCulture); - } - } - } -} diff --git a/src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx b/src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx deleted file mode 100644 index aceeed7..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Resources/FinancialHubConcepts.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Account - - - Category - - - Transaction - - \ No newline at end of file diff --git a/src/api/core/FinancialHub.Core.Domain/Usings.cs b/src/api/core/FinancialHub.Core.Domain/Usings.cs deleted file mode 100644 index 7dbf743..0000000 --- a/src/api/core/FinancialHub.Core.Domain/Usings.cs +++ /dev/null @@ -1,8 +0,0 @@ -// System namespaces -global using System; -global using System.Collections.Generic; -global using System.Threading.Tasks; - -// Domain Models namespaces -global using FinancialHub.Common.Entities; -global using FinancialHub.Common.Models; \ No newline at end of file diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs b/src/api/core/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs deleted file mode 100644 index aa3cd1f..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Contexts/FinancialHubContext.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace FinancialHub.Core.Infra.Data.Contexts -{ - public class FinancialHubContext : DbContext - { - public FinancialHubContext([NotNull] DbContextOptions options) : base(options) - { - } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.ApplyConfigurationsFromAssembly(typeof(FinancialHubContext).Assembly); - base.OnModelCreating(modelBuilder); - } - - public DbSet Accounts { get; set; } - public DbSet Transactions { get; set; } - public DbSet Categories { get; set; } - public DbSet Balances { get; set; } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/core/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs deleted file mode 100644 index 035949c..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Extensions/Configurations/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using FinancialHub.Core.Infra.Data.Contexts; -using FinancialHub.Core.Infra.Data.Repositories; - -namespace FinancialHub.Core.Infra.Data.Extensions.Configurations -{ - public static class IServiceCollectionExtensions - { - public static IServiceCollection AddRepositories(this IServiceCollection services, IConfiguration configuration) - { - services.AddDbContext( - provider => - provider.UseSqlServer( - configuration.GetConnectionString("default"), - x => x.MigrationsHistoryTable("migrations") - ) - ); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - - return services; - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj b/src/api/core/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj deleted file mode 100644 index 6453bfe..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/FinancialHub.Core.Infra.Data.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net6.0 - - - - - - - - - - - - - diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs b/src/api/core/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs deleted file mode 100644 index 9838384..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Mappings/AccountEntityMapping.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace FinancialHub.Core.Infra.Data.Mappings -{ - internal class AccountEntityMapping : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder.Property(t => t.Name) - .HasColumnName("name") - .HasMaxLength(200) - .IsRequired(); - - builder.Property(t => t.Description) - .HasColumnName("description") - .HasMaxLength(500) - .IsRequired(); - - builder.Property(t => t.IsActive) - .HasColumnName("active"); - - builder.ToTable("accounts"); - } - } -} \ No newline at end of file diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs b/src/api/core/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs deleted file mode 100644 index 2f9b7e7..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Mappings/BalanceEntityMapping.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace FinancialHub.Core.Infra.Data.Mappings -{ - internal class BalanceEntityMapping : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder.HasKey(t => t.Id); - builder.HasIndex(t => t.Id).IsUnique(true); - - builder.Property(t => t.Name) - .HasColumnName("name") - .HasMaxLength(200); - builder.Property(t => t.Currency) - .HasColumnName("currency") - .HasMaxLength(50); - builder.Property(t => t.Amount) - .HasColumnType("money") - .IsRequired(); - builder.Property(t => t.IsActive) - .HasColumnName("active") - .IsRequired(); - - builder.Property(t => t.AccountId) - .HasColumnName("account_id") - .IsRequired(); - builder.HasOne(x => x.Account) - .WithMany(x => x.Balances) - .HasForeignKey(x => x.AccountId) - .HasPrincipalKey(x => x.Id) - .IsRequired(); - builder.Navigation(t => t.Account).AutoInclude(); - - builder.ToTable("balances"); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs b/src/api/core/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs deleted file mode 100644 index c9641cd..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Mappings/CategoryEntityMapping.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace FinancialHub.Core.Infra.Data.Mappings -{ - internal class CategoryEntityMapping : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder.Property(t => t.Name) - .HasColumnName("name") - .HasMaxLength(200) - .IsRequired(); - - builder.Property(t => t.Description) - .HasColumnName("description") - .HasMaxLength(500) - .IsRequired(); - - builder.Property(t => t.IsActive) - .HasColumnName("active"); - - builder.ToTable("categories"); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs b/src/api/core/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs deleted file mode 100644 index ee67d71..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Mappings/TransactionEntityMapping.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace FinancialHub.Core.Infra.Data.Mappings -{ - internal class TransactionEntityMapping : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder.HasKey(t => t.Id); - builder.HasIndex(t => t.Id).IsUnique(true); - - builder.Property(t => t.Description) - .HasColumnName("description") - .HasMaxLength(500); - builder.Property(t => t.Amount) - .HasColumnType("money") - .IsRequired(); - builder.Property(t => t.TargetDate) - .HasColumnName("target_date") - .IsRequired(); - builder.Property(t => t.FinishDate) - .HasColumnName("finish_date"); - - builder.Property(t => t.BalanceId) - .HasColumnName("balance_id") - .IsRequired(); - builder.HasOne(x => x.Balance) - .WithMany(x => x.Transactions) - .HasForeignKey(x => x.BalanceId) - .HasPrincipalKey(x => x.Id) - .IsRequired(); - builder.Navigation(t => t.Balance).AutoInclude(); - - builder.Property(t => t.CategoryId) - .HasColumnName("category_id") - .IsRequired(); - builder.HasOne(x => x.Category) - .WithMany(x => x.Transactions) - .HasForeignKey(x => x.CategoryId) - .HasPrincipalKey(x => x.Id) - .IsRequired(); - builder.Navigation(t => t.Category).AutoInclude(); - - builder.Property(t => t.IsActive) - .HasColumnName("active") - .IsRequired(); - builder.Property(t => t.Status) - .HasColumnName("status") - .IsRequired(); - builder.Property(t => t.Type) - .HasColumnName("type") - .IsRequired(); - - builder.ToTable("transactions"); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs deleted file mode 100644 index b41081a..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.Designer.cs +++ /dev/null @@ -1,189 +0,0 @@ -// -using System; -using FinancialHub.Core.Infra.Data.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace FinancialHub.Core.Infra.Data.Migrations -{ - [DbContext(typeof(FinancialHubContext))] - [Migration("20220407152032_v0.2.4")] - partial class v024 - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Currency") - .HasColumnType("varchar(50)") - .HasColumnName("currency"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("accounts"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("categories"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("AccountId") - .HasColumnType("uniqueidentifier") - .HasColumnName("account_id"); - - b.Property("Amount") - .HasColumnType("money") - .HasColumnName("amount"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier") - .HasColumnName("category_id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("FinishDate") - .HasColumnType("datetimeoffset") - .HasColumnName("finish_date"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Status") - .HasColumnType("int") - .HasColumnName("status"); - - b.Property("TargetDate") - .HasColumnType("datetimeoffset") - .HasColumnName("target_date"); - - b.Property("Type") - .HasColumnType("int") - .HasColumnName("type"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") - .WithMany("Transactions") - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") - .WithMany("Transactions") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Navigation("Transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Navigation("Transactions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs deleted file mode 100644 index 4da3f7e..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220407152032_v0.2.4.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace FinancialHub.Core.Infra.Data.Migrations -{ - [ExcludeFromCodeCoverage] - public partial class v024 : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "accounts", - columns: table => new - { - id = table.Column(type: "uniqueidentifier", nullable: false), - name = table.Column(type: "varchar(200)", nullable: true), - description = table.Column(type: "varchar(500)", nullable: true), - currency = table.Column(type: "varchar(50)", nullable: true), - active = table.Column(type: "bit", nullable: false), - creation_time = table.Column(type: "datetimeoffset", nullable: true), - update_time = table.Column(type: "datetimeoffset", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_accounts", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "categories", - columns: table => new - { - id = table.Column(type: "uniqueidentifier", nullable: false), - name = table.Column(type: "varchar(200)", nullable: true), - description = table.Column(type: "varchar(500)", nullable: true), - active = table.Column(type: "bit", nullable: false), - creation_time = table.Column(type: "datetimeoffset", nullable: true), - update_time = table.Column(type: "datetimeoffset", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_categories", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "transactions", - columns: table => new - { - id = table.Column(type: "uniqueidentifier", nullable: false), - description = table.Column(type: "varchar(500)", nullable: true), - amount = table.Column(type: "money", nullable: false), - target_date = table.Column(type: "datetimeoffset", nullable: false), - finish_date = table.Column(type: "datetimeoffset", nullable: false), - account_id = table.Column(type: "uniqueidentifier", nullable: false), - category_id = table.Column(type: "uniqueidentifier", nullable: false), - active = table.Column(type: "bit", nullable: false), - status = table.Column(type: "int", nullable: false), - type = table.Column(type: "int", nullable: false), - creation_time = table.Column(type: "datetimeoffset", nullable: true), - update_time = table.Column(type: "datetimeoffset", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_transactions", x => x.id); - table.ForeignKey( - name: "FK_transactions_accounts_account_id", - column: x => x.account_id, - principalTable: "accounts", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_transactions_categories_category_id", - column: x => x.category_id, - principalTable: "categories", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_transactions_account_id", - table: "transactions", - column: "account_id"); - - migrationBuilder.CreateIndex( - name: "IX_transactions_category_id", - table: "transactions", - column: "category_id"); - - migrationBuilder.CreateIndex( - name: "IX_transactions_id", - table: "transactions", - column: "id", - unique: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "transactions"); - - migrationBuilder.DropTable( - name: "accounts"); - - migrationBuilder.DropTable( - name: "categories"); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs deleted file mode 100644 index 3464a87..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.Designer.cs +++ /dev/null @@ -1,236 +0,0 @@ -// -using System; -using FinancialHub.Core.Infra.Data.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace FinancialHub.Core.Infra.Data.Migrations -{ - [DbContext(typeof(FinancialHubContext))] - [Migration("20220520163358_add-balance")] - partial class addbalance - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("accounts"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("AccountId") - .HasColumnType("uniqueidentifier") - .HasColumnName("account_id"); - - b.Property("Amount") - .HasColumnType("money") - .HasColumnName("amount"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Currency") - .HasColumnType("varchar(50)") - .HasColumnName("currency"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.ToTable("balances"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("categories"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("AccountId") - .HasColumnType("uniqueidentifier") - .HasColumnName("account_id"); - - b.Property("Amount") - .HasColumnType("money") - .HasColumnName("amount"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier") - .HasColumnName("category_id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("FinishDate") - .HasColumnType("datetimeoffset") - .HasColumnName("finish_date"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Status") - .HasColumnType("int") - .HasColumnName("status"); - - b.Property("TargetDate") - .HasColumnType("datetimeoffset") - .HasColumnName("target_date"); - - b.Property("Type") - .HasColumnType("int") - .HasColumnName("type"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") - .WithMany("Balances") - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") - .WithMany("Transactions") - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") - .WithMany("Transactions") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Navigation("Balances"); - - b.Navigation("Transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Navigation("Transactions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs deleted file mode 100644 index 90aa347..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520163358_add-balance.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace FinancialHub.Core.Infra.Data.Migrations -{ - [ExcludeFromCodeCoverage] - public partial class addbalance : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "currency", - table: "accounts"); - - migrationBuilder.CreateTable( - name: "balances", - columns: table => new - { - id = table.Column(type: "uniqueidentifier", nullable: false), - name = table.Column(type: "varchar(200)", nullable: true), - currency = table.Column(type: "varchar(50)", nullable: true), - amount = table.Column(type: "money", nullable: false), - account_id = table.Column(type: "uniqueidentifier", nullable: false), - creation_time = table.Column(type: "datetimeoffset", nullable: true), - update_time = table.Column(type: "datetimeoffset", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_balances", x => x.id); - table.ForeignKey( - name: "FK_balances_accounts_account_id", - column: x => x.account_id, - principalTable: "accounts", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_balances_account_id", - table: "balances", - column: "account_id"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "balances"); - - migrationBuilder.AddColumn( - name: "currency", - table: "accounts", - type: "varchar(50)", - nullable: true); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs deleted file mode 100644 index 3d7e5c1..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.Designer.cs +++ /dev/null @@ -1,242 +0,0 @@ -// -using System; -using FinancialHub.Core.Infra.Data.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace FinancialHub.Core.Infra.Data.Migrations -{ - [DbContext(typeof(FinancialHubContext))] - [Migration("20220520215117_add-balance-to-transaction")] - partial class addbalancetotransaction - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("accounts"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("AccountId") - .HasColumnType("uniqueidentifier") - .HasColumnName("account_id"); - - b.Property("Amount") - .HasColumnType("money") - .HasColumnName("amount"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Currency") - .HasColumnType("varchar(50)") - .HasColumnName("currency"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("balances"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("categories"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("Amount") - .HasColumnType("money") - .HasColumnName("amount"); - - b.Property("BalanceId") - .HasColumnType("uniqueidentifier") - .HasColumnName("balance_id"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier") - .HasColumnName("category_id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("FinishDate") - .HasColumnType("datetimeoffset") - .HasColumnName("finish_date"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Status") - .HasColumnType("int") - .HasColumnName("status"); - - b.Property("TargetDate") - .HasColumnType("datetimeoffset") - .HasColumnName("target_date"); - - b.Property("Type") - .HasColumnType("int") - .HasColumnName("type"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.HasIndex("BalanceId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") - .WithMany("Balances") - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.HasOne("FinancialHub.Domain.Entities.BalanceEntity", "Balance") - .WithMany("Transactions") - .HasForeignKey("BalanceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") - .WithMany("Transactions") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Balance"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Navigation("Balances"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.Navigation("Transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Navigation("Transactions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs deleted file mode 100644 index 6efae8e..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215117_add-balance-to-transaction.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using System.Diagnostics.CodeAnalysis; - -#nullable disable - -namespace FinancialHub.Core.Infra.Data.Migrations -{ - [ExcludeFromCodeCoverage] - public partial class addbalancetotransaction : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_transactions_accounts_account_id", - table: "transactions"); - - migrationBuilder.RenameColumn( - name: "account_id", - table: "transactions", - newName: "balance_id"); - - migrationBuilder.RenameIndex( - name: "IX_transactions_account_id", - table: "transactions", - newName: "IX_transactions_balance_id"); - - migrationBuilder.CreateIndex( - name: "IX_balances_id", - table: "balances", - column: "id", - unique: true); - - migrationBuilder.AddForeignKey( - name: "FK_transactions_balances_balance_id", - table: "transactions", - column: "balance_id", - principalTable: "balances", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_transactions_balances_balance_id", - table: "transactions"); - - migrationBuilder.DropIndex( - name: "IX_balances_id", - table: "balances"); - - migrationBuilder.RenameColumn( - name: "balance_id", - table: "transactions", - newName: "account_id"); - - migrationBuilder.RenameIndex( - name: "IX_transactions_balance_id", - table: "transactions", - newName: "IX_transactions_account_id"); - - migrationBuilder.AddForeignKey( - name: "FK_transactions_accounts_account_id", - table: "transactions", - column: "account_id", - principalTable: "accounts", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs deleted file mode 100644 index e49ccd4..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.Designer.cs +++ /dev/null @@ -1,246 +0,0 @@ -// -using System; -using FinancialHub.Core.Infra.Data.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace FinancialHub.Core.Infra.Data.Migrations -{ - [DbContext(typeof(FinancialHubContext))] - [Migration("20220520215501_add-balance-active")] - partial class addbalanceactive - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("accounts"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("AccountId") - .HasColumnType("uniqueidentifier") - .HasColumnName("account_id"); - - b.Property("Amount") - .HasColumnType("money") - .HasColumnName("amount"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Currency") - .HasColumnType("varchar(50)") - .HasColumnName("currency"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("balances"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("categories"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("Amount") - .HasColumnType("money") - .HasColumnName("amount"); - - b.Property("BalanceId") - .HasColumnType("uniqueidentifier") - .HasColumnName("balance_id"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier") - .HasColumnName("category_id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("FinishDate") - .HasColumnType("datetimeoffset") - .HasColumnName("finish_date"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Status") - .HasColumnType("int") - .HasColumnName("status"); - - b.Property("TargetDate") - .HasColumnType("datetimeoffset") - .HasColumnName("target_date"); - - b.Property("Type") - .HasColumnType("int") - .HasColumnName("type"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.HasIndex("BalanceId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") - .WithMany("Balances") - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.HasOne("FinancialHub.Domain.Entities.BalanceEntity", "Balance") - .WithMany("Transactions") - .HasForeignKey("BalanceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") - .WithMany("Transactions") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Balance"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Navigation("Balances"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.Navigation("Transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Navigation("Transactions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs deleted file mode 100644 index 740819c..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/20220520215501_add-balance-active.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using System.Diagnostics.CodeAnalysis; - -#nullable disable - -namespace FinancialHub.Core.Infra.Data.Migrations -{ - [ExcludeFromCodeCoverage] - public partial class addbalanceactive : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "active", - table: "balances", - type: "bit", - nullable: false, - defaultValue: false); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "active", - table: "balances"); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs b/src/api/core/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs deleted file mode 100644 index f3342c7..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Migrations/FinancialHubContextModelSnapshot.cs +++ /dev/null @@ -1,244 +0,0 @@ -// -using System; -using FinancialHub.Core.Infra.Data.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace FinancialHub.Core.Infra.Data.Migrations -{ - [DbContext(typeof(FinancialHubContext))] - partial class FinancialHubContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("accounts"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("AccountId") - .HasColumnType("uniqueidentifier") - .HasColumnName("account_id"); - - b.Property("Amount") - .HasColumnType("money") - .HasColumnName("amount"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Currency") - .HasColumnType("varchar(50)") - .HasColumnName("currency"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("balances"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Name") - .HasColumnType("varchar(200)") - .HasColumnName("name"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.ToTable("categories"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasColumnName("id"); - - b.Property("Amount") - .HasColumnType("money") - .HasColumnName("amount"); - - b.Property("BalanceId") - .HasColumnType("uniqueidentifier") - .HasColumnName("balance_id"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier") - .HasColumnName("category_id"); - - b.Property("CreationTime") - .HasColumnType("datetimeoffset") - .HasColumnName("creation_time"); - - b.Property("Description") - .HasColumnType("varchar(500)") - .HasColumnName("description"); - - b.Property("FinishDate") - .HasColumnType("datetimeoffset") - .HasColumnName("finish_date"); - - b.Property("IsActive") - .HasColumnType("bit") - .HasColumnName("active"); - - b.Property("Status") - .HasColumnType("int") - .HasColumnName("status"); - - b.Property("TargetDate") - .HasColumnType("datetimeoffset") - .HasColumnName("target_date"); - - b.Property("Type") - .HasColumnType("int") - .HasColumnName("type"); - - b.Property("UpdateTime") - .HasColumnType("datetimeoffset") - .HasColumnName("update_time"); - - b.HasKey("Id"); - - b.HasIndex("BalanceId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.HasOne("FinancialHub.Domain.Entities.AccountEntity", "Account") - .WithMany("Balances") - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.TransactionEntity", b => - { - b.HasOne("FinancialHub.Domain.Entities.BalanceEntity", "Balance") - .WithMany("Transactions") - .HasForeignKey("BalanceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("FinancialHub.Domain.Entities.CategoryEntity", "Category") - .WithMany("Transactions") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Balance"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.AccountEntity", b => - { - b.Navigation("Balances"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.BalanceEntity", b => - { - b.Navigation("Transactions"); - }); - - modelBuilder.Entity("FinancialHub.Domain.Entities.CategoryEntity", b => - { - b.Navigation("Transactions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs deleted file mode 100644 index 52fb560..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/AccountsRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -using FinancialHub.Core.Infra.Data.Contexts; - -namespace FinancialHub.Core.Infra.Data.Repositories -{ - public class AccountsRepository : BaseRepository, IAccountsRepository - { - public AccountsRepository(FinancialHubContext context) : base(context) - { - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs deleted file mode 100644 index fec0d6a..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BalancesRepository.cs +++ /dev/null @@ -1,61 +0,0 @@ -using FinancialHub.Core.Domain.Enums; -using FinancialHub.Core.Infra.Data.Contexts; - -namespace FinancialHub.Core.Infra.Data.Repositories -{ - public class BalancesRepository : BaseRepository, IBalancesRepository - { - public BalancesRepository(FinancialHubContext context) : base(context) - { - } - - public async override Task UpdateAsync(BalanceEntity obj) - { - obj.UpdateTime = DateTimeOffset.Now; - - var result = this.context.Update(obj); - this.context.Entry(result.Entity).Property(x => x.Amount).IsModified = false; - this.context.Entry(result.Entity).Property(x => x.CreationTime).IsModified = false; - - await context.SaveChangesAsync(); - await result.ReloadAsync(); - - return result.Entity; - } - - public async override Task CreateAsync(BalanceEntity obj) - { - obj.Amount = 0; - return await base.CreateAsync(obj); - } - - public async Task ChangeAmountAsync(Guid balanceId, decimal value, TransactionType transactionType, bool removed = false) - { - var balance = await this.GetByIdAsync(balanceId); - - if (transactionType == TransactionType.Earn) - { - balance.Amount = !removed ? balance.Amount + value: balance.Amount - value; - } - else - { - balance.Amount = removed ? balance.Amount + value : balance.Amount - value; - } - - balance.UpdateTime = DateTimeOffset.Now; - context.Update(balance); - await context.SaveChangesAsync(); - context.ChangeTracker.Clear(); - - return balance; - } - - public async Task ChangeAmountAsync(Guid balanceId, decimal value) - { - var balance = await this.GetByIdAsync(balanceId); - context.ChangeTracker.Clear(); - balance.Amount = value; - return await this.UpdateAsync(balance); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs deleted file mode 100644 index 218d808..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/BaseRepository.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Linq; -using FinancialHub.Core.Infra.Data.Contexts; -using FinancialHub.Common.Entities; -using FinancialHub.Common.Interfaces.Repositories; - -namespace FinancialHub.Core.Infra.Data.Repositories -{ - public class BaseRepository : IBaseRepository - where T : BaseEntity - { - protected readonly FinancialHubContext context; - public BaseRepository(FinancialHubContext context) - { - this.context = context; - } - - public virtual async Task CreateAsync(T obj) - { - obj.Id = null; - obj.CreationTime = DateTimeOffset.Now; - obj.UpdateTime = DateTimeOffset.Now; - - var res = await context.Set().AddAsync(obj); - await context.SaveChangesAsync(); - return res.Entity; - } - - public virtual async Task DeleteAsync(Guid id) - { - var entity = await this.GetByIdAsync(id); - - if(entity != null) - { - context.Set().Remove(entity); - return await context.SaveChangesAsync(); - } - else - { - return 0; - } - } - - public virtual async Task UpdateAsync(T obj) - { - obj.UpdateTime = DateTimeOffset.Now; - - var res = context.Set().Update(obj); - this.context.Entry(res.Entity).Property(x => x.CreationTime).IsModified = false; - - await context.SaveChangesAsync(); - - return res.Entity; - } - - public virtual async Task> GetAllAsync() - { - return await context.Set().ToListAsync(); - } - -#pragma warning disable CS1998 // O método assíncrono não possui operadores 'await' e será executado de forma síncrona - public virtual async Task> GetAsync(Func predicate) - { - return context.Set().Where(predicate).ToList(); - } -#pragma warning restore CS1998 // O método assíncrono não possui operadores 'await' e será executado de forma síncrona - - public virtual async Task GetByIdAsync(Guid id) - { - return await context.Set().AsNoTracking().FirstOrDefaultAsync(x => x.Id == id); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs deleted file mode 100644 index 4842f52..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/CategoriesRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -using FinancialHub.Core.Infra.Data.Contexts; - -namespace FinancialHub.Core.Infra.Data.Repositories -{ - public class CategoriesRepository : BaseRepository, ICategoriesRepository - { - public CategoriesRepository(FinancialHubContext context) : base(context) - { - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs b/src/api/core/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs deleted file mode 100644 index a0ee942..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Repositories/TransactionsRepository.cs +++ /dev/null @@ -1,31 +0,0 @@ -using FinancialHub.Core.Infra.Data.Contexts; - -namespace FinancialHub.Core.Infra.Data.Repositories -{ - public class TransactionsRepository : BaseRepository, ITransactionsRepository - { - public TransactionsRepository(FinancialHubContext context) : base(context) - { - } - - public override async Task CreateAsync(TransactionEntity obj) - { - #warning This is not a good practice, remove this later - if(obj == null) - { - throw new ArgumentNullException(nameof(obj)); - } - - obj.Category = null; - obj.Balance = null; - return await base.CreateAsync(obj); - } - - public override async Task UpdateAsync(TransactionEntity obj) - { - obj.Category = null; - obj.Balance = null; - return await base.UpdateAsync(obj); - } - } -} diff --git a/src/api/core/FinancialHub.Core.Infra.Data/Usings.cs b/src/api/core/FinancialHub.Core.Infra.Data/Usings.cs deleted file mode 100644 index 2879c47..0000000 --- a/src/api/core/FinancialHub.Core.Infra.Data/Usings.cs +++ /dev/null @@ -1,13 +0,0 @@ -// System namespaces -global using System; -global using System.Collections.Generic; -global using System.Threading.Tasks; - -// 3rd party namespaces -global using Microsoft.EntityFrameworkCore; - -// Domain project interface namespaces -global using FinancialHub.Core.Domain.Interfaces.Repositories; - -// Domain Project namespaces -global using FinancialHub.Core.Domain.Entities; \ No newline at end of file diff --git a/src/api/core/FinancialHub.Core.WebApi/Controllers/AccountsController.cs b/src/api/core/FinancialHub.Core.WebApi/Controllers/AccountsController.cs deleted file mode 100644 index cec6600..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/Controllers/AccountsController.cs +++ /dev/null @@ -1,97 +0,0 @@ -namespace FinancialHub.Core.WebApi.Controllers -{ - [ApiController] - [Route("[controller]")] - [Produces("application/json")] - [ProducesErrorResponseType(typeof(Exception))] - public class AccountsController : Controller - { - private readonly IAccountBalanceService accountBalanceService; - private readonly IAccountsService service; - - public AccountsController(IAccountBalanceService accountBalanceService,IAccountsService service) - { - this.accountBalanceService = accountBalanceService; - this.service = service; - } - - [HttpGet("{accountId}/balances")] - [ProducesResponseType(typeof(ListResponse), 200)] - public async Task GetAccountBalances([FromRoute] Guid accountId) - { - var result = await this.accountBalanceService.GetBalancesByAccountAsync(accountId); - - return Ok(new ListResponse(result.Data)); - } - - /// - /// Get all accounts of the system (will be changed to only one user) - /// - [HttpGet] - [ProducesResponseType(typeof(ListResponse), 200)] - public async Task GetMyAccounts() - { - var result = await service.GetAllByUserAsync("mock"); - - return Ok(new ListResponse(result.Data)); - } - - /// - /// Creates an account on database (will be changed to only one user) - /// - /// Account to be created - [HttpPost] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] - public async Task CreateAccount([FromBody] AccountModel account) - { - var result = await this.accountBalanceService.CreateAsync(account); - - if (result.HasError) - { - return StatusCode( - result.Error.Code, - new ValidationErrorResponse(result.Error.Message) - ); - } - - return Ok(new SaveResponse(result.Data)); - } - - /// - /// Updates an existing account on database - /// - /// id of the account - /// account changes - [HttpPut("{id}")] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(NotFoundErrorResponse), 404)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] - public async Task UpdateAccount([FromRoute] Guid id, [FromBody] AccountModel account) - { - var response = await service.UpdateAsync(id, account); - - if (response.HasError) - { - return StatusCode( - response.Error.Code, - new ValidationErrorResponse(response.Error.Message) - ); - } - - return Ok(new SaveResponse(response.Data)); - } - - /// - /// Deletes an existing account on database - /// - /// id of the account - [NonAction] - [HttpDelete("{id}")] - public async Task DeleteAccount([FromRoute] Guid id) - { - await accountBalanceService.DeleteAsync(id); - return NoContent(); - } - } -} diff --git a/src/api/core/FinancialHub.Core.WebApi/Controllers/BalancesController.cs b/src/api/core/FinancialHub.Core.WebApi/Controllers/BalancesController.cs deleted file mode 100644 index 32975ca..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/Controllers/BalancesController.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace FinancialHub.Core.WebApi.Controllers -{ - [ApiController] - [Route("[controller]")] - [Produces("application/json")] - [ProducesErrorResponseType(typeof(Exception))] - public class BalancesController : Controller - { - private readonly IBalancesService service; - - public BalancesController(IBalancesService service) - { - this.service = service; - } - - [HttpPost] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] - public async Task CreateBalance([FromBody] BalanceModel balance) - { - var result = await this.service.CreateAsync(balance); - - if (result.HasError) - { - return StatusCode( - result.Error.Code, - new ValidationErrorResponse(result.Error.Message) - ); - } - - return Ok(new SaveResponse(result.Data)); - } - - [HttpPut("{id}")] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(NotFoundErrorResponse), 404)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] - public async Task UpdateBalance([FromRoute] Guid id, [FromBody] BalanceModel balance) - { - var response = await this.service.UpdateAsync(id, balance); - - if (response.HasError) - { - return StatusCode( - response.Error.Code, - new ValidationErrorResponse(response.Error.Message) - ); - } - - return Ok(new SaveResponse(response.Data)); - } - - [NonAction] - [HttpDelete("{id}")] - public async Task DeleteBalance([FromRoute] Guid id) - { - await this.service.DeleteAsync(id); - return NoContent(); - } - } -} diff --git a/src/api/core/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs b/src/api/core/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs deleted file mode 100644 index 4d7ffc5..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/Controllers/CategoriesController.cs +++ /dev/null @@ -1,83 +0,0 @@ -namespace FinancialHub.Core.WebApi.Controllers -{ - [ApiController] - [Route("[controller]")] - [Produces("application/json")] - public class CategoriesController : Controller - { - private readonly ICategoriesService service; - - public CategoriesController(ICategoriesService service) - { - this.service = service; - } - - /// - /// Get all categorys of the system (will be changed to only one user) - /// - [HttpGet] - [ProducesResponseType(typeof(ListResponse), 200)] - public async Task GetMyCategories() - { - var result = await service.GetAllByUserAsync("mock"); - - return Ok(new ListResponse(result.Data)); - } - - /// - /// Creates an category on database (will be changed to only one user) - /// - /// Account to be created - [HttpPost] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] - public async Task CreateCategory([FromBody] CategoryModel category) - { - var result = await service.CreateAsync(category); - - if (result.HasError) - { - return StatusCode( - result.Error.Code, - new ValidationErrorResponse(result.Error.Message) - ); - } - - return Ok(new SaveResponse(result.Data)); - } - - /// - /// Updates an existing category on database - /// - /// id of the category - /// category changes - [HttpPut("{id}")] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] - public async Task UpdateCategory([FromRoute] Guid id, [FromBody] CategoryModel category) - { - var result = await service.UpdateAsync(id, category); - - if (result.HasError) - { - return StatusCode( - result.Error.Code, - new ValidationErrorResponse(result.Error.Message) - ); - } - - return Ok(new SaveResponse(result.Data)); - } - - /// - /// Deletes an existing category on database - /// - /// id of the category - [HttpDelete("{id}")] - public async Task DeleteCategory([FromRoute] Guid id) - { - await service.DeleteAsync(id); - return NoContent(); - } - } -} diff --git a/src/api/core/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs b/src/api/core/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs deleted file mode 100644 index 65642fa..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/Controllers/TransactionsController.cs +++ /dev/null @@ -1,87 +0,0 @@ -using FinancialHub.Core.Domain.Filters; - -namespace FinancialHub.Core.WebApi.Controllers -{ - [ApiController] - [Route("[controller]")] - [Produces("application/json")] - public class TransactionsController : Controller - { - private readonly ITransactionsService service; - private readonly ITransactionBalanceService transactionBalanceService; - - public TransactionsController(ITransactionsService service, ITransactionBalanceService transactionBalanceService) - { - this.service = service; - this.transactionBalanceService = transactionBalanceService; - } - - /// - /// Get all transaction of the system (will be changed to only one user and added filters) - /// - [HttpGet] - [ProducesResponseType(typeof(ListResponse), 200)] - public async Task GetMyTransactions([FromQuery] TransactionFilter filter) - { - var response = await service.GetAllByUserAsync("mock", filter); - return Ok(new ListResponse(response.Data)); - } - - /// - /// Creates an transaction on database (will be changed to only one user) - /// - /// Transaction to be created - [HttpPost] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] - public async Task CreateTransaction([FromBody] TransactionModel transaction) - { - var result = await this.transactionBalanceService.CreateTransactionAsync(transaction); - - if (result.HasError) - { - return StatusCode( - result.Error.Code, - new ValidationErrorResponse(result.Error.Message) - ); - } - - return Ok(new SaveResponse(result.Data)); - } - - /// - /// Updates an existing transaction on database - /// - /// id of the transaction - /// transaction changes - [HttpPut("{id}")] - [ProducesResponseType(typeof(SaveResponse), 200)] - [ProducesResponseType(typeof(ValidationErrorResponse), 400)] - public async Task UpdateTransaction([FromRoute] Guid id, [FromBody] TransactionModel transaction) - { - var result = await this.service.UpdateAsync(id, transaction); - - if (result.HasError) - { - return StatusCode( - result.Error.Code, - new ValidationErrorResponse(result.Error.Message) - ); - } - - return Ok(new SaveResponse(result.Data)); - } - - /// - /// Deletes an existing transaction on database - /// - /// id of the transaction - [HttpDelete("{id}")] - [ProducesResponseType(204)] - public async Task DeleteTransaction([FromRoute] Guid id) - { - await transactionBalanceService.DeleteTransactionAsync(id); - return NoContent(); - } - } -} diff --git a/src/api/core/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs b/src/api/core/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs deleted file mode 100644 index d40054f..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/Extensions/Configurations/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using FluentValidation; -using FluentValidation.AspNetCore; -using Microsoft.OpenApi.Models; - -namespace FinancialHub.Core.WebApi.Extensions.Configurations -{ - public static class IServiceCollectionExtensions - { - public static IServiceCollection AddApiConfigurations(this IServiceCollection services) - { - services.AddControllers(); - services.AddApiVersioning(config => - { - config.DefaultApiVersion = new ApiVersion(1, 0); - config.AssumeDefaultVersionWhenUnspecified = true; - config.ReportApiVersions = true; - }); - - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "Financial Hub WebApi", Version = "v1" }); - }); - - return services; - } - - public static IServiceCollection AddValidators(this IServiceCollection services) - { - services.AddFluentValidation(x => - { - x.AutomaticValidationEnabled = true; - x.DisableDataAnnotationsValidation = true; - }); - - return services; - } - } -} diff --git a/src/api/core/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj b/src/api/core/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj deleted file mode 100644 index eeb3583..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/FinancialHub.Core.WebApi.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - - net6.0 - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - PreserveNewest - true - PreserveNewest - - - - diff --git a/src/api/core/FinancialHub.Core.WebApi/Program.cs b/src/api/core/FinancialHub.Core.WebApi/Program.cs deleted file mode 100644 index 0bf61e1..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/Program.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace FinancialHub.Core.WebApi -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } -} diff --git a/src/api/core/FinancialHub.Core.WebApi/Properties/launchSettings.json b/src/api/core/FinancialHub.Core.WebApi/Properties/launchSettings.json deleted file mode 100644 index ac233d1..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/Properties/launchSettings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:62772", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "FinancialHub.WebApi": { - "commandName": "Project", - "dotnetRunMessages": "true", - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/src/api/core/FinancialHub.Core.WebApi/Startup.cs b/src/api/core/FinancialHub.Core.WebApi/Startup.cs deleted file mode 100644 index de08184..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/Startup.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using FinancialHub.Core.WebApi.Extensions.Configurations; -using FinancialHub.Core.Infra.Data.Extensions.Configurations; -using FinancialHub.Core.Application.Extensions.Configurations; - -namespace FinancialHub.Core.WebApi -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - public void ConfigureServices(IServiceCollection services) - { - services.AddApiConfigurations(); - - services.AddCoreServices(); - services.AddRepositories(Configuration); - - services.AddMvc().AddNewtonsoftJson(); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Financial Hub WebApi v1")); - } - - app.UseRouting(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/src/api/core/FinancialHub.Core.WebApi/Usings.cs b/src/api/core/FinancialHub.Core.WebApi/Usings.cs deleted file mode 100644 index 9b4689b..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/Usings.cs +++ /dev/null @@ -1,16 +0,0 @@ -// System namespaces -global using System; -global using System.Threading.Tasks; - -// Asp.Net namespaces -global using Microsoft.AspNetCore.Mvc; - -// Domain Models namespaces -global using FinancialHub.Core.Domain.Models; - -// Domain Interfaces namespaces -global using FinancialHub.Core.Domain.Interfaces.Services; - -// Common Response namespaces -global using FinancialHub.Common.Responses.Success; -global using FinancialHub.Common.Responses.Errors; \ No newline at end of file diff --git a/src/api/core/FinancialHub.Core.WebApi/appsettings.Development.json b/src/api/core/FinancialHub.Core.WebApi/appsettings.Development.json deleted file mode 100644 index 9398fef..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/appsettings.Development.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "ConnectionStrings": { - "default": "Server=localhost,1450;Database=financial_hub;user=sa;pwd=P@ssw0rd!;" - }, - "AllowedHosts": "*" -} diff --git a/src/api/core/FinancialHub.Core.WebApi/appsettings.Testing.json b/src/api/core/FinancialHub.Core.WebApi/appsettings.Testing.json deleted file mode 100644 index 9398fef..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/appsettings.Testing.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "ConnectionStrings": { - "default": "Server=localhost,1450;Database=financial_hub;user=sa;pwd=P@ssw0rd!;" - }, - "AllowedHosts": "*" -} diff --git a/src/api/core/FinancialHub.Core.WebApi/appsettings.json b/src/api/core/FinancialHub.Core.WebApi/appsettings.json deleted file mode 100644 index 282da1a..0000000 --- a/src/api/core/FinancialHub.Core.WebApi/appsettings.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "ConnectionStrings": { - "default": "" - }, - "AllowedHosts": "*" -} diff --git a/src/api/core/FinancialHub.Core.sln b/src/api/core/FinancialHub.Core.sln deleted file mode 100644 index 8681ce1..0000000 --- a/src/api/core/FinancialHub.Core.sln +++ /dev/null @@ -1,119 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31912.275 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{B00013E6-DB9F-415A-B542-6D32DA258EB2}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{BEE32E30-21CF-489B-B208-3D053E4966A8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{FB841C40-3211-443F-AC95-CD5796CF4FB3}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{0F151C31-117F-438E-A5B5-9EE1D669BE27}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{3B96E644-4E1A-4C2F-8F3C-E4843C921B92}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infra", "Infra", "{15C0C14F-DA06-46BB-A8B0-4BA5D6372777}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application", "FinancialHub.Core.Application\FinancialHub.Core.Application.csproj", "{962A60D1-2373-4086-9DF5-7C77C1335D7E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain", "FinancialHub.Core.Domain\FinancialHub.Core.Domain.csproj", "{D17C1B75-3E9D-4AE7-BAB1-336C00321846}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data", "FinancialHub.Core.Infra.Data\FinancialHub.Core.Infra.Data.csproj", "{632D8DE1-86E8-4668-B093-420CA2933B66}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi", "FinancialHub.Core.WebApi\FinancialHub.Core.WebApi.csproj", "{1766B5F3-D24F-41C2-AA2F-836E74464549}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common", "..\common\FinancialHub.Common\FinancialHub.Common.csproj", "{27BAF3E9-E2C2-4897-9398-96F4B3B9656E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Common.Tests", "..\..\..\tests\common\FinancialHub.Common.Tests\FinancialHub.Common.Tests.csproj", "{67482F4E-58F2-46CC-A5EB-55C5077BFF46}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Application.Tests", "..\..\..\tests\core\FinancialHub.Core.Application.Tests\FinancialHub.Core.Application.Tests.csproj", "{CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Domain.Tests", "..\..\..\tests\core\FinancialHub.Core.Domain.Tests\FinancialHub.Core.Domain.Tests.csproj", "{10742A75-DA97-47E8-A13E-E17C8DF56828}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.Infra.Data.Tests", "..\..\..\tests\core\FinancialHub.Core.Infra.Data.Tests\FinancialHub.Core.Infra.Data.Tests.csproj", "{C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.WebApi.Tests", "..\..\..\tests\core\FinancialHub.Core.WebApi.Tests\FinancialHub.Core.WebApi.Tests.csproj", "{61A63487-07EF-4713-A0F8-D5F3B1AD3033}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinancialHub.Core.IntegrationTests", "..\..\..\tests\core\FinancialHub.Core.IntegrationTests\FinancialHub.Core.IntegrationTests.csproj", "{E7839395-1741-4DE8-8CC3-6D7491786A25}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A6BF8521-37BF-4275-901D-9CF454CFFADC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {962A60D1-2373-4086-9DF5-7C77C1335D7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {962A60D1-2373-4086-9DF5-7C77C1335D7E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {962A60D1-2373-4086-9DF5-7C77C1335D7E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {962A60D1-2373-4086-9DF5-7C77C1335D7E}.Release|Any CPU.Build.0 = Release|Any CPU - {D17C1B75-3E9D-4AE7-BAB1-336C00321846}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D17C1B75-3E9D-4AE7-BAB1-336C00321846}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D17C1B75-3E9D-4AE7-BAB1-336C00321846}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D17C1B75-3E9D-4AE7-BAB1-336C00321846}.Release|Any CPU.Build.0 = Release|Any CPU - {632D8DE1-86E8-4668-B093-420CA2933B66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {632D8DE1-86E8-4668-B093-420CA2933B66}.Debug|Any CPU.Build.0 = Debug|Any CPU - {632D8DE1-86E8-4668-B093-420CA2933B66}.Release|Any CPU.ActiveCfg = Release|Any CPU - {632D8DE1-86E8-4668-B093-420CA2933B66}.Release|Any CPU.Build.0 = Release|Any CPU - {1766B5F3-D24F-41C2-AA2F-836E74464549}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1766B5F3-D24F-41C2-AA2F-836E74464549}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1766B5F3-D24F-41C2-AA2F-836E74464549}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1766B5F3-D24F-41C2-AA2F-836E74464549}.Release|Any CPU.Build.0 = Release|Any CPU - {27BAF3E9-E2C2-4897-9398-96F4B3B9656E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {27BAF3E9-E2C2-4897-9398-96F4B3B9656E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {27BAF3E9-E2C2-4897-9398-96F4B3B9656E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {27BAF3E9-E2C2-4897-9398-96F4B3B9656E}.Release|Any CPU.Build.0 = Release|Any CPU - {67482F4E-58F2-46CC-A5EB-55C5077BFF46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {67482F4E-58F2-46CC-A5EB-55C5077BFF46}.Debug|Any CPU.Build.0 = Debug|Any CPU - {67482F4E-58F2-46CC-A5EB-55C5077BFF46}.Release|Any CPU.ActiveCfg = Release|Any CPU - {67482F4E-58F2-46CC-A5EB-55C5077BFF46}.Release|Any CPU.Build.0 = Release|Any CPU - {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89}.Release|Any CPU.Build.0 = Release|Any CPU - {10742A75-DA97-47E8-A13E-E17C8DF56828}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {10742A75-DA97-47E8-A13E-E17C8DF56828}.Debug|Any CPU.Build.0 = Debug|Any CPU - {10742A75-DA97-47E8-A13E-E17C8DF56828}.Release|Any CPU.ActiveCfg = Release|Any CPU - {10742A75-DA97-47E8-A13E-E17C8DF56828}.Release|Any CPU.Build.0 = Release|Any CPU - {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A}.Release|Any CPU.Build.0 = Release|Any CPU - {61A63487-07EF-4713-A0F8-D5F3B1AD3033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {61A63487-07EF-4713-A0F8-D5F3B1AD3033}.Debug|Any CPU.Build.0 = Debug|Any CPU - {61A63487-07EF-4713-A0F8-D5F3B1AD3033}.Release|Any CPU.ActiveCfg = Release|Any CPU - {61A63487-07EF-4713-A0F8-D5F3B1AD3033}.Release|Any CPU.Build.0 = Release|Any CPU - {E7839395-1741-4DE8-8CC3-6D7491786A25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E7839395-1741-4DE8-8CC3-6D7491786A25}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E7839395-1741-4DE8-8CC3-6D7491786A25}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E7839395-1741-4DE8-8CC3-6D7491786A25}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {FB841C40-3211-443F-AC95-CD5796CF4FB3} = {BEE32E30-21CF-489B-B208-3D053E4966A8} - {0F151C31-117F-438E-A5B5-9EE1D669BE27} = {BEE32E30-21CF-489B-B208-3D053E4966A8} - {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} = {BEE32E30-21CF-489B-B208-3D053E4966A8} - {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} = {BEE32E30-21CF-489B-B208-3D053E4966A8} - {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} = {15C0C14F-DA06-46BB-A8B0-4BA5D6372777} - {962A60D1-2373-4086-9DF5-7C77C1335D7E} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} - {D17C1B75-3E9D-4AE7-BAB1-336C00321846} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} - {632D8DE1-86E8-4668-B093-420CA2933B66} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} - {1766B5F3-D24F-41C2-AA2F-836E74464549} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} - {27BAF3E9-E2C2-4897-9398-96F4B3B9656E} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} - {67482F4E-58F2-46CC-A5EB-55C5077BFF46} = {B00013E6-DB9F-415A-B542-6D32DA258EB2} - {CAE3A98E-1AB8-41C2-BB5E-318C30D64D89} = {FB841C40-3211-443F-AC95-CD5796CF4FB3} - {10742A75-DA97-47E8-A13E-E17C8DF56828} = {0F151C31-117F-438E-A5B5-9EE1D669BE27} - {C7F8A285-8318-4FFC-B1B0-AF4A10020E2A} = {C0D9D883-C3CC-4A74-B373-CAFD6FC4A32F} - {61A63487-07EF-4713-A0F8-D5F3B1AD3033} = {3B96E644-4E1A-4C2F-8F3C-E4843C921B92} - {E7839395-1741-4DE8-8CC3-6D7491786A25} = {BEE32E30-21CF-489B-B208-3D053E4966A8} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {9A4C4A77-82DC-47E2-AA98-E741B329A3E8} - EndGlobalSection -EndGlobal From 0b7d42b44e37a57ee31df1cc1e4a696b893f74cc Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Date: Sat, 24 Feb 2024 01:48:26 -0300 Subject: [PATCH 26/30] Remove core project from pipeline --- .github/workflows/matrix_test_result.yml | 1 - .github/workflows/tests_workflow.yml | 8 -------- 2 files changed, 9 deletions(-) diff --git a/.github/workflows/matrix_test_result.yml b/.github/workflows/matrix_test_result.yml index eade0c3..e21fcb1 100644 --- a/.github/workflows/matrix_test_result.yml +++ b/.github/workflows/matrix_test_result.yml @@ -21,7 +21,6 @@ jobs: strategy: matrix: project: - - core - auth env: project-dir: ${{ inputs.dir }}/${{ matrix.project }} diff --git a/.github/workflows/tests_workflow.yml b/.github/workflows/tests_workflow.yml index baf1d79..cb219f5 100644 --- a/.github/workflows/tests_workflow.yml +++ b/.github/workflows/tests_workflow.yml @@ -19,11 +19,3 @@ jobs: with: dir: ${{ inputs.dir }} dotnet-version: ${{ inputs.dotnet-version }} - - coverage-report: - needs: test-result - uses: ./.github/workflows/coverage_report.yml - secrets: inherit - with: - dir: ${{ inputs.dir }} - dotnet-version: ${{ inputs.dotnet-version }} From 74189e26c0e638e82647552bb7c32d8f55a52252 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Date: Sat, 24 Feb 2024 01:54:45 -0300 Subject: [PATCH 27/30] Remove core tests --- ...FinancialHub.Core.Application.Tests.csproj | 25 -- .../AccountBalanceServiceTests.create.cs | 122 ------ .../AccountBalanceServiceTests.cs | 33 -- .../AccountBalanceServiceTests.delete.cs | 141 ------- .../Accounts/AccountsServiceTests.create.cs | 36 -- .../Services/Accounts/AccountsServiceTests.cs | 53 --- .../Accounts/AccountsServiceTests.delete.cs | 22 - .../Accounts/AccountsServiceTests.get.cs | 33 -- .../Accounts/AccountsServiceTests.update.cs | 71 ---- .../Balances/BalancesServiceTests.create.cs | 92 ----- .../Services/Balances/BalancesServiceTests.cs | 72 ---- .../Balances/BalancesServiceTests.delete.cs | 36 -- .../Balances/BalancesServiceTests.get.cs | 68 ---- .../Balances/BalancesServiceTests.update.cs | 147 ------- .../BalancesServiceTests.updateamount.cs | 82 ---- .../CategoriesServiceTests.create.cs | 36 -- .../Categories/CategoriesServiceTests.cs | 53 --- .../CategoriesServiceTests.delete.cs | 23 -- .../Categories/CategoriesServiceTests.get.cs | 34 -- .../CategoriesServiceTests.update.cs | 71 ---- .../BaseTransactionBalanceTests.cs | 34 -- .../TransactionBalanceTests.create.cs | 114 ------ .../TransactionBalanceTests.cs | 9 - .../TransactionBalanceTests.delete.cs | 153 ------- .../TransactionBalanceTests.update.cs | 131 ------ .../TransactionBalanceTests.updateamount.cs | 378 ------------------ .../TransactionsServiceTests.create.cs | 90 ----- .../Transactions/TransactionsServiceTests.cs | 70 ---- .../TransactionsServiceTests.delete.cs | 135 ------- .../TransactionsServiceTests.get.cs | 72 ---- .../TransactionsServiceTests.update.cs | 130 ------ .../Usings.cs | 21 - .../Validators/AccountValidatorTests.cs | 83 ---- .../Validators/BalanceValidatorTests.cs | 83 ---- .../Validators/CategoryValidatorTests.cs | 83 ---- .../Validators/TransactionValidatorTests.cs | 84 ---- .../Entities/BalanceEntityAssert.cs | 19 - .../Assertions/Models/AccountModelAssert.cs | 12 - .../Assertions/Models/BalanceModelAssert.cs | 19 - .../Assertions/Models/CategoryModelAssert.cs | 12 - .../Models/TransactionModelAssert.cs | 17 - .../Builders/Entities/AccountEntityBuilder.cs | 30 -- .../Builders/Entities/BalanceEntityBuilder.cs | 49 --- .../Entities/CategoryEntityBuilder.cs | 30 -- .../Entities/TransactionEntityBuilder.cs | 90 ----- .../Builders/Models/AccountModelBuilder.cs | 30 -- .../Builders/Models/BalanceModelBuilder.cs | 49 --- .../Builders/Models/CategoryModelBuilder.cs | 30 -- .../Models/TransactionModelBuilder.cs | 84 ---- .../FinancialHub.Core.Domain.Tests.csproj | 26 -- .../Queries/TransactionQueryTests.cs | 209 ---------- .../FinancialHub.Core.Domain.Tests/Usings.cs | 15 - .../FinancialHub.Core.Infra.Data.Tests.csproj | 25 -- .../Accounts/AccountsRepositoryTests.cs | 16 - .../BalancesRepositoryTests.amount.cs | 95 ----- .../BalancesRepositoryTests.create.cs | 19 - .../Balances/BalancesRepositoryTests.cs | 25 -- .../Base/BaseRepositoryTests.create.cs | 60 --- .../Repositories/Base/BaseRepositoryTests.cs | 95 ----- .../Base/BaseRepositoryTests.delete.cs | 34 -- .../Base/BaseRepositoryTests.get.cs | 115 ------ .../Base/BaseRepositoryTests.update.cs | 38 -- .../Categories/CategoriesRepositoryTests.cs | 16 - .../TransactionsRepositoryTests.create.cs | 185 --------- .../TransactionsRepositoryTests.cs | 71 ---- .../TransactionsRepositoryTests.delete.cs | 41 -- .../TransactionsRepositoryTests.update.cs | 121 ------ .../Usings.cs | 15 - .../Base/BaseControllerTests.cs | 33 -- .../Controllers/AccountsControllerTests.cs | 164 -------- .../Controllers/BalancesControllerTests.cs | 193 --------- .../Controllers/CategoriesControllerTests.cs | 134 ------- .../TransactionsControllerTests.cs | 214 ---------- .../Extensions/HttpClientExtensions.cs | 24 -- .../HttpResponseMessageExtensions.cs | 28 -- .../FinancialHub.Core.IntegrationTests.csproj | 38 -- .../Setup/FinancialHubFixture.cs | 86 ---- .../Usings.cs | 39 -- .../AccountsControllerTests.create.cs | 58 --- .../Accounts/AccountsControllerTests.cs | 28 -- .../AccountsControllerTests.delete.cs | 17 - .../Accounts/AccountsControllerTests.get.cs | 30 -- .../AccountsControllerTests.update.cs | 60 --- .../BalancesControllerTests.create.cs | 57 --- .../Balances/BalancesControllerTests.cs | 26 -- .../BalancesControllerTests.delete.cs | 16 - .../BalancesControllerTests.update.cs | 58 --- .../CategoriesControllerTests.create.cs | 58 --- .../Categories/CategoriesControllerTests.cs | 24 -- .../CategoriesControllerTests.delete.cs | 17 - .../CategoriesControllerTests.get.cs | 30 -- .../CategoriesControllerTests.update.cs | 60 --- .../TransactionsControllerTests.create.cs | 58 --- .../TransactionsControllerTests.cs | 26 -- .../TransactionsControllerTests.delete.cs | 17 - .../TransactionsControllerTests.get.cs | 32 -- .../TransactionsControllerTests.update.cs | 60 --- .../FinancialHub.Core.WebApi.Tests.csproj | 23 -- .../FinancialHub.Core.WebApi.Tests/Usings.cs | 27 -- 99 files changed, 6347 deletions(-) delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Usings.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs delete mode 100644 tests/core/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs delete mode 100644 tests/core/FinancialHub.Core.Domain.Tests/Usings.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.Infra.Data.Tests/Usings.cs delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs delete mode 100644 tests/core/FinancialHub.Core.IntegrationTests/Usings.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj delete mode 100644 tests/core/FinancialHub.Core.WebApi.Tests/Usings.cs diff --git a/tests/core/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj b/tests/core/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj deleted file mode 100644 index 6e4abe6..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/FinancialHub.Core.Application.Tests.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net6.0 - enable - - false - - - - - - - - - - - - - - - - - - diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs deleted file mode 100644 index 2d65c4a..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.create.cs +++ /dev/null @@ -1,122 +0,0 @@ -using FinancialHub.Core.Domain.Tests.Assertions.Models; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class AccountBalanceServiceTests - { - [Test] - public async Task CreateAsync_CreatesAccount() - { - var account = this.accountModelBuilder.Generate(); - - this.accountsService - .Setup(x => x.CreateAsync(account)) - .ReturnsAsync(account) - .Verifiable(); - this.balanceService - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await - Task.FromResult( - new ServiceResult(x) - ) - ) - .Verifiable(); - - await this.service.CreateAsync(account); - - this.accountsService.Verify(x => x.CreateAsync(account),Times.Once); - } - - [Test] - public async Task CreateAsync_CreatesDefaultBalance() - { - var account = this.accountModelBuilder.Generate(); - - this.accountsService - .Setup(x => x.CreateAsync(account)) - .ReturnsAsync(account) - .Verifiable(); - this.balanceService - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await - Task.FromResult( - new ServiceResult(x) - ) - ) - .Verifiable(); - - await this.service.CreateAsync(account); - this.balanceService.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); - } - - [Test] - public async Task CreateAsync_ValidAccount_ReturnsCreatedAccount() - { - var account = this.accountModelBuilder.Generate(); - - this.accountsService - .Setup(x => x.CreateAsync(account)) - .ReturnsAsync(account) - .Verifiable(); - this.balanceService - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await - Task.FromResult( - new ServiceResult(x) - ) - ) - .Verifiable(); - - var result = await this.service.CreateAsync(account); - - Assert.IsFalse(result.HasError); - AccountModelAssert.Equal(account, result.Data!); - } - - [Test] - public async Task CreateAsync_ErrorOnCreateAccount_ReturnsError() - { - var account = this.accountModelBuilder.Generate(); - var error = new ServiceError(1,"Account Error"); - - this.accountsService - .Setup(x => x.CreateAsync(account)) - .ReturnsAsync(account) - .Verifiable(); - this.balanceService - .Setup(x => x.CreateAsync(It.IsAny())) - .ReturnsAsync(error) - .Verifiable(); - - var result = await this.service.CreateAsync(account); - - Assert.IsTrue(result.HasError); - Assert.AreEqual(error.Message, result.Error!.Message); - } - - [Test] - public async Task CreateAsync_ErrorOnCreateDefaultBalance_ReturnsError() - { - var account = this.accountModelBuilder.Generate(); - var error = new ServiceError(1, "Balance Error"); - - this.accountsService - .Setup(x => x.CreateAsync(account)) - .ReturnsAsync(error) - .Verifiable(); - this.balanceService - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await - Task.FromResult( - new ServiceResult(x) - ) - ) - .Verifiable(); - - var result = await this.service.CreateAsync(account); - - Assert.IsTrue(result.HasError); - Assert.AreEqual(error.Message, result.Error!.Message); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs deleted file mode 100644 index 1e4d94e..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -using FinancialHub.Core.Domain.Interfaces.Services; -using FinancialHub.Core.Application.Services; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class AccountBalanceServiceTests - { - protected Random random; - protected AccountModelBuilder accountModelBuilder; - protected BalanceModelBuilder balanceModelBuilder; - - private IAccountBalanceService service; - - private Mock balanceService; - private Mock accountsService; - - [SetUp] - public void Setup() - { - this.balanceService = new Mock(); - this.accountsService = new Mock(); - this.service = new AccountBalanceService( - balanceService.Object, - accountsService.Object - ); - - this.random = new Random(); - - this.accountModelBuilder = new AccountModelBuilder(); - this.balanceModelBuilder = new BalanceModelBuilder(); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs deleted file mode 100644 index f4ea8b5..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/AccountBalance/AccountBalanceServiceTests.delete.cs +++ /dev/null @@ -1,141 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class AccountBalanceServiceTests - { - [Test] - public async Task DeleteAsync_RemovesBalances() - { - var expectedResult = random.Next(1, 100); - var account = this.accountModelBuilder.Generate(); - var balances = this.balanceModelBuilder - .WithAccount(account) - .Generate(expectedResult); - - this.accountsService - .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(0) - .Verifiable(); - this.balanceService - .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(balances) - .Verifiable(); - this.balanceService - .Setup(x => x.DeleteAsync(It.IsAny())) - .ReturnsAsync(1) - .Verifiable(); - - var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); - - Assert.AreEqual(expectedResult, result.Data); - - this.balanceService.Verify(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault()),Times.Once); - this.balanceService.Verify(x => x.DeleteAsync(It.IsAny()),Times.Exactly(expectedResult)); - } - - [Test] - public async Task DeleteAsync_RemovesAccount() - { - var account = this.accountModelBuilder.Generate(); - var balances = this.balanceModelBuilder - .WithAccount(account) - .Generate(0); - - this.accountsService - .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(1) - .Verifiable(); - - this.balanceService - .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(balances) - .Verifiable(); - - var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); - - Assert.AreEqual(1, result.Data); - - this.accountsService.Verify(x => x.DeleteAsync(account.Id.GetValueOrDefault()), Times.Once); - } - - [Test] - public async Task DeleteAsync_AccountDeletionError_ReturnsError() - { - var expectedResult = new ServiceError(1,"Error"); - var account = this.accountModelBuilder.Generate(); - var balances = this.balanceModelBuilder - .WithAccount(account) - .Generate(0); - - this.accountsService - .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(expectedResult) - .Verifiable(); - this.balanceService - .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(balances) - .Verifiable(); - var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); - - Assert.IsTrue(result.HasError); - Assert.AreEqual(expectedResult,result.Error); - Assert.AreEqual(0, result.Data); - } - - [Test] - public async Task DeleteAsync_BalanceDeletionError_ReturnsError() - { - var expectedResult = new ServiceError(1, "Error"); - var account = this.accountModelBuilder.Generate(); - var balances = this.balanceModelBuilder - .WithAccount(account) - .Generate(1); - - this.accountsService - .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(1) - .Verifiable(); - this.balanceService - .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(balances) - .Verifiable(); - this.balanceService - .Setup(x => x.DeleteAsync(It.IsAny())) - .ReturnsAsync(expectedResult) - .Verifiable(); - - var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); - - Assert.IsTrue(result.HasError); - Assert.AreEqual(expectedResult, result.Error); - Assert.AreEqual(0, result.Data); - } - - [Test] - public async Task DeleteAsync_Success_ReturnsRemovedBalancesAndAccount() - { - var expectedResult = random.Next(1, 100); - var account = this.accountModelBuilder.Generate(); - var balances = this.balanceModelBuilder - .WithAccount(account) - .Generate(expectedResult); - - this.accountsService - .Setup(x => x.DeleteAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(1) - .Verifiable(); - this.balanceService - .Setup(x => x.GetAllByAccountAsync(account.Id.GetValueOrDefault())) - .ReturnsAsync(balances) - .Verifiable(); - this.balanceService - .Setup(x => x.DeleteAsync(It.IsAny())) - .ReturnsAsync(1) - .Verifiable(); - - var result = await this.service.DeleteAsync(account.Id.GetValueOrDefault()); - - Assert.IsFalse(result.HasError); - Assert.AreEqual(expectedResult + 1, result.Data); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs deleted file mode 100644 index 753691b..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.create.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class AccountsServiceTests - { - [Test] - [TestCase(Description = "Create valid account", Category = "Create")] - public async Task CreateAsync_ValidAccountModel_ReturnsAccountModel() - { - var model = this.accountModelBuilder.Generate(); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - - var result = await this.service.CreateAsync(model); - - Assert.IsNotNull(result.Data); - Assert.IsInstanceOf>(result); - - this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); - this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); - this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs deleted file mode 100644 index 6ec249a..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.cs +++ /dev/null @@ -1,53 +0,0 @@ -using AutoMapper; -using FinancialHub.Core.Domain.Interfaces.Mappers; -using FinancialHub.Core.Domain.Interfaces.Repositories; -using FinancialHub.Core.Domain.Interfaces.Services; -using FinancialHub.Core.Domain.Tests.Builders.Entities; -using FinancialHub.Core.Application.Mappers; -using FinancialHub.Core.Application.Services; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class AccountsServiceTests - { - protected Random random; - protected AccountEntityBuilder accountEntityBuilder; - protected AccountModelBuilder accountModelBuilder; - - private IAccountsService service; - - private IMapper mapper; - private Mock mapperWrapper; - private Mock repository; - - private void MockMapper() - { - mapper = new MapperConfiguration(mc => - { - mc.AddProfile(new FinancialHubAutoMapperProfile()); - } - ).CreateMapper(); - - this.mapperWrapper = new Mock(); - } - - [SetUp] - public void Setup() - { - this.MockMapper(); - - this.repository = new Mock(); - this.service = new AccountsService(mapperWrapper.Object,repository.Object); - - this.random = new Random(); - - this.accountEntityBuilder = new AccountEntityBuilder(); - this.accountModelBuilder = new AccountModelBuilder(); - } - - public ICollection GenerateAccounts() - { - return this.accountEntityBuilder.Generate(random.Next(5,10)); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs deleted file mode 100644 index ead6140..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.delete.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class AccountsServiceTests - { - [Test] - public async Task DeleteAsync_RepositorySuccess_ReturnsAccountModel() - { - var expectedResult = random.Next(1,100); - var guid = Guid.NewGuid(); - this.repository - .Setup(x => x.DeleteAsync(guid)) - .Returns(async () => await Task.FromResult(expectedResult)) - .Verifiable(); - - var result = await this.service.DeleteAsync(guid); - - Assert.IsInstanceOf>(result); - Assert.AreEqual(expectedResult,result.Data); - this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs deleted file mode 100644 index 40621c5..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.get.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Linq; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class AccountsServiceTests - { - [Test] - [TestCase(Description = "Get by user sucess return",Category = "Get")] - public async Task GetByUsersAsync_ValidUser_ReturnsAccounts() - { - var entitiesMock = this.GenerateAccounts(); - - this.repository - .Setup(x => x.GetAllAsync()) - .ReturnsAsync(entitiesMock.ToArray()) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map>(It.IsAny>())) - .Returns>((ent) => this.mapper.Map>(ent)) - .Verifiable(); - - var result = await this.service.GetAllByUserAsync(string.Empty); - - Assert.IsInstanceOf>>(result); - Assert.IsFalse(result.HasError); - Assert.AreEqual(entitiesMock.Count, result.Data!.Count); - - this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); - this.repository.Verify(x => x.GetAllAsync(),Times.Once()); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs deleted file mode 100644 index 6e1435a..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Accounts/AccountsServiceTests.update.cs +++ /dev/null @@ -1,71 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class AccountsServiceTests - { - [Test] - [TestCase(Description = "Update valid account", Category = "Update")] - public async Task UpdateAsync_ValidAccountModel_ReturnsAccountModel() - { - var model = this.accountModelBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsNotNull(result); - Assert.IsInstanceOf>(result); - - this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); - - this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); - this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); - } - - [Test] - [TestCase(Description = "Update non existing account", Category = "Update")] - public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() - { - var id = Guid.NewGuid(); - var model = this.accountModelBuilder - .WithId(id) - .Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(default(AccountEntity)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - var result = await this.service.UpdateAsync(id, model); - - Assert.IsInstanceOf>(result); - Assert.IsTrue(result.HasError); - - this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs deleted file mode 100644 index bd902db..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.create.cs +++ /dev/null @@ -1,92 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class BalancesServiceTests - { - [Test] - public async Task CreateAsync_ValidatesIfAccountExists() - { - var model = this.balanceModelBuilder.Generate(); - - this.accountsRepository - .Setup(x => x.GetByIdAsync(model.AccountId)) - .ReturnsAsync(this.mapper.Map(model.Account)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.CreateAsync(model); - - this.accountsRepository.Verify(x => x.GetByIdAsync(model.AccountId), Times.Once); - } - - [Test] - public async Task CreateAsync_CreatesBalance() - { - var model = this.balanceModelBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.accountsRepository - .Setup(x => x.GetByIdAsync(model.AccountId)) - .ReturnsAsync(this.mapper.Map(model.Account)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.CreateAsync(model); - - this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); - } - - [Test] - public async Task CreateAsync_ValidBalanceModel_ReturnsBalanceModel() - { - var model = this.balanceModelBuilder.Generate(); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.accountsRepository - .Setup(x => x.GetByIdAsync(model.AccountId)) - .ReturnsAsync(this.mapper.Map(model.Account)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.CreateAsync(model); - - Assert.IsNotNull(result.Data); - Assert.IsInstanceOf>(result); - } - - [Test] - public async Task CreateAsync_InvalidAccountModel_ReturnsNotFoundError() - { - var model = this.balanceModelBuilder.Generate(); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.CreateAsync(model); - - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Account with id {model.AccountId}", result.Error!.Message); - - this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Never); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs deleted file mode 100644 index 975ad0c..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.cs +++ /dev/null @@ -1,72 +0,0 @@ -using AutoMapper; -using FinancialHub.Core.Domain.Interfaces.Mappers; -using FinancialHub.Core.Domain.Interfaces.Repositories; -using FinancialHub.Core.Domain.Interfaces.Services; -using FinancialHub.Core.Domain.Tests.Builders.Entities; -using FinancialHub.Core.Application.Mappers; -using FinancialHub.Core.Application.Services; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class BalancesServiceTests - { - protected Random random; - protected BalanceEntityBuilder balanceEntityBuilder; - protected BalanceModelBuilder balanceModelBuilder; - - private IBalancesService service; - - private IMapper mapper; - private Mock mapperWrapper; - private Mock repository; - private Mock accountsRepository; - - private void MockMapper() - { - mapper = new MapperConfiguration(mc => - { - mc.AddProfile(new FinancialHubAutoMapperProfile()); - } - ).CreateMapper(); - - this.mapperWrapper = new Mock(); - } - - [SetUp] - public void Setup() - { - this.MockMapper(); - - this.repository = new Mock(); - this.accountsRepository = new Mock(); - this.service = new BalancesService( - mapperWrapper.Object, - repository.Object, - accountsRepository.Object - ); - - this.random = new Random(); - - this.balanceEntityBuilder = new BalanceEntityBuilder(); - this.balanceModelBuilder = new BalanceModelBuilder(); - } - - private void SetUpMapper() - { - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - } - - public ICollection GenerateBalances() - { - return this.balanceEntityBuilder.Generate(random.Next(5, 10)); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs deleted file mode 100644 index efc29bb..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.delete.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class BalancesServiceTests - { - [Test] - public async Task DeleteAsync_RemovesBalance() - { - var expectedResult = random.Next(1, 100); - var guid = Guid.NewGuid(); - this.repository - .Setup(x => x.DeleteAsync(guid)) - .Returns(async () => await Task.FromResult(expectedResult)) - .Verifiable(); - - await this.service.DeleteAsync(guid); - - this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); - } - - [Test] - public async Task DeleteAsync_RepositorySuccess_ReturnsRemovedBalances() - { - var expectedResult = random.Next(1,100); - var guid = Guid.NewGuid(); - this.repository - .Setup(x => x.DeleteAsync(guid)) - .Returns(async () => await Task.FromResult(expectedResult)) - .Verifiable(); - - var result = await this.service.DeleteAsync(guid); - - Assert.IsInstanceOf>(result); - Assert.AreEqual(expectedResult,result.Data); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs deleted file mode 100644 index baf00f1..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.get.cs +++ /dev/null @@ -1,68 +0,0 @@ -using FinancialHub.Core.Domain.Tests.Assertions.Entities; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class BalancesServiceTests - { - [Test] - public async Task GetByAccountAsync_ValidAccount_ReturnsBalances() - { - var firstEntity = this.balanceEntityBuilder.Generate(); - var entitiesMock = this.balanceEntityBuilder - .WithAccount(firstEntity.Account) - .Generate(random.Next(5, 10)); - - this.repository - .Setup(x => x.GetAsync(It.IsAny>())) - .ReturnsAsync(entitiesMock.ToArray()) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map>(It.IsAny>())) - .Returns>((ent) => this.mapper.Map>(ent)) - .Verifiable(); - - var result = await this.service.GetAllByAccountAsync(firstEntity.Account.Id.GetValueOrDefault()); - - Assert.IsInstanceOf>>(result); - Assert.IsFalse(result.HasError); - Assert.AreEqual(entitiesMock.Count, result.Data!.Count); - - this.repository.Verify(x => x.GetAsync(It.IsAny>()), Times.Once); - } - - [Test] - public async Task GetByIdAsync_ValidId_ReturnsBalance() - { - var entity = this.balanceEntityBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(entity.Id.GetValueOrDefault())) - .ReturnsAsync(entity) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.GetByIdAsync(entity.Id.GetValueOrDefault()); - - Assert.IsInstanceOf>(result); - Assert.IsFalse(result.HasError); - BalanceEntityAssert.Equal(entity, result.Data!); - - this.repository.Verify(x => x.GetByIdAsync(entity.Id.GetValueOrDefault()), Times.Once); - } - - [Test] - public async Task GetByIdAsync_InvalidId_ReturnsNotFoundError() - { - var entity = this.balanceEntityBuilder.Generate(); - - this.SetUpMapper(); - - var result = await this.service.GetByIdAsync(entity.Id.GetValueOrDefault()); - - Assert.IsInstanceOf>(result); - Assert.IsTrue(result.HasError); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs deleted file mode 100644 index 1edef3a..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.update.cs +++ /dev/null @@ -1,147 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class BalancesServiceTests - { - [Test] - public async Task UpdateAsync_ValidatesIfAccountExists() - { - var model = this.balanceModelBuilder.Generate(); - - this.accountsRepository - .Setup(x => x.GetByIdAsync(model.AccountId)) - .ReturnsAsync(this.mapper.Map(model.Account)) - .Verifiable(); - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - this.accountsRepository.Verify(x => x.GetByIdAsync(model.AccountId), Times.Once); - } - - [Test] - public async Task UpdateAsync_ValidatesIfBalanceExists() - { - var model = this.balanceModelBuilder.Generate(); - var id = model.Id.GetValueOrDefault(); - this.repository - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(default(BalanceEntity)) - .Verifiable(); - - var result = await this.service.UpdateAsync(id, model); - - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {id}", result.Error!.Message); - this.repository.Verify(x => x.GetByIdAsync(id), Times.Once); - } - - [Test] - public async Task UpdateAsync_UpdatesBalance() - { - var model = this.balanceModelBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.accountsRepository - .Setup(x => x.GetByIdAsync(model.AccountId)) - .ReturnsAsync(this.mapper.Map(model.Account)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); - } - - [Test] - public async Task UpdateAsync_ValidBalanceModel_ReturnsBalanceModel() - { - var model = this.balanceModelBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.accountsRepository - .Setup(x => x.GetByIdAsync(model.AccountId)) - .ReturnsAsync(this.mapper.Map(model.Account)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsInstanceOf>(result); - Assert.IsNotNull(result.Data); - } - - [Test] - public async Task UpdateAsync_NonExistingBalanceId_ReturnsResultError() - { - var model = this.balanceModelBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(default(BalanceEntity)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsInstanceOf>(result); - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {model.Id}", result.Error!.Message); - - this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); - } - - [Test] - public async Task UpdateAsync_NonExistingAccountId_ReturnsResultError() - { - var model = this.balanceModelBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsInstanceOf>(result); - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Account with id {model.AccountId}", result.Error!.Message); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs deleted file mode 100644 index dac1633..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Balances/BalancesServiceTests.updateamount.cs +++ /dev/null @@ -1,82 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class BalancesServiceTests - { - [Test] - public async Task UpdateAmountAsync_UpdatesBalanceAmount() - { - var id = Guid.NewGuid(); - var model = this.balanceModelBuilder.WithId(id).Generate(); - var entity = this.mapper.Map(model); - var amount = this.random.Next(1000, 10000); - this.repository - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(entity); - - this.repository - .Setup(x => x.ChangeAmountAsync(id, amount)) - .ReturnsAsync(entity) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.UpdateAmountAsync(id, amount); - - this.repository.Verify(x => x.ChangeAmountAsync(id, amount), Times.Once); - } - - [Test] - public async Task UpdateAmountAsync_ValidBalanceModel_ReturnsBalanceModel() - { - var id = Guid.NewGuid(); - var model = this.balanceModelBuilder.WithId(id).Generate(); - var entity = this.mapper.Map(model); - var amount = this.random.Next(1000, 10000); - - this.repository - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(entity); - - this.repository - .Setup(x => x.ChangeAmountAsync(id, amount)) - .ReturnsAsync(entity); - - this.accountsRepository - .Setup(x => x.GetByIdAsync(model.AccountId)) - .ReturnsAsync(this.mapper.Map(model.Account)); - - this.SetUpMapper(); - - var result = await this.service.UpdateAmountAsync(id, amount); - - Assert.IsInstanceOf>(result); - Assert.IsNotNull(result.Data); - } - - [Test] - public async Task UpdateAmountAsync_NonExistingBalanceId_ReturnsResultError() - { - var id = Guid.NewGuid(); - var model = this.balanceModelBuilder.WithId(id).Generate(); - var entity = this.mapper.Map(model); - var amount = this.random.Next(1000, 10000); - - this.repository - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(default(BalanceEntity)) - .Verifiable(); - this.repository - .Setup(x => x.ChangeAmountAsync(id, amount)) - .Verifiable(); - - var result = await this.service.UpdateAmountAsync(id, amount); - - Assert.IsInstanceOf>(result); - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {id}", result.Error!.Message); - - this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs deleted file mode 100644 index aeaf6cd..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.create.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class CategoriesServiceTests - { - [Test] - [TestCase(Description = "Create valid Category", Category = "Create")] - public async Task CreateAsync_ValidCategoryModel_ReturnsCategoryModel() - { - var model = this.categoryModelBuilder.Generate(); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - - var result = await this.service.CreateAsync(model); - - Assert.IsNotNull(result.Data); - Assert.IsInstanceOf>(result); - - this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); - this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); - this.mapperWrapper.Verify(x => x.Map(It.IsAny()),Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs deleted file mode 100644 index 8a1c5c2..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.cs +++ /dev/null @@ -1,53 +0,0 @@ -using AutoMapper; -using FinancialHub.Core.Domain.Interfaces.Mappers; -using FinancialHub.Core.Domain.Interfaces.Repositories; -using FinancialHub.Core.Domain.Interfaces.Services; -using FinancialHub.Core.Domain.Tests.Builders.Entities; -using FinancialHub.Core.Application.Mappers; -using FinancialHub.Core.Application.Services; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class CategoriesServiceTests - { - protected Random random; - protected CategoryEntityBuilder categoryBuilder; - protected CategoryModelBuilder categoryModelBuilder; - - private ICategoriesService service; - - private IMapper mapper; - private Mock mapperWrapper; - private Mock repository; - - private void MockMapper() - { - mapper = new MapperConfiguration(mc => - { - mc.AddProfile(new FinancialHubAutoMapperProfile()); - } - ).CreateMapper(); - - this.mapperWrapper = new Mock(); - } - - [SetUp] - public void Setup() - { - this.MockMapper(); - - this.repository = new Mock(); - this.service = new CategoriesService(mapperWrapper.Object,repository.Object); - - this.random = new Random(); - - this.categoryBuilder = new CategoryEntityBuilder(); - this.categoryModelBuilder = new CategoryModelBuilder(); - } - - private ICollection CreateCategories() - { - return this.categoryBuilder.Generate(random.Next(10, 100)); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs deleted file mode 100644 index c0aadd9..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.delete.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class CategoriesServiceTests - { - [Test] - [TestCase(Description = "Update valid Category", Category = "Delete")] - public async Task DeleteAsync_RepositorySuccess_ReturnsCategoryModel() - { - var expectedResult = random.Next(1,100); - var guid = Guid.NewGuid(); - this.repository - .Setup(x => x.DeleteAsync(guid)) - .Returns(async () => await Task.FromResult(expectedResult)) - .Verifiable(); - - var result = await this.service.DeleteAsync(guid); - - Assert.IsInstanceOf>(result); - Assert.AreEqual(expectedResult,result.Data); - this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs deleted file mode 100644 index 019d346..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.get.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Linq; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class CategoriesServiceTests - { - //TODO: change mock when filter by user - [Test] - [TestCase(Description = "Get by user sucess return",Category = "Get")] - public async Task GetByUsersAsync_ValidUser_ReturnsCategories() - { - var entitiesMock = this.CreateCategories(); - - this.repository - .Setup(x => x.GetAllAsync()) - .ReturnsAsync(entitiesMock.ToArray()) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map>(It.IsAny>())) - .Returns>((ent) => this.mapper.Map>(ent)) - .Verifiable(); - - var result = await this.service.GetAllByUserAsync(string.Empty); - - Assert.IsInstanceOf>>(result); - Assert.IsFalse(result.HasError); - Assert.AreEqual(entitiesMock.Count(), result.Data!.Count); - - this.mapperWrapper.Verify(x => x.Map>(It.IsAny>()),Times.Once); - this.repository.Verify(x => x.GetAllAsync(),Times.Once()); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs deleted file mode 100644 index 7284ea0..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Categories/CategoriesServiceTests.update.cs +++ /dev/null @@ -1,71 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class CategoriesServiceTests - { - [Test] - [TestCase(Description = "Update valid Category", Category = "Update")] - public async Task UpdateAsync_ValidCategoryModel_ReturnsCategoryModel() - { - var model = this.categoryModelBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsNotNull(result); - Assert.IsInstanceOf>(result); - - this.repository.Verify(x => x.GetByIdAsync(model.Id.GetValueOrDefault()), Times.Once); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); - - this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); - this.mapperWrapper.Verify(x => x.Map(It.IsAny()), Times.Once); - } - - [Test] - [TestCase(Description = "Update non existing Category", Category = "Update")] - public async Task UpdateAsync_NonExistingCategoryId_ReturnsResultError() - { - var id = Guid.NewGuid(); - var model = this.categoryModelBuilder - .WithId(id) - .Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(default(CategoryEntity)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - var result = await this.service.UpdateAsync(id, model); - - Assert.IsInstanceOf>(result); - Assert.IsTrue(result.HasError); - - this.repository.Verify(x => x.GetByIdAsync(id), Times.Once); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Never); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs deleted file mode 100644 index caa11c7..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/BaseTransactionBalanceTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -using FinancialHub.Core.Domain.Interfaces.Services; -using FinancialHub.Core.Application.Services; - -namespace FinancialHub.Core.Application.Tests.Services.TransactionBalance -{ - public abstract class BaseTransactionBalanceTests - { - protected Random random; - - protected Mock balancesService; - protected Mock transactionsService; - - protected BalanceModelBuilder balanceModelBuilder; - protected TransactionModelBuilder transactionModelBuilder; - - protected ITransactionBalanceService service; - - [SetUp] - public void Setup() - { - this.balancesService = new Mock(); - this.transactionsService = new Mock(); - this.service = new TransactionBalanceService( - transactionsService.Object, - balancesService.Object - ); - - this.random = new Random(); - - this.balanceModelBuilder = new BalanceModelBuilder(); - this.transactionModelBuilder = new TransactionModelBuilder(); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs deleted file mode 100644 index 81d99a1..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.create.cs +++ /dev/null @@ -1,114 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class TransactionBalanceTests - { - [TestCase(TransactionType.Earn)] - [TestCase(TransactionType.Expense)] - public async Task CreateTransactionAsync_PaidTransaction_ShouldReturnCreatedTransaction(TransactionType type) - { - var transaction = this.transactionModelBuilder - .WithType(type) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - var balance = this.balanceModelBuilder - .WithAmount(0) - .WithId(transaction.BalanceId) - .Generate(); - - this.transactionsService - .Setup(x => x.CreateAsync(transaction)) - .ReturnsAsync(transaction).Verifiable(); - this.balancesService - .Setup(x => x.GetByIdAsync(transaction.BalanceId)) - .ReturnsAsync(balance); - this.balancesService - .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, transaction.Amount)); - - var result = await this.service.CreateTransactionAsync(transaction); - - Assert.AreEqual(transaction, result.Data); - Assert.IsFalse(result.HasError); - Assert.IsNull(result.Error); - } - - [TestCase(TransactionType.Earn)] - [TestCase(TransactionType.Expense)] - public async Task CreateTransactionAsync_PaidTransaction_ShouldUpdateBalance(TransactionType type) - { - var transaction = this.transactionModelBuilder - .WithType(type) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - var balance = this.balanceModelBuilder - .WithId(transaction.BalanceId) - .Generate(); - var expectedResult = - type == TransactionType.Earn? - balance.Amount + transaction.Amount: - balance.Amount - transaction.Amount; - - this.transactionsService - .Setup(x => x.CreateAsync(transaction)) - .ReturnsAsync(transaction) - .Verifiable(); - this.balancesService - .Setup(x => x.GetByIdAsync(transaction.BalanceId)) - .ReturnsAsync(balance) - .Verifiable(); - this.balancesService - .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, expectedResult)) - .Verifiable(); - - await this.service.CreateTransactionAsync(transaction); - - this.transactionsService.Verify(x => x.CreateAsync(transaction), Times.Once); - this.balancesService.Verify(x => x.GetByIdAsync(transaction.BalanceId), Times.Once); - this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, expectedResult), Times.Once); - } - - [Test] - public async Task CreateTransactionAsync_TransactionCreationFailed_ReturnsServiceError() - { - var transaction = this.transactionModelBuilder - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - - var error = new ServiceError(1, "Error message"); - this.transactionsService - .Setup(x => x.CreateAsync(transaction)) - .ReturnsAsync(error) - .Verifiable(); - - var result = await this.service.CreateTransactionAsync(transaction); - - Assert.IsNull(result.Data); - Assert.IsTrue(result.HasError); - Assert.AreEqual(error ,result.Error); - } - - [Test] - public async Task CreateTransactionAsync_NotPaidTransaction_ShouldNotUpdateBalance() - { - var transaction = this.transactionModelBuilder - .WithStatus(TransactionStatus.NotCommitted) - .WithActiveStatus(true) - .Generate(); - - this.transactionsService - .Setup(x => x.CreateAsync(transaction)) - .ReturnsAsync(transaction) - .Verifiable(); - - await this.service.CreateTransactionAsync(transaction); - - this.transactionsService.Verify(x => x.CreateAsync(transaction), Times.Once); - this.balancesService.Verify(x => x.GetByIdAsync(transaction.BalanceId), Times.Never); - this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny()), Times.Never); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs deleted file mode 100644 index f6d708e..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.cs +++ /dev/null @@ -1,9 +0,0 @@ -using FinancialHub.Core.Application.Tests.Services.TransactionBalance; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class TransactionBalanceTests : BaseTransactionBalanceTests - { - - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs deleted file mode 100644 index 481e969..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.delete.cs +++ /dev/null @@ -1,153 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class TransactionBalanceTests - { - [Test] - public async Task DeleteTransactionAsync_ValidTransactionId_ReturnsTrue() - { - var id = Guid.NewGuid(); - var transaction = this.transactionModelBuilder.WithId(id).Generate(); - this.transactionsService - .Setup(x => x.DeleteAsync(id)) - .ReturnsAsync(1); - this.transactionsService - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(transaction); - this.balancesService - .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny())); - - var result = await this.service.DeleteTransactionAsync(id); - - Assert.IsFalse(result.HasError); - Assert.IsTrue(result.Data); - } - - [Test] - public async Task DeleteTransactionAsync_NoDeletion_ReturnsFalse() - { - var id = Guid.NewGuid(); - this.transactionsService - .Setup(x => x.DeleteAsync(id)) - .ReturnsAsync(0); - - var result = await this.service.DeleteTransactionAsync(id); - Assert.IsFalse(result.Data); - } - - [Test] - public async Task DeleteTransactionAsync_TransactionDeleteError_ReturnsError() - { - var id = Guid.NewGuid(); - var error = new ServiceError(1, "error message"); - this.transactionsService - .Setup(x => x.DeleteAsync(id)) - .ReturnsAsync(error); - var result = await this.service.DeleteTransactionAsync(id); - - Assert.IsTrue(result.HasError); - Assert.AreEqual(error.Message ,result.Error!.Message); - } - - [Test] - public async Task DeleteTransactionAsync_PaidTransaction_UpdatesAmount() - { - var id = Guid.NewGuid(); - var transaction = this.transactionModelBuilder - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .WithId(id) - .Generate(); - - this.transactionsService - .Setup(x => x.DeleteAsync(id)) - .ReturnsAsync(1); - this.transactionsService - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(transaction); - this.balancesService - .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny())) - .Verifiable(); - await this.service.DeleteTransactionAsync(id); - - this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny()), Times.Once); - } - - [Test] - public async Task DeleteTransactionAsync_NotPaidTransaction_DoNotUpdateAmount() - { - var id = Guid.NewGuid(); - var transaction = this.transactionModelBuilder - .WithStatus(TransactionStatus.NotCommitted) - .WithId(id) - .Generate(); - - this.transactionsService - .Setup(x => x.DeleteAsync(id)) - .ReturnsAsync(1); - this.transactionsService - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(transaction); - await this.service.DeleteTransactionAsync(id); - - this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, It.IsAny()), Times.Never); - } - - [Test] - public async Task DeleteTransactionAsync_EarnTransction_RemovesAmount() - { - var balance = this.balanceModelBuilder.Generate(); - var id = Guid.NewGuid(); - var transaction = this.transactionModelBuilder - .WithBalance(balance) - .WithType(TransactionType.Earn) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .WithId(id) - .Generate(); - var expectedAmount = balance.Amount - transaction.Amount; - - this.transactionsService - .Setup(x => x.DeleteAsync(id)) - .ReturnsAsync(1); - this.transactionsService - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(transaction); - this.balancesService - .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, expectedAmount)) - .Verifiable(); - await this.service.DeleteTransactionAsync(id); - - this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, expectedAmount), Times.Once); - } - - [Test] - public async Task DeleteTransactionAsync_ExpenseTransction_AddsAmount() - { - var balance = this.balanceModelBuilder.Generate(); - var id = Guid.NewGuid(); - var transaction = this.transactionModelBuilder - .WithBalance(balance) - .WithType(TransactionType.Expense) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .WithId(id) - .Generate(); - var expectedAmount = balance.Amount + transaction.Amount; - - this.transactionsService - .Setup(x => x.DeleteAsync(id)) - .ReturnsAsync(1); - this.transactionsService - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(transaction); - this.balancesService - .Setup(x => x.UpdateAmountAsync(transaction.BalanceId, expectedAmount)) - .Verifiable(); - await this.service.DeleteTransactionAsync(id); - - this.balancesService.Verify(x => x.UpdateAmountAsync(transaction.BalanceId, expectedAmount), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs deleted file mode 100644 index dd4a8d7..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.update.cs +++ /dev/null @@ -1,131 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class TransactionBalanceTests - { - [Test] - public async Task UpdateTransactionAsync_ValidTransactionWithDifferentBalances_UpdatesBalancesAmount() - { - var oldBalance = this.balanceModelBuilder.Generate(); - var newBalance = this.balanceModelBuilder.Generate(); - var id = Guid.NewGuid(); - - var oldTransaction = this.transactionModelBuilder - .WithType(TransactionType.Earn) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .WithBalance(oldBalance) - .WithId(id) - .Generate(); - var newTransaction = this.transactionModelBuilder - .WithType(TransactionType.Earn) - .WithStatus(TransactionStatus.NotCommitted) - .WithActiveStatus(true) - .WithBalance(newBalance) - .WithId(id) - .Generate(); - - this.transactionsService - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(oldTransaction); - this.transactionsService - .Setup(x => x.UpdateAsync(id, newTransaction)) - .ReturnsAsync(newTransaction); - - this.balancesService - .Setup(x => x.GetByIdAsync(oldTransaction.BalanceId)) - .ReturnsAsync(oldBalance); - this.balancesService - .Setup(x => x.GetByIdAsync(newTransaction.BalanceId)) - .ReturnsAsync(newBalance); - this.balancesService - .Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny())) - .Verifiable(); - - var result = await this.service.UpdateTransactionAsync(id, newTransaction); - - Assert.IsFalse(result.HasError); - Assert.AreSame(newTransaction, result.Data); - this.balancesService - .Verify( - x => x.UpdateAmountAsync(It.IsAny(), It.IsAny()), - Times.Between(1,2, Moq.Range.Inclusive) - ); - } - - [Test] - public async Task UpdateTransactionAsync_ValidTransactionWithSameBalance_UpdatesBalanceAmount() - { - var balance = this.balanceModelBuilder.Generate(); - var id = Guid.NewGuid(); - - var oldTransaction = this.transactionModelBuilder - .WithType(TransactionType.Earn) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .WithBalance(balance) - .WithId(id) - .Generate(); - var newTransaction = this.transactionModelBuilder - .WithType(TransactionType.Earn) - .WithStatus(TransactionStatus.NotCommitted) - .WithActiveStatus(true) - .WithBalance(balance) - .WithId(id) - .Generate(); - - this.transactionsService - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(oldTransaction); - this.transactionsService - .Setup(x => x.UpdateAsync(id, newTransaction)) - .ReturnsAsync(newTransaction); - - this.balancesService - .Setup(x => x.GetByIdAsync(newTransaction.BalanceId)) - .ReturnsAsync(balance); - this.balancesService - .Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny())) - .Verifiable(); - - var result = await this.service.UpdateTransactionAsync(id, newTransaction); - - Assert.IsFalse(result.HasError); - Assert.AreSame(newTransaction, result.Data); - this.balancesService - .Verify( - x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny()), - Times.Once - ); - } - - [Test] - public async Task UpdateTransactionAsync_TransactionUpdateFailed_ReturnsUpdateError() - { - var balance = this.balanceModelBuilder.Generate(); - var id = Guid.NewGuid(); - var newTransaction = this.transactionModelBuilder - .WithType(TransactionType.Earn) - .WithStatus(TransactionStatus.NotCommitted) - .WithActiveStatus(true) - .WithBalance(balance) - .WithId(id) - .Generate(); - - var error = new ServiceError(1, "Update error message"); - this.transactionsService - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(newTransaction); - - this.transactionsService - .Setup(x => x.UpdateAsync(id, newTransaction)) - .ReturnsAsync(error); - - var result = await this.service.UpdateTransactionAsync(id, newTransaction); - - Assert.IsTrue(result.HasError); - Assert.AreEqual(error.Message, result.Error!.Message); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs deleted file mode 100644 index acf4b2f..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/TransactionBalance/TransactionBalanceTests.updateamount.cs +++ /dev/null @@ -1,378 +0,0 @@ -using FinancialHub.Core.Domain.Enums; -using FinancialHub.Core.Application.Tests.Services.TransactionBalance; - -namespace FinancialHub.Core.Application.Tests.Services -{ - //TODO: fix UpdateAmount in test names - //TOOD: maybe separate some testcases - public partial class TransactionBalanceTests - { - public class UpdateAmountAsync - { - public class SameBalance : BaseTransactionBalanceTests - { - [TestCase(TransactionStatus.NotCommitted, TransactionType.Expense, true)] - [TestCase(TransactionStatus.NotCommitted, TransactionType.Earn, true)] - [TestCase(TransactionStatus.NotCommitted, TransactionType.Expense, false)] - [TestCase(TransactionStatus.NotCommitted, TransactionType.Earn, false)] - [TestCase(TransactionStatus.Committed, TransactionType.Expense, false)] - [TestCase(TransactionStatus.Committed, TransactionType.Earn, false)] - public async Task NotPaid_DoNotUpdatesAmount( - TransactionStatus status, TransactionType type, bool activeStatus - ) - { - var balance = this.balanceModelBuilder.Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(status) - .WithType(type) - .WithActiveStatus(activeStatus) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(status) - .WithType(type) - .WithActiveStatus(activeStatus) - .Generate(); - - await this.service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(It.IsAny(), It.IsAny()), Times.Never); - } - - [TestCase(TransactionStatus.Committed, TransactionType.Expense)] - [TestCase(TransactionStatus.Committed, TransactionType.Earn)] - public async Task NoChanges_DoNotUpdateAmount(TransactionStatus status, TransactionType type) - { - var balance = this.balanceModelBuilder.Generate(); - var transactionId = Guid.NewGuid(); - var oldTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(status) - .WithType(type) - .WithActiveStatus(true) - .WithId(transactionId) - .Generate(); - - await this.service.UpdateAmountAsync(oldTransaction, oldTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(It.IsAny(), It.IsAny()), Times.Never); - } - - [TestCase(TransactionType.Expense, TransactionType.Expense)] - [TestCase(TransactionType.Expense, TransactionType.Earn)] - [TestCase(TransactionType.Earn, TransactionType.Earn)] - [TestCase(TransactionType.Earn, TransactionType.Expense)] - public async Task PaidToNotPaid_RemovesAmountUpdates(TransactionType oldType, TransactionType type) - { - var balanceId = Guid.NewGuid(); - var balance = this.balanceModelBuilder - .WithId(balanceId) - .Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.NotCommitted) - .WithType(oldType) - .WithActiveStatus(true) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.Committed) - .WithType(type) - .WithActiveStatus(true) - .Generate(); - - var expectedResult = - type == TransactionType.Earn ? - balance.Amount + newTransaction.Amount : - balance.Amount - newTransaction.Amount; - this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); - - await service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); - } - - [TestCase(TransactionType.Expense)] - [TestCase(TransactionType.Earn)] - public async Task DifferentAmount_AddsDifference(TransactionType type) - { - var balanceId = Guid.NewGuid(); - var startValue = random.Next(1000, 10000); - var balance = this.balanceModelBuilder - .WithAmount(startValue) - .WithId(balanceId) - .Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.Committed) - .WithType(type) - .WithActiveStatus(true) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.Committed) - .WithType(type) - .WithActiveStatus(true) - .Generate(); - var expectedResult = - type == TransactionType.Earn ? - startValue + newTransaction.Amount - oldTransaction.Amount : - startValue + oldTransaction.Amount - newTransaction.Amount; - this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); - - await service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); - } - - [Test] - public async Task ExpenseToEarn_AddsRevemovedAmount() - { - var balanceId = Guid.NewGuid(); - var startValue = random.Next(1000, 10000); - var balance = this.balanceModelBuilder - .WithAmount(startValue) - .WithId(balanceId) - .Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.Committed) - .WithType(TransactionType.Expense) - .WithActiveStatus(true) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.Committed) - .WithType(TransactionType.Earn) - .WithActiveStatus(true) - .Generate(); - - var expectedResult = startValue + (newTransaction.Amount + oldTransaction.Amount); - this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); - - await service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); - } - - [Test] - public async Task EarnToExpense_RemovesAddedAmount() { - var balanceId = Guid.NewGuid(); - var startValue = random.Next(1000, 10000); - var balance = this.balanceModelBuilder - .WithAmount(startValue) - .WithId(balanceId) - .Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.Committed) - .WithType(TransactionType.Earn) - .WithActiveStatus(true) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.Committed) - .WithType(TransactionType.Expense) - .WithActiveStatus(true) - .Generate(); - - var expectedResult = startValue - oldTransaction.Amount - newTransaction.Amount; - this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); - - await service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); - } - - [TestCase(TransactionType.Expense, TransactionType.Expense)] - [TestCase(TransactionType.Expense, TransactionType.Earn)] - [TestCase(TransactionType.Earn, TransactionType.Earn)] - [TestCase(TransactionType.Earn, TransactionType.Expense)] - public async Task PaidToNotPaid_RemovesAmountChanges(TransactionType oldType, TransactionType type) - { - var balanceId = Guid.NewGuid(); - var balance = this.balanceModelBuilder - .WithId(balanceId) - .Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.Committed) - .WithType(oldType) - .WithActiveStatus(true) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithBalance(balance) - .WithStatus(TransactionStatus.NotCommitted) - .WithType(type) - .WithActiveStatus(true) - .Generate(); - - var expectedResult = - type == TransactionType.Earn ? - balance.Amount - newTransaction.Amount: - balance.Amount + newTransaction.Amount; - this.balancesService.Setup(x => x.UpdateAmountAsync(balanceId, expectedResult)); - - await service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(balanceId, expectedResult), Times.Once); - } - } - - public class DifferenteBalance : BaseTransactionBalanceTests - { - [TestCase(TransactionType.Expense, TransactionType.Expense)] - [TestCase(TransactionType.Expense, TransactionType.Earn)] - [TestCase(TransactionType.Earn, TransactionType.Earn)] - [TestCase(TransactionType.Earn, TransactionType.Expense)] - public async Task NotPaidToPaid_AppliesAmountChangesOnNewBalance(TransactionType oldType, TransactionType type) - { - var oldBalance = this.balanceModelBuilder.Generate(); - var newBalance = this.balanceModelBuilder.Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithBalance(oldBalance) - .WithType(oldType) - .WithStatus(TransactionStatus.NotCommitted) - .WithActiveStatus(true) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithBalance(newBalance) - .WithType(type) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - var expectedResult = - type == TransactionType.Earn? - newBalance.Amount + newTransaction.Amount: - newBalance.Amount - newTransaction.Amount; - - this.balancesService.Setup(x => x.UpdateAmountAsync(oldTransaction.BalanceId, It.IsAny())); - this.balancesService.Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedResult)); - - await this.service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(oldTransaction.BalanceId, It.IsAny()), Times.Never); - this.balancesService.Verify(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedResult), Times.Once); - } - - [TestCase(TransactionType.Expense, TransactionType.Expense)] - [TestCase(TransactionType.Expense, TransactionType.Earn)] - [TestCase(TransactionType.Earn, TransactionType.Earn)] - [TestCase(TransactionType.Earn, TransactionType.Expense)] - public async Task NotPaidToPaid_RemoveAmountChangesFromOldBalance(TransactionType oldType, TransactionType type) - { - var oldStartValue = 0; - var oldBalance = this.balanceModelBuilder.WithAmount(oldStartValue).Generate(); - var newBalance = this.balanceModelBuilder.WithAmount(oldStartValue).Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithAmount(10) - .WithBalance(oldBalance) - .WithType(oldType) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithAmount(10) - .WithBalance(newBalance) - .WithType(type) - .WithStatus(TransactionStatus.NotCommitted) - .WithActiveStatus(true) - .Generate(); - var expectedResult = - oldType == TransactionType.Earn ? - oldBalance.Amount - oldTransaction.Amount : - oldBalance.Amount + oldTransaction.Amount; - - this.balancesService.Setup(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedResult)); - this.balancesService.Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny())); - - await this.service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedResult), Times.Once); - this.balancesService.Verify(x => x.UpdateAmountAsync(newTransaction.BalanceId, It.IsAny()), Times.Never); - } - - [Test] - public async Task EarnTransactions_RemovesAmountFromOldBalanceAndSentToNewBalance() - { - var oldBalance = this.balanceModelBuilder.Generate(); - var newBalance = this.balanceModelBuilder.Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithBalance(oldBalance) - .WithType(TransactionType.Earn) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithBalance(newBalance) - .WithType(TransactionType.Earn) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - - var expectedOldBalanceAmount = oldBalance.Amount - oldTransaction.Amount; - var expectedNewBalanceAmount = newBalance.Amount + newTransaction.Amount; - - this.balancesService.Setup(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedOldBalanceAmount)); - this.balancesService.Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedNewBalanceAmount)); - - await this.service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedOldBalanceAmount), Times.Once); - this.balancesService.Verify(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedNewBalanceAmount), Times.Once); - } - - [Test] - public async Task ExpenseTransactions_RemovesAmountFromOldBalanceAndSentToNewBalance() - { - var oldBalance = this.balanceModelBuilder.Generate(); - var newBalance = this.balanceModelBuilder.Generate(); - - var oldTransaction = this.transactionModelBuilder - .WithBalance(oldBalance) - .WithType(TransactionType.Expense) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - - var newTransaction = this.transactionModelBuilder - .WithBalance(newBalance) - .WithType(TransactionType.Expense) - .WithStatus(TransactionStatus.Committed) - .WithActiveStatus(true) - .Generate(); - - var expectedOldBalanceAmount = oldBalance.Amount + oldTransaction.Amount; - var expectedNewBalanceAmount = newBalance.Amount - newTransaction.Amount; - - this.balancesService.Setup(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedOldBalanceAmount)); - this.balancesService.Setup(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedNewBalanceAmount)); - - await this.service.UpdateAmountAsync(oldTransaction, newTransaction); - - this.balancesService.Verify(x => x.UpdateAmountAsync(oldTransaction.BalanceId, expectedOldBalanceAmount), Times.Once); - this.balancesService.Verify(x => x.UpdateAmountAsync(newTransaction.BalanceId, expectedNewBalanceAmount), Times.Once); - } - } - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs deleted file mode 100644 index d83cc76..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.create.cs +++ /dev/null @@ -1,90 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class TransactionsServiceTests - { - [Test] - public async Task CreateAsync_ValidTransaction_CreatesTransaction() - { - var model = this.transactionModelBuilder.Generate(); - - this.categoriesRepository - .Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)); - - this.balancesRepository - .Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(this.mapper.Map(model.Balance)); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.CreateAsync(model); - - this.repository.Verify(x => x.CreateAsync(It.IsAny()), Times.Once); - } - - [Test] - public async Task CreateAsync_ValidTransaction_ReturnsCreatedTransaction() - { - var model = this.transactionModelBuilder.Generate(); - - this.categoriesRepository - .Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)); - - this.balancesRepository - .Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(this.mapper.Map(model.Balance)); - - this.repository - .Setup(x => x.CreateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.CreateAsync(model); - - Assert.IsNotNull(result.Data); - Assert.IsInstanceOf>(result); - } - - [Test] - public async Task CreateAsync_InvalidCategory_ReturnsNotFoundError() - { - var model = this.transactionModelBuilder.Generate(); - - this.SetUpMapper(); - - this.balancesRepository - .Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(this.mapper.Map(model.Balance)); - - var result = await this.service.CreateAsync(model); - - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error!.Message); - } - - [Test] - public async Task CreateAsync_InvalidBalance_ReturnsNotFoundError() - { - var model = this.transactionModelBuilder.Generate(); - - this.SetUpMapper(); - - this.categoriesRepository - .Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)); - - var result = await this.service.CreateAsync(model); - - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error!.Message); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs deleted file mode 100644 index d3ae8d8..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.cs +++ /dev/null @@ -1,70 +0,0 @@ -using AutoMapper; -using FinancialHub.Core.Domain.Interfaces.Mappers; -using FinancialHub.Core.Domain.Interfaces.Repositories; -using FinancialHub.Core.Domain.Interfaces.Services; -using FinancialHub.Core.Domain.Tests.Builders.Entities; -using FinancialHub.Core.Application.Mappers; -using FinancialHub.Core.Application.Services; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class TransactionsServiceTests - { - protected Random random; - protected TransactionEntityBuilder transactionBuilder; - protected TransactionModelBuilder transactionModelBuilder; - - private ITransactionsService service; - - private IMapper mapper; - private Mock mapperWrapper; - private Mock repository; - private Mock balancesRepository; - private Mock categoriesRepository; - - private void MockMapper() - { - mapper = new MapperConfiguration(mc => - { - mc.AddProfile(new FinancialHubAutoMapperProfile()); - } - ).CreateMapper(); - - this.mapperWrapper = new Mock(); - } - - [SetUp] - public void Setup() - { - this.MockMapper(); - - this.repository = new Mock(); - this.balancesRepository = new Mock(); - this.categoriesRepository = new Mock(); - this.service = new TransactionsService(mapperWrapper.Object,repository.Object,balancesRepository.Object,categoriesRepository.Object); - - this.random = new Random(); - - this.transactionBuilder = new TransactionEntityBuilder(); - this.transactionModelBuilder = new TransactionModelBuilder(); - } - - private void SetUpMapper() - { - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((model) => this.mapper.Map(model)) - .Verifiable(); - } - - public ICollection GenerateTransactions() - { - return this.transactionBuilder.Generate(random.Next(5, 10)); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs deleted file mode 100644 index fad29cb..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.delete.cs +++ /dev/null @@ -1,135 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class TransactionsServiceTests - { - [Test] - public async Task DeleteAsync_ExistingTransaction_RemovesTransactions() - { - var expectedResult = random.Next(1, 100); - var transaction = this.transactionBuilder.Generate(); - var guid = transaction.Id.GetValueOrDefault(); - - this.repository - .Setup(x => x.DeleteAsync(guid)) - .ReturnsAsync(expectedResult) - .Verifiable(); - this.repository - .Setup(x => x.GetByIdAsync(guid)) - .ReturnsAsync(transaction); - - this.SetUpMapper(); - - await this.service.DeleteAsync(guid); - - this.repository.Verify(x => x.DeleteAsync(guid), Times.Once); - } - - [Test] - public async Task DeleteAsync_ExistingTransaction_ReturnsRemovedTransactions() - { - var expectedResult = random.Next(1,100); - var transaction = this.transactionBuilder.Generate(); - var guid = transaction.Id.GetValueOrDefault(); - - this.repository - .Setup(x => x.DeleteAsync(guid)) - .ReturnsAsync(expectedResult); - this.repository - .Setup(x => x.GetByIdAsync(guid)) - .ReturnsAsync(transaction); - - this.SetUpMapper(); - - var result = await this.service.DeleteAsync(guid); - - Assert.IsInstanceOf>(result); - Assert.AreEqual(expectedResult,result.Data); - } - - [Test] - public async Task DeleteAsync_NotExistingTransaction_ReturnsNotFoundError() - { - var transaction = this.transactionBuilder.Generate(); - var guid = transaction.Id.GetValueOrDefault(); - - this.repository - .Setup(x => x.GetByIdAsync(guid)); - - var result = await this.service.DeleteAsync(guid); - - Assert.Zero(result.Data); - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Transaction with id {guid}", result.Error!.Message); - } - - [Test] - public async Task DeleteAsync_NotExistingTransaction_DoesNotRemovesTransactions() - { - var transaction = this.transactionBuilder.Generate(); - var guid = transaction.Id.GetValueOrDefault(); - - this.repository - .Setup(x => x.GetByIdAsync(guid)); - - await this.service.DeleteAsync(guid); - - this.repository.Verify(x => x.GetByIdAsync(guid),Times.Once); - } - - [TestCase(TransactionStatus.Committed, false)] - [TestCase(TransactionStatus.NotCommitted, true)] - [TestCase(TransactionStatus.NotCommitted, false)] - public async Task DeleteAsync_ExistingNotCommitedOrInactiveTransaction_RemovesBalanceAmount( - TransactionStatus status, bool isActive - ) - { - var expectedResult = random.Next(1, 100); - var transaction = this.transactionBuilder - .WithStatus(status) - .WithActiveStatus(isActive) - .Generate(); - var guid = transaction.Id.GetValueOrDefault(); - - this.repository - .Setup(x => x.DeleteAsync(guid)) - .ReturnsAsync(expectedResult); - this.repository - .Setup(x => x.GetByIdAsync(guid)) - .ReturnsAsync(transaction); - - this.SetUpMapper(); - - await this.service.DeleteAsync(guid); - - this.balancesRepository.Verify(x => x.ChangeAmountAsync(transaction.BalanceId,transaction.Amount,transaction.Type,true), Times.Never); - } - - [TestCase(TransactionStatus.Committed, true)] - public async Task DeleteAsync_ExistingCommitedAndActiveTransaction_RemovesBalanceAmount( - TransactionStatus status, bool isActive - ) - { - var expectedResult = random.Next(1, 100); - var transaction = this.transactionBuilder - .WithStatus(status) - .WithActiveStatus(isActive) - .Generate(); - var guid = transaction.Id.GetValueOrDefault(); - - this.repository - .Setup(x => x.DeleteAsync(guid)) - .ReturnsAsync(expectedResult); - this.repository - .Setup(x => x.GetByIdAsync(guid)) - .ReturnsAsync(transaction); - - this.SetUpMapper(); - - await this.service.DeleteAsync(guid); - - this.balancesRepository.Verify(x => x.ChangeAmountAsync(transaction.BalanceId, transaction.Amount, transaction.Type,true), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs deleted file mode 100644 index cee2983..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.get.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Linq; -using FinancialHub.Core.Domain.Filters; -using FinancialHub.Core.Domain.Queries; - -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class TransactionsServiceTests - { - [Test] - public async Task GetByUsersAsync_ValidUser_ReturnsTransactions() - { - var filter = new TransactionFilter(); - var entitiesMock = this.GenerateTransactions(); - - this.repository - .Setup(x => x.GetAsync(It.IsAny>())) - .ReturnsAsync(entitiesMock.ToArray()); - - this.mapperWrapper - .Setup(x => x.Map(It.IsAny())) - .Returns((ent) => this.mapper.Map(ent)) - .Verifiable(); - - this.mapperWrapper - .Setup(x => x.Map>(It.IsAny>())) - .Returns>((ent) => this.mapper.Map>(ent)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.GetAllByUserAsync(string.Empty, filter); - - Assert.IsInstanceOf>>(result); - Assert.IsFalse(result.HasError); - Assert.AreEqual(entitiesMock.Count, result.Data!.Count); - } - - [Test] - public async Task GetByIdAsync_ExistingTransaction_ReturnsTransaction() - { - var id = Guid.NewGuid(); - var transaction = this.transactionBuilder - .WithId(id) - .Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(id)) - .ReturnsAsync(transaction); - - this.SetUpMapper(); - - var result = await this.service.GetByIdAsync(id); - - Assert.IsFalse(result.HasError); - Assert.IsInstanceOf>(result); - Assert.AreEqual(transaction.Id, result.Data!.Id); - } - - [Test] - public async Task GetByIdAsync_NonExistingTransaction_ReturnsNotFoundError() - { - var id = Guid.NewGuid(); - - this.SetUpMapper(); - - var result = await this.service.GetByIdAsync(id); - - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Transaction with id {id}", result.Error!.Message); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs b/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs deleted file mode 100644 index 9ab2ddf..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Services/Transactions/TransactionsServiceTests.update.cs +++ /dev/null @@ -1,130 +0,0 @@ -namespace FinancialHub.Core.Application.Tests.Services -{ - public partial class TransactionsServiceTests - { - [Test] - public async Task UpdateAsync_ValidTransaction_UpdatesTransaction() - { - var model = this.transactionModelBuilder.Generate(); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(this.mapper.Map(model.Balance)) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - this.repository.Verify(x => x.UpdateAsync(It.IsAny()), Times.Once); - } - - [Test] - public async Task UpdateAsync_ValidTransaction_ReturnsTransaction() - { - var model = this.transactionModelBuilder.Generate(); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(this.mapper.Map(model.Balance)) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - this.SetUpMapper(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsNotNull(result); - Assert.IsInstanceOf>(result); - } - - [Test] - public async Task UpdateAsync_NonExistingTransactionId_ReturnsResultError() - { - var model = this.transactionModelBuilder.Generate(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(default(TransactionEntity)) - .Verifiable(); - - this.repository - .Setup(x => x.UpdateAsync(It.IsAny())) - .Returns(async (x) => await Task.FromResult(x)) - .Verifiable(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsInstanceOf>(result); - Assert.IsTrue(result.HasError); - } - - [Test] - public async Task UpdateAsync_InvalidCategory_ReturnsNotFoundError() - { - var model = this.transactionModelBuilder.Generate(); - - this.SetUpMapper(); - - this.balancesRepository.Setup(x => x.GetByIdAsync(model.BalanceId)) - .ReturnsAsync(this.mapper.Map(model.Balance)) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Category with id {model.CategoryId}", result.Error!.Message); - } - - [Test] - public async Task UpdateAsync_InvalidBalance_ReturnsNotFoundError() - { - var model = this.transactionModelBuilder.Generate(); - - this.SetUpMapper(); - - this.categoriesRepository.Setup(x => x.GetByIdAsync(model.CategoryId)) - .ReturnsAsync(this.mapper.Map(model.Category)) - .Verifiable(); - - this.repository - .Setup(x => x.GetByIdAsync(model.Id.GetValueOrDefault())) - .ReturnsAsync(this.mapper.Map(model)) - .Verifiable(); - - var result = await this.service.UpdateAsync(model.Id.GetValueOrDefault(), model); - - Assert.IsTrue(result.HasError); - Assert.AreEqual($"Not found Balance with id {model.BalanceId}", result.Error!.Message); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Usings.cs b/tests/core/FinancialHub.Core.Application.Tests/Usings.cs deleted file mode 100644 index 8fdc623..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Usings.cs +++ /dev/null @@ -1,21 +0,0 @@ -// System namespaces -global using System; -global using System.Threading.Tasks; -global using System.Collections.Generic; - -// 3rd party test namespaces -global using NUnit.Framework; -global using Moq; - -// Domain builder tests namespaces -global using FinancialHub.Core.Domain.Tests.Builders.Models; - -// Common Project namespaces -global using FinancialHub.Common.Results; -global using FinancialHub.Common.Results.Errors; - -// Domain Project namespaces -global using FinancialHub.Core.Domain.Models; -global using FinancialHub.Core.Domain.Entities; - -[assembly: Category("Unit")] \ No newline at end of file diff --git a/tests/core/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs deleted file mode 100644 index f2a6d54..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Validators/AccountValidatorTests.cs +++ /dev/null @@ -1,83 +0,0 @@ -using FinancialHub.Core.Application.Validators; - -namespace FinancialHub.Core.Application.Tests.Validators -{ - public class AccountValidatorTests - { - private AccountModelBuilder builder; - private readonly AccountValidator validator; - - public AccountValidatorTests() - { - this.validator = new AccountValidator(); - } - - [SetUp] - public void SetUp() - { - this.builder = new AccountModelBuilder(); - } - - [Test] - public void Account_Valid_ReturnsSuccess() - { - var account = builder.Generate(); - - var result = validator.Validate(account); - - Assert.IsTrue(result.IsValid); - Assert.IsEmpty(result.Errors); - } - - [TestCase("")] - [TestCase(null)] - public void Account_NullOrEmptyName_ReturnsRequiredError(string invalidName) - { - var account = builder.WithName(invalidName).Generate(); - - var result = validator.Validate(account); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual("Name is required",result.Errors[0].ErrorMessage); - } - - [Test] - public void Account_BigName_ReturnsMaxLengthError() - { - var invalidName = new string('a',201); - var account = builder.WithName(invalidName).Generate(); - - var result = validator.Validate(account); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual($"Name exceeds the max length of 200", result.Errors[0].ErrorMessage); - } - - [TestCase("")] - [TestCase(null)] - public void Account_NullOrEmptyDescription_ReturnsSuccess(string description) - { - var account = builder.WithDescription(description).Generate(); - - var result = validator.Validate(account); - - Assert.IsTrue(result.IsValid); - Assert.IsEmpty(result.Errors); - } - - [Test] - public void Account_BigDescription_ReturnsMaxLengthError() - { - var invalidDescription = new string('a', 501); - var account = builder.WithDescription(invalidDescription).Generate(); - - var result = validator.Validate(account); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual($"Description exceeds the max length of 500", result.Errors[0].ErrorMessage); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs deleted file mode 100644 index 01f39a6..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Validators/BalanceValidatorTests.cs +++ /dev/null @@ -1,83 +0,0 @@ -using FinancialHub.Core.Application.Validators; - -namespace FinancialHub.Core.Application.Tests.Validators -{ - public class BalanceValidatorTests - { - private BalanceModelBuilder builder; - private readonly BalanceValidator validator; - - public BalanceValidatorTests() - { - this.validator = new BalanceValidator(); - } - - [SetUp] - public void SetUp() - { - this.builder = new BalanceModelBuilder(); - } - - [Test] - public void Balance_Valid_ReturnsSuccess() - { - var balance = builder.Generate(); - - var result = validator.Validate(balance); - - Assert.IsTrue(result.IsValid); - Assert.IsEmpty(result.Errors); - } - - [TestCase("")] - [TestCase(null)] - public void Balance_NullOrEmptyName_ReturnsRequiredError(string invalidName) - { - var account = builder.WithName(invalidName).Generate(); - - var result = validator.Validate(account); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual("Name is required", result.Errors[0].ErrorMessage); - } - - [Test] - public void Balance_BigName_ReturnsMaxLengthError() - { - var invalidName = new string('a', 201); - var account = builder.WithName(invalidName).Generate(); - - var result = validator.Validate(account); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual($"Name exceeds the max length of 200", result.Errors[0].ErrorMessage); - } - - [Test] - public void Balance_EmptyAccountId_ReturnsRequiredError() - { - var invalidId = Guid.Empty; - var account = builder.WithAccountId(invalidId).Generate(); - - var result = validator.Validate(account); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual("Account Id is required", result.Errors[0].ErrorMessage); - } - - [Test] - public void Balance_NullAccountId_ReturnsRequiredError() - { - var account = builder.WithAccountId((Guid)default).Generate(); - - var result = validator.Validate(account); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual("Account Id is required", result.Errors[0].ErrorMessage); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs deleted file mode 100644 index ddf3e2d..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Validators/CategoryValidatorTests.cs +++ /dev/null @@ -1,83 +0,0 @@ -using FinancialHub.Core.Application.Validators; - -namespace FinancialHub.Core.Application.Tests.Validators -{ - public class CategoryValidatorTests - { - private CategoryModelBuilder builder; - private readonly CategoryValidator validator; - - public CategoryValidatorTests() - { - this.validator = new CategoryValidator(); - } - - [SetUp] - public void SetUp() - { - this.builder = new CategoryModelBuilder(); - } - - [Test] - public void CategoryValidator_ValidCategory_ReturnsSuccess() - { - var category = builder.Generate(); - - var result = validator.Validate(category); - - Assert.IsTrue(result.IsValid); - Assert.IsEmpty(result.Errors); - } - - [TestCase("")] - [TestCase(null)] - public void CategoryValidator_NullOrEmptyName_ReturnsRequiredError(string invalidName) - { - var category = builder.WithName(invalidName).Generate(); - - var result = validator.Validate(category); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual("Name is required", result.Errors[0].ErrorMessage); - } - - [Test] - public void CategoryValidator_BigName_ReturnsMaxLengthError() - { - var invalidName = new string('a', 201); - var category = builder.WithName(invalidName).Generate(); - - var result = validator.Validate(category); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual($"Name exceeds the max length of 200", result.Errors[0].ErrorMessage); - } - - [TestCase("")] - [TestCase(null)] - public void CategoryValidator_NullOrEmptyDescription_ReturnsSuccess(string description) - { - var category = builder.WithDescription(description).Generate(); - - var result = validator.Validate(category); - - Assert.IsTrue(result.IsValid); - Assert.IsEmpty(result.Errors); - } - - [Test] - public void CategoryValidator_BigDescription_ReturnsMaxLengthError() - { - var invalidDescription = new string('a', 501); - var category = builder.WithDescription(invalidDescription).Generate(); - - var result = validator.Validate(category); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual($"Description exceeds the max length of 500", result.Errors[0].ErrorMessage); - } - } -} diff --git a/tests/core/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs b/tests/core/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs deleted file mode 100644 index 51f27a6..0000000 --- a/tests/core/FinancialHub.Core.Application.Tests/Validators/TransactionValidatorTests.cs +++ /dev/null @@ -1,84 +0,0 @@ -using FinancialHub.Core.Domain.Enums; -using FinancialHub.Core.Application.Validators; - -namespace FinancialHub.Core.Application.Tests.Validators -{ - public class TransactionValidatorTests - { - private TransactionModelBuilder builder; - private readonly TransactionValidator validator; - - public TransactionValidatorTests() - { - this.validator = new TransactionValidator(); - } - - [SetUp] - public void SetUp() - { - this.builder = new TransactionModelBuilder(); - } - - [Test] - public void TransactionValidator_ValidCategory_ReturnsSuccess() - { - var transaction = builder.Generate(); - - var result = validator.Validate(transaction); - - Assert.IsTrue(result.IsValid); - Assert.IsEmpty(result.Errors); - } - - [TestCase("")] - [TestCase(null)] - public void TransactionValidator_NullOrEmptyDescription_ReturnsSuccess(string description) - { - var transaction = builder.WithDescription(description).Generate(); - - var result = validator.Validate(transaction); - - Assert.IsTrue(result.IsValid); - Assert.IsEmpty(result.Errors); - } - - [Test] - public void TransactionValidator_BigDescription_ReturnsMaxLengthError() - { - var invalidDescription = new string('a', 501); - var transaction = builder.WithDescription(invalidDescription).Generate(); - - var result = validator.Validate(transaction); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual("Description exceeds the max length of 500", result.Errors[0].ErrorMessage); - } - - [Test] - public void TransactionValidator_TypeOutOfEnum_ReturnsError() - { - var type = 999; - var transaction = builder.WithType((TransactionType)type).Generate(); - - var result = validator.Validate(transaction); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual("Type has a range of values which does not include '999'", result.Errors[0].ErrorMessage); - } - - [Test] - public void TransactionValidator_StatusOutOfEnum_ReturnsError() - { - var status = 999; - var transaction = builder.WithStatus((TransactionStatus)status).Generate(); - - var result = validator.Validate(transaction); - - Assert.IsFalse(result.IsValid); - Assert.IsNotEmpty(result.Errors); - Assert.AreEqual("Status has a range of values which does not include '999'", result.Errors[0].ErrorMessage); - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs deleted file mode 100644 index 9e70b87..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Entities/BalanceEntityAssert.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Assertions.Entities -{ - public static class BalanceEntityAssert - { - public static void Equal(BalanceEntity expected, BalanceEntity result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.AccountId, result.AccountId); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - - public static void Equal(BalanceEntity expected, BalanceModel result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.AccountId, result.AccountId); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs deleted file mode 100644 index 65e805e..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/AccountModelAssert.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Assertions.Models -{ - public static class AccountModelAssert - { - public static void Equal(AccountModel expected, AccountModel result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.Description, result.Description); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs deleted file mode 100644 index 8817a50..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/BalanceModelAssert.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Assertions.Models -{ - public static class BalanceModelAssert - { - public static void Equal(BalanceModel expected, BalanceModel result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.AccountId, result.AccountId); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - - public static void Equal(BalanceModel expected, BalanceEntity result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.AccountId, result.AccountId); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs deleted file mode 100644 index ffb228c..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/CategoryModelAssert.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Assertions.Models -{ - public static class CategoryModelAssert - { - public static void Equal(CategoryModel expected, CategoryModel result) - { - Assert.AreEqual(expected.Name, result.Name); - Assert.AreEqual(expected.Description, result.Description); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs b/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs deleted file mode 100644 index b5d64ec..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Assertions/Models/TransactionModelAssert.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Assertions.Models -{ - public static class TransactionModelAssert - { - public static void Equal(TransactionModel expected, TransactionModel result) - { - Assert.AreEqual(expected.BalanceId, result.BalanceId); - Assert.AreEqual(expected.CategoryId, result.CategoryId); - Assert.AreEqual(expected.TargetDate, result.TargetDate); - Assert.AreEqual(expected.FinishDate, result.FinishDate); - Assert.AreEqual(expected.Amount, result.Amount); - Assert.AreEqual(expected.Type, result.Type); - Assert.AreEqual(expected.Description, result.Description); - Assert.AreEqual(expected.IsActive, result.IsActive); - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs deleted file mode 100644 index 2f09cf7..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/AccountEntityBuilder.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Builders.Entities -{ - public class AccountEntityBuilder : BaseEntityBuilder - { - public AccountEntityBuilder() : base() - { - this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); - this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); - this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); - } - - public AccountEntityBuilder WithName(string name) - { - this.RuleFor(c => c.Name, name); - return this; - } - - public AccountEntityBuilder WithDescription(string description) - { - this.RuleFor(c => c.Description, description); - return this; - } - - public AccountEntityBuilder WithActive(bool isActive) - { - this.RuleFor(c => c.IsActive, isActive); - return this; - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs deleted file mode 100644 index b999ed7..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/BalanceEntityBuilder.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Builders.Entities -{ - public class BalanceEntityBuilder : BaseEntityBuilder - { - public BalanceEntityBuilder() : base() - { - var account = new AccountEntityBuilder().Generate(); - - this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); - this.RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code); - this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000), 2)); - - this.RuleFor(x => x.Account, fake => account); - this.RuleFor(x => x.AccountId, fake => account.Id); - } - - public BalanceEntityBuilder WithName(string name) - { - this.RuleFor(c => c.Name, name); - return this; - } - - public BalanceEntityBuilder WithCurrency(string currency) - { - this.RuleFor(c => c.Currency, currency); - return this; - } - - public BalanceEntityBuilder WithAmount(decimal amount) - { - this.RuleFor(c => c.Amount, amount); - return this; - } - - public BalanceEntityBuilder WithAccount(AccountEntity account) - { - this.RuleFor(x => x.AccountId, fake => account.Id); - this.RuleFor(x => x.Account, fake => account); - return this; - } - - public BalanceEntityBuilder WithAccountId(Guid? accountId) - { - this.RuleFor(x => x.AccountId, fake => accountId); - this.Ignore( x => x.Account); - return this; - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs deleted file mode 100644 index 3573f60..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/CategoryEntityBuilder.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Builders.Entities -{ - public class CategoryEntityBuilder : BaseEntityBuilder - { - public CategoryEntityBuilder() : base() - { - this.RuleFor(x => x.Name, fake => fake.Finance.Random.Word()); - this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); - this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); - } - - public CategoryEntityBuilder WithName(string name) - { - this.RuleFor(c => c.Name, name); - return this; - } - - public CategoryEntityBuilder WithDescription(string description) - { - this.RuleFor(c => c.Description, description); - return this; - } - - public CategoryEntityBuilder WithActive(bool isActive) - { - this.RuleFor(c => c.IsActive, isActive); - return this; - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs deleted file mode 100644 index a1a5cc3..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Entities/TransactionEntityBuilder.cs +++ /dev/null @@ -1,90 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Domain.Tests.Builders.Entities -{ - public class TransactionEntityBuilder : BaseEntityBuilder - { - public TransactionEntityBuilder() : base() - { - var balance = new BalanceEntityBuilder().Generate(); - var category = new CategoryEntityBuilder().Generate(); - - this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000),2)); - this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); - this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); - this.RuleFor(x => x.Type, fake => fake.PickRandom()); - this.RuleFor(x => x.Status, fake => fake.PickRandom()); - - this.RuleFor(x => x.BalanceId, fake => balance.Id); - this.RuleFor(x => x.Balance, fake => balance); - this.RuleFor(x => x.CategoryId, fake => category.Id); - this.RuleFor(x => x.Category, fake => category); - - this.RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset()); - this.RuleFor(x => x.FinishDate, fake => fake.Date.RecentOffset()); - } - - public TransactionEntityBuilder WithCategoryId(Guid? categoryId) - { - this.RuleFor(x => x.CategoryId, fake => categoryId); - this.Ignore(x => x.Category); - return this; - } - - public TransactionEntityBuilder WithCategory(CategoryEntity category) - { - this.RuleFor(x => x.CategoryId, fake => category.Id); - this.RuleFor(x => x.Category, fake => category); - return this; - } - - public TransactionEntityBuilder WithBalance(BalanceEntity balance) - { - this.RuleFor(x => x.BalanceId, fake => balance.Id); - this.RuleFor(x => x.Balance, fake => balance); - return this; - } - - public TransactionEntityBuilder WithBalanceId(Guid? balanceId) - { - this.RuleFor(x => x.BalanceId, fake => balanceId); - this.Ignore( x => x.Balance); - return this; - } - - public TransactionEntityBuilder WithStatus(TransactionStatus transactionStatus) - { - this.RuleFor(x => x.Status, fake => transactionStatus); - return this; - } - - public TransactionEntityBuilder WithAmount(decimal amount) - { - this.RuleFor(x => x.Amount, fake => amount); - return this; - } - - public TransactionEntityBuilder WithType(TransactionType type) - { - this.RuleFor(x => x.Type, fake => type); - return this; - } - - public TransactionEntityBuilder WithActiveStatus(bool isActive) - { - this.RuleFor(x => x.IsActive, fake => isActive); - return this; - } - - public TransactionEntityBuilder WithTargetDate(DateTime date) - { - this.RuleFor(x => x.TargetDate, date); - return this; - } - public TransactionEntityBuilder WithTargetDateNextTo(DateTime date,int offset = 90) - { - this.RuleFor(x => x.TargetDate, fake => fake.Date.RecentOffset(offset, date)); - return this; - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs deleted file mode 100644 index 232695d..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/AccountModelBuilder.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Builders.Models -{ - public class AccountModelBuilder : BaseModelBuilder - { - public AccountModelBuilder() : base() - { - this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); - this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); - this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); - } - - public AccountModelBuilder WithName(string name) - { - this.RuleFor(c => c.Name, name); - return this; - } - - public AccountModelBuilder WithDescription(string description) - { - this.RuleFor(c => c.Description, description); - return this; - } - - public AccountModelBuilder WithActive(bool isActive) - { - this.RuleFor(c => c.IsActive, isActive); - return this; - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs deleted file mode 100644 index b9dec29..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/BalanceModelBuilder.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Builders.Models -{ - public class BalanceModelBuilder : BaseModelBuilder - { - public BalanceModelBuilder() : base() - { - var account = new AccountModelBuilder().Generate(); - - this.RuleFor(x => x.Name, fake => fake.Finance.AccountName()); - this.RuleFor(x => x.Currency, fake => fake.Finance.Currency().Code); - this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000), 2)); - - this.RuleFor(x => x.Account, fake => account); - this.RuleFor(x => x.AccountId, fake => account.Id); - } - - public BalanceModelBuilder WithName(string name) - { - this.RuleFor(c => c.Name, name); - return this; - } - - public BalanceModelBuilder WithCurrency(string currency) - { - this.RuleFor(c => c.Currency, currency); - return this; - } - - public BalanceModelBuilder WithAmount(decimal amount) - { - this.RuleFor(c => c.Amount, amount); - return this; - } - - public BalanceModelBuilder WithAccount(AccountModel account) - { - this.WithAccountId(account.Id); - this.RuleFor(x => x.Account, fake => account); - return this; - } - - public BalanceModelBuilder WithAccountId(Guid? accountId) - { - this.RuleFor(x => x.AccountId, fake => accountId); - this.Ignore(x => x.Account); - return this; - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs deleted file mode 100644 index 3f188fc..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/CategoryModelBuilder.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace FinancialHub.Core.Domain.Tests.Builders.Models -{ - public class CategoryModelBuilder : BaseModelBuilder - { - public CategoryModelBuilder() : base() - { - this.RuleFor(x => x.Name, fake => fake.Finance.Random.Word()); - this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); - this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool());; - } - - public CategoryModelBuilder WithName(string name) - { - this.RuleFor(c => c.Name, name); - return this; - } - - public CategoryModelBuilder WithDescription(string description) - { - this.RuleFor(c => c.Description, description); - return this; - } - - public CategoryModelBuilder WithActive(bool isActive) - { - this.RuleFor(c => c.IsActive, isActive); - return this; - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs b/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs deleted file mode 100644 index eaf2807..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Builders/Models/TransactionModelBuilder.cs +++ /dev/null @@ -1,84 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Domain.Tests.Builders.Models -{ - public class TransactionModelBuilder : BaseModelBuilder - { - public TransactionModelBuilder() : base() - { - var balance = new BalanceModelBuilder().Generate(); - var category = new CategoryModelBuilder().Generate(); - - this.RuleFor(x => x.Amount, fake => decimal.Round(fake.Random.Decimal(0, 10000),2)); - this.RuleFor(x => x.Description, fake => fake.Lorem.Sentences(5)); - this.RuleFor(x => x.IsActive, fake => fake.System.Random.Bool()); - this.RuleFor(x => x.Type, fake => fake.PickRandom()); - this.RuleFor(x => x.Status, fake => fake.PickRandom()); - - this.RuleFor(x => x.BalanceId, fake => balance.Id); - this.RuleFor(x => x.Balance, fake => balance); - - this.RuleFor(x => x.CategoryId, fake => category.Id); - this.RuleFor(x => x.Category, fake => category); - - } - - public TransactionModelBuilder WithDescription(string description) - { - this.RuleFor(c => c.Description, description); - return this; - } - - public TransactionModelBuilder WithCategoryId(Guid? categoryId) - { - this.RuleFor(x => x.CategoryId, fake => categoryId); - this.Ignore( x => x.Category); - return this; - } - - public TransactionModelBuilder WithCategory(CategoryModel category) - { - this.WithCategoryId(category.Id); - this.RuleFor(x => x.Category, fake => category); - return this; - } - - public TransactionModelBuilder WithBalance(BalanceModel balance) - { - this.WithBalanceId(balance.Id); - this.RuleFor(x => x.Balance, fake => balance); - return this; - } - - public TransactionModelBuilder WithBalanceId(Guid? balanceId) - { - this.RuleFor(x => x.BalanceId, fake => balanceId); - this.Ignore(x => x.Balance); - return this; - } - - public TransactionModelBuilder WithStatus(TransactionStatus transactionStatus) - { - this.RuleFor(x => x.Status, fake => transactionStatus); - return this; - } - - public TransactionModelBuilder WithAmount(decimal amount) - { - this.RuleFor(x => x.Amount, fake => amount); - return this; - } - - public TransactionModelBuilder WithType(TransactionType type) - { - this.RuleFor(x => x.Type, fake => type); - return this; - } - - public TransactionModelBuilder WithActiveStatus(bool isActive) - { - this.RuleFor(x => x.IsActive, fake => isActive); - return this; - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj b/tests/core/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj deleted file mode 100644 index bd6b070..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/FinancialHub.Core.Domain.Tests.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - net6.0 - enable - - false - - - - - - - - - - - - - - - - - - - diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs b/tests/core/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs deleted file mode 100644 index 2ef0d7e..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Queries/TransactionQueryTests.cs +++ /dev/null @@ -1,209 +0,0 @@ -using NUnit.Framework; -using System.Linq; -using FinancialHub.Core.Domain.Enums; -using FinancialHub.Core.Domain.Queries; -using FinancialHub.Core.Domain.Tests.Builders.Entities; - -namespace FinancialHub.Core.Domain.Tests.Queries -{ - public class TransactionQueryTests - { - private readonly Random random; - private TransactionEntityBuilder transactionBuilder; - - public TransactionQueryTests() - { - this.random = new Random(); - } - - [SetUp] - public void SetUp() - { - this.transactionBuilder = new TransactionEntityBuilder(); - } - - [Test] - public void Query_AlwaysFilterByActiveStatus() - { - var size = this.random.Next(10,100); - var entities = this.transactionBuilder.Generate(size); - - var query = new TransactionQuery().Query(); - - var expectedResult = entities.Where(x => x.IsActive); - var result = entities.Where(query); - - Assert.AreEqual(expectedResult, result); - } - - [Test] - public void Query_OnlyStartDate_FiltersStartDateMonth() - { - var thisDate = DateTime.Now; - var size = this.random.Next(10, 100); - - var entity = this.transactionBuilder - .WithTargetDate(thisDate) - .WithActiveStatus(true) - .Generate(); - var entities = this.transactionBuilder - .WithTargetDateNextTo(thisDate,30) - .Generate(size); - entities.Add(entity); - - var transactionQuery = new TransactionQuery() - { - StartDate = thisDate - }; - - var result = entities.Where(transactionQuery.Query()); - - foreach (var res in result) - { - Assert.AreEqual(thisDate.Month, res.TargetDate.Month); - Assert.IsTrue(res.IsActive); - } - Assert.Greater(result.Count(), 0); - } - - [Test] - public void Query_OnlyEndDate_DoNotFilterByDate() - { - var endDate = DateTime.Now.AddMonths(-2); - - var size = this.random.Next(10, 100); - var entities = this.transactionBuilder - .WithTargetDateNextTo(endDate) - .Generate(size); - - var transactionQuery = new TransactionQuery() - { - EndDate = endDate - }; - - var result = entities.Where(transactionQuery.Query()); - - var expectedResult = entities.Where(x => x.IsActive); - Assert.AreEqual(expectedResult, result); - } - - [Test] - public void Query_StartDateAndEndDate_FiltersBetweenDates() - { - var startDate = DateTime.Now.AddMonths(-2); - var endDate = startDate.AddMonths(2); - - var size = this.random.Next(10, 100); - var entities = this.transactionBuilder - .WithTargetDateNextTo(startDate) - .Generate(size); - - var transactionQuery = new TransactionQuery() - { - StartDate = startDate, - EndDate = endDate - }; - - var result = entities.Where(transactionQuery.Query()); - - var expectedResult = entities.Where(x => - x.IsActive && - x.TargetDate >= startDate && - x.TargetDate <= endDate - ); - - Assert.AreEqual(expectedResult, result); - } - - [Test] - public void Query_Balances_FiltersByBalance() - { - var size = this.random.Next(10, 100); - var entities = this.transactionBuilder.Generate(size); - - var balances = entities.Where(x=> x.Amount > 1000).Select(x => x.BalanceId).ToArray(); - - var transactionQuery = new TransactionQuery() - { - Balances = balances - }; - - var result = entities.Where(transactionQuery.Query()); - - var expectedResult = entities.Where( - x => x.IsActive && balances.Contains(x.BalanceId) - ); - - Assert.AreEqual(expectedResult, result); - } - - [Test] - public void Query_Categories_FiltersByCategory() - { - var size = this.random.Next(10, 100); - var entities = this.transactionBuilder.Generate(size); - - var categories = entities.Where(x => x.Amount > 1000).Select(x => x.CategoryId).ToArray(); - var transactionQuery = new TransactionQuery() - { - Categories = categories - }; - - var result = entities.Where(transactionQuery.Query()); - - var expectedResult = entities.Where( - x => x.IsActive && categories.Contains(x.CategoryId) - ); - - Assert.AreEqual(expectedResult, result); - } - - [Test] - public void Query_Types_FiltersByType() - { - var size = this.random.Next(10, 100); - var entities = this.transactionBuilder.Generate(size); - - var types = new TransactionType[1] - { - TransactionType.Earn - }; - var transactionQuery = new TransactionQuery() - { - Types = types - }; - - var result = entities.Where(transactionQuery.Query()); - - var expectedResult = entities.Where( - x => x.IsActive && types.Contains(x.Type) - ); - - Assert.AreEqual(expectedResult, result); - } - - [Test] - public void Query_Status_FiltersByStatus() - { - var size = this.random.Next(10, 100); - var entities = this.transactionBuilder.Generate(size); - - var status = new TransactionStatus[1] - { - TransactionStatus.Committed - }; - var transactionQuery = new TransactionQuery() - { - Status = status - }; - - var result = entities.Where(transactionQuery.Query()); - - var expectedResult = entities.Where( - x => x.IsActive && status.Contains(x.Status) - ); - - Assert.AreEqual(expectedResult, result); - } - } -} diff --git a/tests/core/FinancialHub.Core.Domain.Tests/Usings.cs b/tests/core/FinancialHub.Core.Domain.Tests/Usings.cs deleted file mode 100644 index 8cb909d..0000000 --- a/tests/core/FinancialHub.Core.Domain.Tests/Usings.cs +++ /dev/null @@ -1,15 +0,0 @@ -// System namespaces -global using System; - -// 3rd party test namespaces -global using NUnit.Framework; - -// Domain builder tests namespaces -global using FinancialHub.Common.Tests.Builders.Entities; -global using FinancialHub.Common.Tests.Builders.Models; - -// Domain Models namespaces -global using FinancialHub.Core.Domain.Entities; -global using FinancialHub.Core.Domain.Models; - -[assembly: Category("Unit")] \ No newline at end of file diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj b/tests/core/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj deleted file mode 100644 index 40a3373..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/FinancialHub.Core.Infra.Data.Tests.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net6.0 - - false - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs deleted file mode 100644 index ed00b72..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Accounts/AccountsRepositoryTests.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FinancialHub.Core.Infra.Data.Repositories; -using FinancialHub.Core.Infra.Data.Tests.Repositories.Base; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories -{ - public class AccountsRepositoryTests : BaseRepositoryTests - { - [SetUp] - protected override void Setup() - { - base.Setup(); - this.repository = new AccountsRepository(this.context); - this.builder = new AccountEntityBuilder(); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs deleted file mode 100644 index b1bda66..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.amount.cs +++ /dev/null @@ -1,95 +0,0 @@ -using FinancialHub.Core.Domain.Enums; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories -{ - public partial class BalancesRepositoryTests - { - [Test] - public async Task AddAmountAsync_EarnTransaction_AddsAmount() - { - var balanceId = Guid.NewGuid(); - var balance = this.balanceBuilder - .WithAmount(0) - .WithId(balanceId) - .Generate(); - await this.InsertData(balance); - this.context.ChangeTracker.Clear(); - - var amount = this.random.Next(10,1000); - var entity = this.transactionBuilder - .WithType(TransactionType.Earn) - .WithBalanceId(balanceId) - .WithAmount(amount) - .Generate(); - - var balanceResult = await this.balanceRepository.ChangeAmountAsync(balanceId,amount, TransactionType.Earn); - Assert.AreEqual(balance.Amount + entity.Amount, balanceResult.Amount); - } - - [Test] - public async Task AddAmountAsync_ExpenseTransaction_RemovesAmount() - { - var balanceId = Guid.NewGuid(); - var balance = this.balanceBuilder - .WithAmount(0) - .WithId(balanceId) - .Generate(); - await this.InsertData(balance); - this.context.ChangeTracker.Clear(); - - var amount = this.random.Next(10, 1000); - var entity = this.transactionBuilder - .WithType(TransactionType.Expense) - .WithBalanceId(balanceId) - .WithAmount(amount) - .Generate(); - - var balanceResult = await this.balanceRepository.ChangeAmountAsync(balanceId, amount, TransactionType.Expense); - Assert.AreEqual(balance.Amount - entity.Amount, balanceResult.Amount); - } - - [Test] - public async Task RemoveAmountAsync_EarnTransaction_RemovesAmount() - { - var balanceId = Guid.NewGuid(); - var balance = this.balanceBuilder - .WithAmount(0) - .WithId(balanceId) - .Generate(); - await this.InsertData(balance); - this.context.ChangeTracker.Clear(); - - var amount = this.random.Next(10, 1000); - var entity = this.transactionBuilder - .WithType(TransactionType.Earn) - .WithBalanceId(balanceId) - .WithAmount(amount) - .Generate(); - - var balanceResult = await this.balanceRepository.ChangeAmountAsync(balanceId, amount, TransactionType.Earn, true); - Assert.AreEqual(balance.Amount - entity.Amount, balanceResult.Amount); - } - - [Test] - public async Task RemoveAmountAsync_ExpenseTransaction_AddsAmount() - { - var balanceId = Guid.NewGuid(); - var balance = this.balanceBuilder - .WithAmount(0) - .WithId(balanceId) - .Generate(); - await this.InsertData(balance); - this.context.ChangeTracker.Clear(); - - var amount = this.random.Next(10, 1000); - var entity = this.transactionBuilder - .WithType(TransactionType.Expense) - .WithBalanceId(balanceId) - .WithAmount(amount) - .Generate(); - - var balanceResult = await this.balanceRepository.ChangeAmountAsync(balanceId, amount, TransactionType.Expense, true); - Assert.AreEqual(balance.Amount + entity.Amount, balanceResult.Amount); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs deleted file mode 100644 index 260ae84..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.create.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace FinancialHub.Core.Infra.Data.Tests.Repositories -{ - public partial class BalancesRepositoryTests - { - [Test] - public async Task CreateAsync_ShouldCreatesBalanceWithZeroAmount() - { - var item = this.GenerateObject(); - - var createdItem = await this.repository.CreateAsync(item); - - this.AssertCreated(createdItem); - Assert.Zero(createdItem.Amount); - - var databaseItem = context.Set().FirstOrDefault(x => x.Id == createdItem.Id); - Assert.Zero(databaseItem.Amount); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs deleted file mode 100644 index 35bf6e1..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Balances/BalancesRepositoryTests.cs +++ /dev/null @@ -1,25 +0,0 @@ -using FinancialHub.Core.Domain.Interfaces.Repositories; -using FinancialHub.Core.Infra.Data.Repositories; -using FinancialHub.Core.Infra.Data.Tests.Repositories.Base; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories -{ - public partial class BalancesRepositoryTests : BaseRepositoryTests - { - public TransactionEntityBuilder transactionBuilder; - public IBalancesRepository balanceRepository; - public BalanceEntityBuilder balanceBuilder; - - [SetUp] - protected override void Setup() - { - base.Setup(); - this.balanceRepository = new BalancesRepository(this.context); - this.balanceBuilder = new BalanceEntityBuilder(); - this.transactionBuilder = new TransactionEntityBuilder(); - - this.repository = this.balanceRepository; - this.builder = this.balanceBuilder; - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs deleted file mode 100644 index bd5c473..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.create.cs +++ /dev/null @@ -1,60 +0,0 @@ -using FinancialHub.Common.Entities; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests - where T : BaseEntity - { - protected virtual void AssertCreated(T createdItem) - { - Assert.IsNotNull(createdItem); - Assert.IsNotNull(createdItem.Id); - Assert.IsNotNull(createdItem.CreationTime); - Assert.IsNotNull(createdItem.UpdateTime); - Assert.IsInstanceOf(createdItem); - - Assert.IsNotEmpty(context.Set().ToList()); - } - - [Test] - [TestCase(TestName = "Create new Item", Category = "Create")] - public virtual async Task CreateAsync_ValidItem_AddsOneRow(T item = null) - { - item ??= this.GenerateObject(); - - var createdItem = await this.repository.CreateAsync(item); - - this.AssertCreated(createdItem); - } - - [Test] - [TestCase(TestName = "Create new Item with id", Category = "Create")] - public virtual async Task CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(T item = null) - { - var id = item == null ? Guid.NewGuid() : item.Id.GetValueOrDefault(); - item ??= this.GenerateObject(id); - - var createdItem = await this.repository.CreateAsync(item); - - this.AssertCreated(createdItem); - Assert.AreNotEqual(id,createdItem.Id); - } - - [Test] - [TestCase(TestName = "Create item with existing id", Category = "Create")] - public virtual async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithTheDifferentId(T item = null) - { - var id = item == null ? Guid.NewGuid() : item.Id.GetValueOrDefault(); - - item ??= this.GenerateObject(id); - await this.InsertData(item); - - item ??= this.GenerateObject(id); - - var result = await this.repository.CreateAsync(item); - - this.AssertCreated(result); - Assert.AreEqual(2,context.Set().Count()); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs deleted file mode 100644 index 1b38dac..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore; -using Microsoft.Data.Sqlite; -using FinancialHub.Common.Entities; -using FinancialHub.Common.Tests.Builders.Entities; -using FinancialHub.Common.Interfaces.Repositories; -using FinancialHub.Core.Infra.Data.Contexts; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests - where T : BaseEntity - { - protected BaseEntityBuilder builder; - protected FinancialHubContext context; - protected Random random; - - protected IBaseRepository repository; - - protected FinancialHubContext GetContext() - { - //TODO: use docker/ local sql database - var conn = new SqliteConnection("DataSource=:memory:"); - conn.Open(); - - var cfg = new DbContextOptionsBuilder().UseSqlite(conn); - cfg.EnableSensitiveDataLogging(true); - - return new FinancialHubContext( - cfg.Options - ); - } - - #region lifeCycle - [SetUp] - protected virtual void Setup() - { - this.random = new Random(); - this.context = this.GetContext(); - this.context.Database.EnsureCreated(); - } - - [TearDown] - protected virtual void TearDown() - { - this.context.Dispose(); - } - #endregion - - #region Generics - protected virtual async Task> InsertData(ICollection items) - where Y : BaseEntity - { - var list = new List(); - foreach (var item in items) - { - var entity = await this.context.Set().AddAsync(item); - await this.context.SaveChangesAsync(); - list.Add(entity.Entity); - } - await this.context.SaveChangesAsync(); - return list; - } - - protected virtual async Task InsertData(Y item) - where Y : BaseEntity - { - var res = await this.context.Set().AddAsync(item); - item.Id = res.Entity.Id; - await this.context.SaveChangesAsync(); - - return res.Entity; - } - - #endregion - - protected virtual ICollection GenerateData(int min = 1, int max = 100) - { - var count = new Random().Next(min, max); - return this.builder.Generate(count); - } - - protected virtual T GenerateObject(Guid? id = null) - { - if (id == null) - { - return this.builder.Generate(); - } - else - { - return this.builder.WithId(id.Value).Generate(); - } - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs deleted file mode 100644 index f4f5e71..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.delete.cs +++ /dev/null @@ -1,34 +0,0 @@ -using FinancialHub.Common.Entities; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests - where T : BaseEntity - { - [Test] - [TestCase(TestName = "Delete existing Item", Category = "Delete")] - public virtual async Task DeleteAsync_ExistingItem_AffectsOneRow() - { - var items = this.GenerateData(); - await this.InsertData(items); - this.context.ChangeTracker.Clear(); - - var affectedRows = await this.repository.DeleteAsync(items.First().Id.Value); - Assert.AreEqual(1, affectedRows); - Assert.AreEqual(items.Count - 1, context.Set().ToList().Count); - } - - [Test] - [TestCase(TestName = "Delete non existing Item", Category = "Delete")] - public virtual async Task DeleteAsync_NonExistingItem_AffectsNothing() - { - var items = this.GenerateData(); - await this.InsertData(items); - this.context.ChangeTracker.Clear(); - - var affectedRows = await this.repository.DeleteAsync(Guid.Empty); - Assert.AreEqual(0, affectedRows); - Assert.IsNotEmpty(context.Set().ToList()); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs deleted file mode 100644 index a5432cb..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.get.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System.Collections.Generic; -using FinancialHub.Common.Entities; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests - where T : BaseEntity - { - [Test] - [TestCase(TestName = "Get All Items without data",Category = "Get")] - public virtual async Task GetAllAsync_NoData_ReturnsEmpty() - { - var list = await this.repository.GetAllAsync(); - - Assert.IsEmpty(list); - Assert.IsInstanceOf>(list); - } - - [Test] - [TestCase(TestName = "Get All Items with data", Category = "Get")] - public virtual async Task GetAllAsync_Data_ReturnsItems() - { - var items = this.GenerateData(); - items = await this.InsertData(items); - - var list = await this.repository.GetAllAsync(); - - Assert.IsNotEmpty(list); - Assert.AreEqual(items,list); - Assert.IsInstanceOf>(list); - } - - [Test] - [TestCase(TestName = "Get Items with no filter", Category = "Get")] - public virtual async Task GetAsync_NoFilter_ReturnsAllItems() - { - var items = this.GenerateData(); - items = await this.InsertData(items); - - var list = await this.repository.GetAsync((x) => true); - - Assert.IsNotEmpty(list); - Assert.AreEqual(items, list); - Assert.IsInstanceOf>(list); - } - - [Test] - [TestCase(TestName = "Get Items not setting filter", Category = "Get")] - public virtual async Task GetAsync_NullFilter_ThrowsArgumentNullException() - { - await this.InsertData(this.GenerateData()); - - Assert.ThrowsAsync(typeof(ArgumentNullException), async () => await this.repository.GetAsync(null)); - } - - [Test] - [TestCase(TestName = "Get Items filtering", Category = "Get")] - public virtual async Task GetAsync_Filter_ReturnsFilteredItems() - { - var items = this.GenerateData(10,100); - items = await this.InsertData(items); - - var id = items.First().Id; - Func filter = (x) => x.Id == id; - var expectedResult = items.Where(filter); - - var list = await this.repository.GetAsync(filter); - - Assert.IsNotEmpty(list); - Assert.AreEqual(expectedResult, list); - Assert.IsInstanceOf>(list); - } - - [Test] - [TestCase(TestName = "Get Items with wrong filter", Category = "Get")] - public virtual async Task GetAsync_WrongFilter_ReturnsEmpty() - { - await this.InsertData(this.GenerateData(10, 100)); - - static bool filter(T x) => x.Id == Guid.Empty; - - var list = await this.repository.GetAsync(filter); - - Assert.IsEmpty(list); - Assert.IsInstanceOf>(list); - } - - [Test] - [TestCase(TestName = "Get By Id with existing id", Category = "Get")] - public virtual async Task GetByIdAsync_ExistingId_ReturnsItem() - { - var items = this.GenerateData(1); - items = await this.InsertData(items); - - var id = items.First().Id; - - var item = await this.repository.GetByIdAsync(id.Value); - - Assert.IsNotNull(item); - Assert.AreEqual(id,item.Id); - Assert.IsInstanceOf(item); - } - - [Test] - [TestCase(TestName = "Get By Id with non-existing id", Category = "Get")] - public virtual async Task GetByIdAsync_NonExistingId_ReturnsNull() - { - await this.InsertData(this.GenerateData()); - - var item = await this.repository.GetByIdAsync(Guid.Empty); - - Assert.IsNull(item); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs deleted file mode 100644 index c4a23f9..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Base/BaseRepositoryTests.update.cs +++ /dev/null @@ -1,38 +0,0 @@ -using FinancialHub.Common.Entities; -using Microsoft.EntityFrameworkCore; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories.Base -{ - public abstract partial class BaseRepositoryTests - where T : BaseEntity - { - [Test] - [TestCase(TestName = "Update existing Item", Category = "Update")] - public virtual async Task UpdateAsync_ExistingItem_UpdatesItem() - { - var item = this.GenerateObject(); - await this.InsertData(new T[1] { item }); - - var oldCreationTime = item.UpdateTime.GetValueOrDefault(); - - var updatedItem = await this.repository.UpdateAsync(item); - - Assert.IsNotNull(updatedItem); - Assert.IsNotNull(updatedItem.Id); - Assert.IsNotNull(updatedItem.CreationTime); - Assert.IsNotNull(updatedItem.UpdateTime); - Assert.AreNotEqual(oldCreationTime,updatedItem.UpdateTime); - Assert.IsInstanceOf(updatedItem); - } - - [Test] - [TestCase(TestName = "Update non existing Item", Category = "Update")] - public virtual void UpdateAsync_NonExistingItem_ThrowsDbUpdateConcurrencyException() - { - var id = Guid.NewGuid(); - var item = this.GenerateObject(id); - - Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(item)); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs deleted file mode 100644 index 241908d..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Categories/CategoriesRepositoryTests.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FinancialHub.Core.Infra.Data.Tests.Repositories.Base; -using FinancialHub.Core.Infra.Data.Repositories; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories -{ - public class CategoriesRepositoryTests : BaseRepositoryTests - { - [SetUp] - protected override void Setup() - { - base.Setup(); - this.repository = new CategoriesRepository(this.context); - this.builder = new CategoryEntityBuilder(); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs deleted file mode 100644 index da81620..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.create.cs +++ /dev/null @@ -1,185 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories -{ - public partial class TransactionsRepositoryTests - { - protected override void AssertCreated(TransactionEntity createdItem) - { - base.AssertCreated(createdItem); - - Assert.IsNotNull(createdItem.BalanceId); - Assert.IsNotNull(createdItem.Category); - Assert.AreEqual(createdItem.BalanceId, createdItem.Balance.Id); - Assert.AreEqual(createdItem.CategoryId, createdItem.Category.Id); - } - - [Test] - [TestCase(TestName = "Create new Transaction with valid Category and Balance", Category = "Create")] - public override async Task CreateAsync_ValidItem_AddsOneRow(TransactionEntity item = null) - { - var entity = this.GenerateObject(); - - entity.Category = await this.InsertData(entity.Category); - entity.Balance = await this.InsertData(entity.Balance); - - await base.CreateAsync_ValidItem_AddsOneRow(entity); - } - - [Test] - [TestCase(TestName = "Create new Item with id", Category = "Create")] - public async override Task CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(TransactionEntity item = null) - { - var entity = this.GenerateObject(); - - var generatedBalance = this.GenerateBalance(entity.BalanceId); - var generatedCategory = this.GenerateCategory(entity.CategoryId); - - await this.InsertData(generatedBalance); - await this.InsertData(generatedCategory); - - await base.CreateAsync_ValidItemWithId_AddsOneRowWithTheDifferentId(entity); - } - - [Test] - [TestCase(TestName = "Create item with existing id", Category = "Create")] - public override async Task CreateAsync_ValidItemWithExistingId_AddsOneRowWithTheDifferentId(TransactionEntity item = null) - { - var id = Guid.NewGuid(); - item = this.GenerateObject(id); - - //INSERTS BALANCE AND CATEGORY - var generatedBalance = this.GenerateBalance(item.BalanceId); - var generatedCategory = this.GenerateCategory(item.CategoryId); - - await this.InsertData(generatedBalance); - await this.InsertData(generatedCategory); - - item.Category = null; - item.Balance = null; - item = await this.InsertData(item); - - var newItem = this.GenerateObject(id); - newItem.CategoryId = generatedCategory.Id.GetValueOrDefault(); - newItem.BalanceId = generatedBalance.Id.GetValueOrDefault(); - - var result = await this.repository.CreateAsync(newItem); - - Assert.AreNotEqual(item.Id,newItem.Id); - this.AssertCreated(result); - Assert.AreEqual(2, context.Set().Count()); - } - - [Test] - [TestCase(TestName = "Create new Transaction without Updates/Creates Category", Category = "Create")] - public async Task CreateAsync_ValidItemWithCategory_DoesNotUpdateCategory() - { - var entity = this.GenerateObject(); - - var oldCategory = this.GenerateCategory(entity.CategoryId); - - await this.InsertData(entity.Balance); - await this.InsertData(oldCategory); - - entity.Category.Name = Guid.NewGuid().ToString(); - - var result = await this.repository.CreateAsync(entity); - - this.AssertCreated(result); - Assert.AreEqual(1,this.context.Categories.Count()); - - var category = this.context.Categories.FirstOrDefault(x => x.Id == entity.CategoryId); - - Assert.AreEqual(oldCategory, category); - Assert.AreEqual(oldCategory, result.Category); - } - - [Test] - [TestCase(TestName = "Create new Transaction without Updates/Creates Balance", Category = "Create")] - public async Task CreateAsync_ValidItemWithBalance_DoesNotUpdateBalance() - { - var entity = this.GenerateObject(); - - var oldBalance = this.GenerateBalance(entity.BalanceId); - - await this.InsertData(oldBalance); - await this.InsertData(entity.Category); - - entity.Balance.Name = Guid.NewGuid().ToString(); - - var result = await this.repository.CreateAsync(entity); - - this.AssertCreated(result); - Assert.AreEqual(1, this.context.Balances.Count()); - - var balance = this.context.Balances.FirstOrDefault(x => x.Id == entity.BalanceId); - - Assert.AreEqual(oldBalance, balance); - Assert.AreEqual(oldBalance, result.Balance); - } - - [Test] - [TestCase(TestName = "Create new Transaction with invalid Balance", Category = "Create")] - public async Task CreateAsync_InvalidBalanceId_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - - await this.InsertData(this.GenerateBalance()); - - entity.Category = await this.InsertData(entity.Category); - entity.CategoryId = entity.Category.Id.GetValueOrDefault(); - - Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); - - Assert.IsEmpty(this.context.Transactions); - Assert.AreEqual(1, this.context.Balances.Count()); - Assert.AreEqual(1, this.context.Categories.Count()); - } - - [Test] - [TestCase(TestName = "Create new Transaction with invalid Category", Category = "Create")] - public async Task CreateAsync_InvalidCategoryId_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - - await this.InsertData(entity.Balance); - await this.InsertData(this.GenerateCategory()); - - Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); - - Assert.IsEmpty(this.context.Transactions); - Assert.AreEqual(1, this.context.Balances.Count()); - Assert.AreEqual(1, this.context.Categories.Count()); - } - - [Test] - [TestCase(TestName = "Create new Transaction with no Balance", Category = "Create")] - public async Task CreateAsync_NoBalance_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - - await this.InsertData(entity.Category); - - entity.Balance = null; - - Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); - - Assert.IsEmpty(this.context.Transactions.ToList()); - } - - [Test] - [TestCase(TestName = "Create new Transaction with no Category", Category = "Create")] - public async Task CreateAsync_NoCategory_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - - await this.InsertData(entity.Balance); - - entity.Category = null; - - Assert.ThrowsAsync(async () => await this.repository.CreateAsync(entity)); - - Assert.IsEmpty(this.context.Transactions.ToList()); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs deleted file mode 100644 index dc28940..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.cs +++ /dev/null @@ -1,71 +0,0 @@ -using FinancialHub.Core.Infra.Data.Repositories; -using FinancialHub.Core.Infra.Data.Tests.Repositories.Base; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories -{ - public partial class TransactionsRepositoryTests : BaseRepositoryTests - { - private BalanceEntityBuilder balanceEntityBuilder; - private CategoryEntityBuilder categoryEntityBuilder; - - [SetUp] - protected override void Setup() - { - base.Setup(); - this.repository = new TransactionsRepository(this.context); - - this.balanceEntityBuilder = new BalanceEntityBuilder(); - this.categoryEntityBuilder = new CategoryEntityBuilder(); - - this.builder = new TransactionEntityBuilder(); - } - - protected TransactionEntity GenerateTransaction(Guid? id = null,Guid? accountId = null, Guid? categoryId = null) - { - var category = this.GenerateCategory(categoryId); - var balance = this.GenerateBalance(accountId); - - var build = (TransactionEntityBuilder)this.builder; - - if (id == null) - { - return build - .WithBalance(balance) - .WithCategory(category) - .Generate(); - } - else - { - return build - .WithBalance(balance) - .WithCategory(category) - .WithId(id.Value) - .Generate(); - } - } - - protected CategoryEntity GenerateCategory(Guid? id = null) - { - if (id == null) - { - return this.categoryEntityBuilder.Generate(); - } - else - { - return this.categoryEntityBuilder.WithId(id.Value).Generate(); - } - } - - protected BalanceEntity GenerateBalance(Guid? id = null) - { - if (id == null) - { - return this.balanceEntityBuilder.Generate(); - } - else - { - return this.balanceEntityBuilder.WithId(id.Value).Generate(); - } - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs deleted file mode 100644 index c695a91..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.delete.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace FinancialHub.Core.Infra.Data.Tests.Repositories -{ - public partial class TransactionsRepositoryTests - { - [Test] - public async Task DeleteAsync_DoesNotDeleteBalance() - { - var entity = this.GenerateObject(); - - await this.InsertData(entity.Balance); - await this.InsertData(entity.Category); - await this.InsertData(entity); - this.context.ChangeTracker.Clear(); - - var result = await this.repository.DeleteAsync(entity.Id.Value); - - Assert.AreEqual(1,result); - - Assert.IsEmpty(this.context.Transactions.Local); - Assert.AreEqual(1, this.context.Balances.Local.Count); - } - - [Test] - public async Task DeleteAsync_DoesNotDeleteCategory() - { - var entity = this.GenerateObject(); - - await this.InsertData(entity.Balance); - await this.InsertData(entity.Category); - await this.InsertData(entity); - this.context.ChangeTracker.Clear(); - - var result = await this.repository.DeleteAsync(entity.Id.Value); - - Assert.AreEqual(1, result); - - Assert.IsEmpty(this.context.Transactions.Local); - Assert.AreEqual(1, this.context.Categories.Local.Count); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs deleted file mode 100644 index e4e7657..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Repositories/Transactions/TransactionsRepositoryTests.update.cs +++ /dev/null @@ -1,121 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace FinancialHub.Core.Infra.Data.Tests.Repositories -{ - public partial class TransactionsRepositoryTests - { - protected async Task InsertTransaction(TransactionEntity entity) - { - await this.InsertData(entity.Balance); - await this.InsertData(entity.Category); - await this.InsertData(entity); - - context.Entry(entity).State = EntityState.Detached; - } - - [Test] - [TestCase(TestName = "Update Transaction but not Balance", Category = "Update")] - public async Task UpdateAsync_ValidItemWithBalance_DoesNotUpdateBalance() - { - var entity = this.GenerateObject(); - await this.InsertTransaction(entity); - - var changedEntity = this.GenerateTransaction(entity.Id, entity.BalanceId, entity.CategoryId); - - var result = await this.repository.UpdateAsync(changedEntity); - - this.AssertCreated(result); - Assert.AreEqual(1, this.context.Balances.Local.Count); - - var balance = this.context.Balances.FirstOrDefault(x => x.Id == changedEntity.BalanceId); - Assert.AreEqual(balance, result.Balance); - } - - [Test] - [TestCase(TestName = "Update Transaction but not Category", Category = "Update")] - public async Task UpdateAsync_ValidItemWithCategory_DoesNotUpdateCategory() - { - var entity = this.GenerateObject(); - await this.InsertTransaction(entity); - - var changedEntity = this.GenerateTransaction(entity.Id, entity.BalanceId, entity.CategoryId); - - var result = await this.repository.UpdateAsync(changedEntity); - - this.AssertCreated(result); - Assert.AreEqual(1, this.context.Categories.Local.Count); - - var category = this.context.Categories.FirstOrDefault(x => x.Id == changedEntity.CategoryId); - Assert.AreEqual(category, result.Category); - } - - [Test] - [TestCase(TestName = "Update Transaction changing Balance", Category = "Update")] - public async Task UpdateAsync_ChangeBalanceId_ChangesBalance() - { - var entity = this.GenerateObject(); - await this.InsertTransaction(entity); - - var newBalance = this.GenerateBalance(); - await this.InsertData(newBalance); - - entity.BalanceId = (Guid)newBalance.Id; - - var result = await this.repository.CreateAsync(entity); - - this.AssertCreated(result); - - Assert.AreEqual(newBalance.Id, result.BalanceId); - Assert.AreEqual(newBalance, result.Balance); - } - - [Test] - [TestCase(TestName = "Update Transaction changing Category", Category = "Update")] - public async Task UpdateAsync_ChangeCategoryId_ChangesCategory() - { - var entity = this.GenerateObject(); - await this.InsertTransaction(entity); - - var newCategory = this.GenerateCategory(); - await this.InsertData(newCategory); - - entity.CategoryId = (Guid)newCategory.Id; - - var result = await this.repository.CreateAsync(entity); - - this.AssertCreated(result); - - Assert.AreEqual(newCategory.Id, result.CategoryId); - Assert.AreEqual(newCategory, result.Category); - } - - [Test] - [TestCase(TestName = "Update Transaction with invalid Balance", Category = "Update")] - public async Task UpdateAsync_InvalidBalanceId_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - - await this.InsertTransaction(entity); - - var newCategory = this.GenerateCategory(); - entity.CategoryId = (Guid)newCategory.Id; - - Assert.ThrowsAsync( async () =>await this.repository.UpdateAsync(entity)); - } - - [Test] - [TestCase(TestName = "Update Transaction with invalid Category", Category = "Update")] - public async Task UpdateAsync_InvalidCategoryId_ThrowsDbUpdateException() - { - var entity = this.GenerateObject(); - var newCategory = this.GenerateCategory(); - - await this.InsertTransaction(entity); - - entity.CategoryId = (Guid)newCategory.Id; - entity.Category = newCategory; - - Assert.ThrowsAsync(async () => await this.repository.UpdateAsync(entity)); - } - } -} diff --git a/tests/core/FinancialHub.Core.Infra.Data.Tests/Usings.cs b/tests/core/FinancialHub.Core.Infra.Data.Tests/Usings.cs deleted file mode 100644 index f5b6e09..0000000 --- a/tests/core/FinancialHub.Core.Infra.Data.Tests/Usings.cs +++ /dev/null @@ -1,15 +0,0 @@ -// System namespaces -global using System; -global using System.Linq; -global using System.Threading.Tasks; - -// 3rd party test namespaces -global using NUnit.Framework; - -// Domain Project tests namespaces -global using FinancialHub.Core.Domain.Tests.Builders.Entities; - -// Domain Project namespaces -global using FinancialHub.Core.Domain.Entities; - -[assembly: Category("Unit")] \ No newline at end of file diff --git a/tests/core/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs deleted file mode 100644 index 98cbd0c..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/Base/BaseControllerTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Net.Http; - -namespace FinancialHub.Core.IntegrationTests.Base -{ - [TestFixtureSource(typeof(FinancialHubApiFixture))] - public abstract class BaseControllerTests - { - protected readonly FinancialHubApiFixture fixture; - protected HttpClient client => fixture.Client; - - protected readonly string baseEndpoint; - protected readonly Random random; - - protected BaseControllerTests(FinancialHubApiFixture fixture,string endpoint) - { - this.fixture = fixture; - this.baseEndpoint = endpoint; - this.random = new Random(); - } - - [SetUp] - public virtual void SetUp() - { - this.fixture.CreateDatabase(); - } - - [TearDown] - public virtual void TearDown() - { - this.fixture.ClearData(); - } - } -} diff --git a/tests/core/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs deleted file mode 100644 index fd4d237..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/Controllers/AccountsControllerTests.cs +++ /dev/null @@ -1,164 +0,0 @@ -namespace FinancialHub.Core.IntegrationTests -{ - public class AccountsControllerTests : BaseControllerTests - { - private AccountEntityBuilder entityBuilder; - private AccountModelBuilder modelBuilder; - private BalanceEntityBuilder balanceBuilder; - - public AccountsControllerTests(FinancialHubApiFixture fixture) : base(fixture, "/accounts") - { - - } - - public override void SetUp() - { - this.modelBuilder = new AccountModelBuilder(); - this.entityBuilder = new AccountEntityBuilder(); - this.balanceBuilder = new BalanceEntityBuilder(); - base.SetUp(); - } - - protected async Task AssertGetExists(AccountModel expected) - { - var getResponse = await this.client.GetAsync(baseEndpoint); - - var getResult = await getResponse.ReadContentAsync>(); - Assert.AreEqual(1, getResult?.Data.Count); - AccountModelAssert.Equal(expected, getResult!.Data.First()); - } - - protected void Populate(int amount = 10) - { - var account = this.entityBuilder.Generate(); - var data = this.balanceBuilder.WithAccountId(account.Id).Generate(amount); - this.fixture.AddData(account); - this.fixture.AddData(data.ToArray()); - } - - [Test] - public async Task GetAccountsBalances_ReturnBalances() - { - var expectedAmount = this.random.Next(1, 10); - this.Populate(this.random.Next(1, 10)); - - var account = this.entityBuilder.Generate(); - var data = this.balanceBuilder.WithAccountId(account.Id).Generate(expectedAmount); - this.fixture.AddData(account); - this.fixture.AddData(data.ToArray()); - - var response = await this.client.GetAsync($"{baseEndpoint}/{account.Id}/balances"); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.AreEqual(expectedAmount, result?.Data.Count); - } - - [Test] - public async Task GetAll_ReturnAccounts() - { - var data = entityBuilder.Generate(10); - this.fixture.AddData(data.ToArray()); - - var response = await this.client.GetAsync(baseEndpoint); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.AreEqual(data.Count, result?.Data.Count); - } - - [Test] - public async Task Post_ValidAccount_ReturnCreatedAccount() - { - var data = this.modelBuilder.Generate(); - - var response = await this.client.PostAsync(baseEndpoint, data); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - AccountModelAssert.Equal(data, result!.Data); - } - - [Test] - public async Task Post_ValidAccount_CreateAccount() - { - var body = this.modelBuilder.Generate(); - - await this.client.PostAsync(baseEndpoint, body); - - await this.AssertGetExists(body); - } - - [Test] - public async Task Put_ExistingAccount_ReturnUpdatedAccount() - { - var id = Guid.NewGuid(); - this.fixture.AddData(entityBuilder.WithId(id).Generate()); - - var body = this.modelBuilder.WithId(id).Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - Assert.AreEqual(body.Id, result?.Data.Id); - AccountModelAssert.Equal(body,result!.Data); - } - - [Test] - public async Task Put_ExistingAccount_UpdatesAccount() - { - var id = Guid.NewGuid(); - this.fixture.AddData(entityBuilder.WithId(id).Generate()); - - var body = this.modelBuilder.WithId(id).Generate(); - await this.client.PutAsync($"{baseEndpoint}/{id}", body); - - await this.AssertGetExists(body); - } - - [Test] - public async Task Put_NonExistingAccount_ReturnNotFoundError() - { - var id = Guid.NewGuid(); - var body = this.modelBuilder.WithId(id).Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); - Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); - - var result = await response.ReadContentAsync(); - Assert.AreEqual($"Not found account with id {id}", result!.Message); - } - - [Test] - [Ignore("Endpoint disabled")] - public async Task Delete_ReturnNoContent() - { - var id = Guid.NewGuid(); - - var data = entityBuilder.WithId(id).Generate(); - this.fixture.AddData(data); - - var response = await this.client.DeleteAsync($"{baseEndpoint}/{id}"); - Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); - } - - [Test] - [Ignore("Endpoint disabled")] - public async Task Delete_RemovesAccountFromDatabase() - { - var id = Guid.NewGuid(); - - var data = entityBuilder.WithId(id).Generate(); - this.fixture.AddData(data); - - await this.client.DeleteAsync($"{baseEndpoint}/{id}"); - - var getResponse = await this.client.GetAsync(baseEndpoint); - var getResult = await getResponse.ReadContentAsync>(); - Assert.IsEmpty(getResult!.Data); - } - } -} \ No newline at end of file diff --git a/tests/core/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs deleted file mode 100644 index cc35466..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/Controllers/BalancesControllerTests.cs +++ /dev/null @@ -1,193 +0,0 @@ -namespace FinancialHub.Core.IntegrationTests -{ - public class BalancesControllerTests : BaseControllerTests - { - private BalanceEntityBuilder entityBuilder; - private BalanceModelBuilder modelBuilder; - private AccountEntityBuilder accountBuilder; - - public BalancesControllerTests(FinancialHubApiFixture fixture) : base(fixture ,"/balances") - { - } - - public override void SetUp() - { - this.entityBuilder = new BalanceEntityBuilder(); - this.modelBuilder = new BalanceModelBuilder(); - this.accountBuilder = new AccountEntityBuilder(); - base.SetUp(); - } - - protected void AssertExists(BalanceModel expected) - { - var data = this.fixture.GetData(); - BalanceModelAssert.Equal(expected, data.First()); - } - - [Test] - public async Task Post_ValidBalance_ReturnsCreatedBalance() - { - var account = this.accountBuilder.Generate(); - this.fixture.AddData(account); - var data = this.modelBuilder.WithAccountId(account.Id).Generate(); - - var response = await this.client.PostAsync(baseEndpoint, data); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - BalanceModelAssert.Equal(data, result!.Data); - } - - [Test] - public async Task Post_ValidBalance_CreatesBalance() - { - var account = this.accountBuilder.Generate(); - this.fixture.AddData(account); - var body = this.modelBuilder.WithAccountId(account.Id).Generate(); - - await this.client.PostAsync(baseEndpoint, body); - - this.AssertExists(body); - } - - [Test] - public async Task Post_ValidBalance_CreatesBalanceWithAmountZero() - { - var account = this.accountBuilder.Generate(); - this.fixture.AddData(account); - var body = this.modelBuilder.WithAccountId(account.Id).Generate(); - - var response = await this.client.PostAsync(baseEndpoint, body); - var result = await response.ReadContentAsync>(); - Assert.Zero(result!.Data.Amount); - } - - [Test] - public async Task Put_ExistingBalance_ReturnsUpdatedBalance() - { - var account = this.accountBuilder.Generate(); - this.fixture.AddData(account); - - var id = Guid.NewGuid(); - var entity = entityBuilder - .WithAccountId(account.Id) - .WithId(id) - .Generate(); - this.fixture.AddData(entity); - - var data = this.modelBuilder - .WithAccountId(account.Id) - .WithId(id) - .Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{id}", data); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - BalanceModelAssert.Equal(data, result!.Data); - } - - [Test] - public async Task Put_ExistingBalance_UpdatesBalance() - { - var account = this.accountBuilder.Generate(); - this.fixture.AddData(account); - - var id = Guid.NewGuid(); - var entity = entityBuilder - .WithAccountId(account.Id) - .WithId(id) - .Generate(); - this.fixture.AddData(entity); - - var data = this.modelBuilder - .WithAccountId(account.Id) - .WithId(id) - .Generate(); - - await this.client.PutAsync($"{baseEndpoint}/{id}", data); - - this.AssertExists(data); - } - - [Test] - public async Task Put_ExistingBalance_DoesNotUpdatesBalanceAmount() - { - var account = this.accountBuilder.Generate(); - this.fixture.AddData(account); - - var id = Guid.NewGuid(); - var entity = entityBuilder - .WithAccountId(account.Id) - .WithAmount(0) - .WithId(id) - .Generate(); - this.fixture.AddData(entity); - - var data = this.modelBuilder - .WithAccountId(account.Id) - .WithId(id) - .Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{id}", data); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.Zero(result!.Data.Amount); - } - - [Test] - public async Task Put_NotExistingBalance_ReturnsNotFound() - { - var account = this.accountBuilder.Generate(); - this.fixture.AddData(account); - - var entity = entityBuilder - .WithAccountId(account.Id) - .Generate(); - this.fixture.AddData(entity); - - var id = Guid.NewGuid(); - var data = this.modelBuilder - .WithAccountId(account.Id) - .WithId(id) - .Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{id}", data); - Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); - - var result = await response.ReadContentAsync(); - Assert.AreEqual(result?.Message, $"Not found Balance with id {id}"); - } - - [Test] - [Ignore("Endpoint disabled")] - public async Task Delete_ReturnsNoContent() - { - var id = Guid.NewGuid(); - - var data = entityBuilder.WithId(id).Generate(); - this.fixture.AddData(data); - - var response = await this.client.DeleteAsync($"{baseEndpoint}/{id}"); - Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); - } - - [Test] - [Ignore("Endpoint disabled")] - public async Task Delete_RemovesBalanceFromDatabase() - { - var id = Guid.NewGuid(); - - var data = entityBuilder.WithId(id).Generate(); - this.fixture.AddData(data); - - await this.client.DeleteAsync($"{baseEndpoint}/{id}"); - - var result = this.fixture.GetData(); - Assert.IsEmpty(result); - } - } -} diff --git a/tests/core/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs deleted file mode 100644 index aa83f76..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/Controllers/CategoriesControllerTests.cs +++ /dev/null @@ -1,134 +0,0 @@ -namespace FinancialHub.Core.IntegrationTests -{ - public class CategoriesControllerTests : BaseControllerTests - { - private CategoryEntityBuilder dataBuilder; - private CategoryModelBuilder builder; - - public CategoriesControllerTests(FinancialHubApiFixture fixture) : base(fixture, "/categories") - { - - } - - public override void SetUp() - { - this.dataBuilder = new CategoryEntityBuilder(); - this.builder = new CategoryModelBuilder(); - base.SetUp(); - } - - protected async Task AssertGetExists(CategoryModel expected) - { - var getResponse = await this.client.GetAsync(baseEndpoint); - - var getResult = await getResponse.ReadContentAsync>(); - Assert.AreEqual(1, getResult?.Data.Count); - CategoryModelAssert.Equal(expected, getResult!.Data.First()); - } - - [Test] - public async Task GetAll_ReturnCategories() - { - var data = dataBuilder.Generate(10); - this.fixture.AddData(data.ToArray()); - - var response = await this.client.GetAsync(baseEndpoint); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.AreEqual(data.Count, result?.Data.Count); - } - - [Test] - public async Task Post_ValidCategory_ReturnCreatedCategory() - { - var data = this.builder.Generate(); - - var response = await this.client.PostAsync(baseEndpoint, data); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - CategoryModelAssert.Equal(data, result!.Data); - } - - [Test] - public async Task Post_ValidCategory_CreateCategory() - { - var body = this.builder.Generate(); - - await this.client.PostAsync(baseEndpoint, body); - - await this.AssertGetExists(body); - } - - [Test] - public async Task Put_ExistingCategory_ReturnUpdatedCategory() - { - var id = Guid.NewGuid(); - this.fixture.AddData(dataBuilder.WithId(id).Generate()); - - var body = this.builder.WithId(id).Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - Assert.AreEqual(body.Id, result?.Data.Id); - CategoryModelAssert.Equal(body,result!.Data); - } - - [Test] - public async Task Put_ExistingCategory_UpdatesCategory() - { - var id = Guid.NewGuid(); - this.fixture.AddData(dataBuilder.WithId(id).Generate()); - - var body = this.builder.WithId(id).Generate(); - await this.client.PutAsync($"{baseEndpoint}/{id}", body); - - await this.AssertGetExists(body); - } - - [Test] - public async Task Put_NonExistingCategory_ReturnNotFoundError() - { - var id = Guid.NewGuid(); - var body = this.builder.WithId(id).Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{id}", body); - Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); - - var result = await response.ReadContentAsync(); - Assert.AreEqual($"Not found category with id {id}", result!.Message); - } - - [Test] - public async Task Delete_ReturnNoContent() - { - var id = Guid.NewGuid(); - - var data = dataBuilder.WithId(id).Generate(); - this.fixture.AddData(data); - - var response = await this.client.DeleteAsync($"{baseEndpoint}/{id}"); - Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); - } - - [Test] - public async Task Delete_RemovesCategoryFromDatabase() - { - var id = Guid.NewGuid(); - - var data = dataBuilder.WithId(id).Generate(); - this.fixture.AddData(data); - - await this.client.DeleteAsync($"{baseEndpoint}/{id}"); - - var getResponse = await this.client.GetAsync(baseEndpoint); - var getResult = await getResponse.ReadContentAsync>(); - Assert.IsEmpty(getResult!.Data); - } - } -} \ No newline at end of file diff --git a/tests/core/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs b/tests/core/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs deleted file mode 100644 index 104cdfb..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/Controllers/TransactionsControllerTests.cs +++ /dev/null @@ -1,214 +0,0 @@ -namespace FinancialHub.Core.IntegrationTests -{ - public class TransactionsControllerTests : BaseControllerTests - { - private TransactionEntityBuilder entityBuilder; - private TransactionModelBuilder modelBuilder; - - public TransactionsControllerTests(FinancialHubApiFixture fixture) : base(fixture, "/Transactions") - { - - } - - public override void SetUp() - { - this.entityBuilder = new TransactionEntityBuilder(); - this.modelBuilder = new TransactionModelBuilder(); - base.SetUp(); - } - - protected async Task AssertGetExists(TransactionModel expected) - { - var getResponse = await this.client.GetAsync(baseEndpoint); - - var getResult = await getResponse.ReadContentAsync>(); - Assert.AreEqual(1, getResult?.Data.Count); - TransactionModelAssert.Equal(expected, getResult!.Data.First()); - } - - protected TransactionModel CreateValidTransaction(bool isActive = true) - { - var model = entityBuilder.Generate(); - - this.fixture.AddData(model.Category); - this.fixture.AddData(model.Balance); - - return modelBuilder - .WithBalanceId(model.Balance.Id) - .WithCategoryId(model.Category.Id) - .WithActiveStatus(isActive) - .Generate(); - } - - protected TransactionModel InsertTransaction(bool isActive = true) - { - var model = entityBuilder.Generate(); - - var account = this.fixture.AddData(model.Balance.Account).First(); - model.Balance.Account = null; - model.Balance.AccountId = account.Id.GetValueOrDefault(); - - var balance = this.fixture.AddData(model.Balance).First(); - var category = this.fixture.AddData(model.Category).First(); - - var data = entityBuilder - .WithBalanceId(balance.Id) - .WithCategoryId(category.Id) - .WithActiveStatus(isActive) - .Generate(); - - data = this.fixture.AddData(data).First(); - - return modelBuilder - .WithBalanceId(balance.Id) - .WithCategoryId(category.Id) - .WithActiveStatus(isActive) - .WithId(data.Id.GetValueOrDefault()) - .Generate(); - } - - protected TransactionModel[] InsertTransactions(bool isActive = true) - { - var model = entityBuilder.Generate(); - - this.fixture.AddData(model.Category); - this.fixture.AddData(model.Balance); - - var data = entityBuilder - .WithBalanceId(model.Balance.Id) - .WithCategoryId(model.Category.Id) - .WithActiveStatus(isActive) - .Generate(10); - - this.fixture.AddData(data.ToArray()); - - - return data.Select( - x => modelBuilder - .WithBalanceId(x.BalanceId) - .WithCategoryId(x.BalanceId) - .WithActiveStatus(isActive) - .WithId(x.Id.GetValueOrDefault()) - .Generate() - ).ToArray(); - } - - [Test] - public async Task GetAll_ReturnActiveTransactions() - { - var data = this.InsertTransactions(); - - var response = await this.client.GetAsync(baseEndpoint); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.AreEqual(data.Length, result?.Data.Count); - } - - [Test] - public async Task GetAll_DoesNotReturnNotActiveTransactions() - { - this.InsertTransactions(false); - - var response = await this.client.GetAsync(baseEndpoint); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.Zero(result!.Data.Count); - } - - [Test] - public async Task Post_ValidTransaction_ReturnCreatedTransaction() - { - var data = this.CreateValidTransaction(); - - var response = await this.client.PostAsync(baseEndpoint, data); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - TransactionModelAssert.Equal(data, result!.Data); - } - - [Test] - public async Task Post_ValidTransaction_CreateTransaction() - { - var body = this.CreateValidTransaction(); - - await this.client.PostAsync(baseEndpoint, body); - - await this.AssertGetExists(body); - } - - [Test] - public async Task Put_ExistingTransaction_ReturnUpdatedTransaction() - { - var data = this.InsertTransaction(true); - - var body = this.modelBuilder - .WithBalanceId(data.BalanceId) - .WithCategoryId(data.CategoryId) - .WithActiveStatus(data.IsActive) - .WithId(data.Id.GetValueOrDefault()) - .Generate(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{data.Id}", body); - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - - var result = await response.ReadContentAsync>(); - Assert.IsNotNull(result?.Data); - Assert.AreEqual(body.Id, result?.Data.Id); - TransactionModelAssert.Equal(body,result!.Data); - } - - [Test] - public async Task Put_ExistingTransaction_UpdatesTransaction() - { - var data = this.InsertTransaction(true); - - var body = this.modelBuilder - .WithBalanceId(data.BalanceId) - .WithCategoryId(data.CategoryId) - .WithActiveStatus(data.IsActive) - .WithId(data.Id.GetValueOrDefault()) - .Generate(); - await this.client.PutAsync($"{baseEndpoint}/{data.Id}", body); - - await this.AssertGetExists(body); - } - - [Test] - public async Task Put_NonExistingTransaction_ReturnNotFoundError() - { - var body = this.CreateValidTransaction(); - - var response = await this.client.PutAsync($"{baseEndpoint}/{body.Id}", body); - Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); - - var result = await response.ReadContentAsync(); - Assert.AreEqual($"Not found Transaction with id {body.Id}", result!.Message); - } - - [Test] - public async Task Delete_ReturnNoContent() - { - var body = this.InsertTransaction(); - - var response = await this.client.DeleteAsync($"{baseEndpoint}/{body.Id}"); - - Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); - } - - [Test] - public async Task Delete_RemovesTransactionFromDatabase() - { - var body = this.InsertTransaction(); - - await this.client.DeleteAsync($"{baseEndpoint}/{body.Id}"); - - var getResponse = await this.client.GetAsync(baseEndpoint); - var getResult = await getResponse.ReadContentAsync>(); - Assert.IsEmpty(getResult!.Data); - } - } -} \ No newline at end of file diff --git a/tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs b/tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs deleted file mode 100644 index cde0c68..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpClientExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Net.Http; -using System.Text; -using System.Text.Json; - -namespace FinancialHub.Core.IntegrationTests.Extensions -{ - public static class HttpClientExtensions - { - public static HttpContent CreateContent(T content) - { - return new StringContent(JsonSerializer.Serialize(content), Encoding.UTF8, "application/json"); - } - - public static async Task PostAsync(this HttpClient client, string requestUri, T? content) - { - return await client.PostAsync(requestUri, CreateContent(content)); - } - - public static async Task PutAsync(this HttpClient client, string requestUri, T? content) - { - return await client.PutAsync(requestUri, CreateContent(content)); - } - } -} diff --git a/tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs b/tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs deleted file mode 100644 index 256becc..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/Extensions/HttpResponseMessageExtensions.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Net.Http; -using System.Text.Json; - -namespace FinancialHub.Core.IntegrationTests.Extensions -{ - public static class HttpResponseMessageExtensions - { - public static async Task ReadContentAsync(this HttpResponseMessage response) - { - try - { - var stream = await response.Content.ReadAsStreamAsync(); - - return await JsonSerializer.DeserializeAsync(stream, - new JsonSerializerOptions() - { - PropertyNameCaseInsensitive = true - } - ); - } - catch (Exception e) - { - var json = await response.Content.ReadAsStringAsync(); - throw new Exception($"Not able to Read the content:\n{json}",e); - } - } - } -} diff --git a/tests/core/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj b/tests/core/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj deleted file mode 100644 index 0cdb39f..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/FinancialHub.Core.IntegrationTests.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - net6.0 - enable - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/core/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs b/tests/core/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs deleted file mode 100644 index 3905598..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/Setup/FinancialHubFixture.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Net.Http; -using System.Collections; -using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.Extensions.DependencyInjection; -using FinancialHub.Core.WebApi; -using FinancialHub.Core.Infra.Data.Contexts; -using Microsoft.AspNetCore.Hosting; - -namespace FinancialHub.Core.IntegrationTests.Setup -{ - public class FinancialHubApiFixture : IEnumerable, IDisposable - { - public HttpClient Client { get; protected set; } - public WebApplicationFactory Api { get; protected set; } - - public FinancialHubApiFixture() - { - this.Api = new WebApplicationFactory() - .WithWebHostBuilder( - builder => - { - builder.UseEnvironment("Testing"); - } - ); - - this.Client = this.Api.CreateClient(); - } - - public T[] AddData(params T[] data) - where T : BaseEntity - { - using (var scope = this.Api.Server.Services.CreateScope()) - { - var context = scope.ServiceProvider.GetRequiredService(); - context.Set().AddRange(data); - context.SaveChanges(); - - context.ChangeTracker.Clear(); - - var res = context.Set().ToArray(); - return res.Where(x => data.Any(y => y.Id == x.Id)).ToArray(); - } - } - - public IEnumerable GetData() - where T : BaseEntity - { - using (var scope = this.Api.Server.Services.CreateScope()) - { - var context = scope.ServiceProvider.GetRequiredService(); - return context.Set().ToArray(); - } - } - - public void CreateDatabase() - { - using(var scope = this.Api.Services.CreateScope()) - { - //TODO: run migrations - var db = scope.ServiceProvider.GetRequiredService(); - db.Database.EnsureCreated(); - } - } - - public void ClearData() - { - using (var scope = this.Api.Server.Services.CreateScope()) - { - var context = scope.ServiceProvider.GetRequiredService(); - context.Database.EnsureDeleted(); - } - } - - public void Dispose() - { - this.Api.Dispose(); - this.Client.Dispose(); - GC.SuppressFinalize(this); - } - - public IEnumerator GetEnumerator() - { - yield return this; - } - } -} diff --git a/tests/core/FinancialHub.Core.IntegrationTests/Usings.cs b/tests/core/FinancialHub.Core.IntegrationTests/Usings.cs deleted file mode 100644 index 5a764cd..0000000 --- a/tests/core/FinancialHub.Core.IntegrationTests/Usings.cs +++ /dev/null @@ -1,39 +0,0 @@ -// System namespaces -global using System; -global using System.Net; -global using System.Linq; -global using System.Collections.Generic; -global using System.Threading.Tasks; - -// 3rd party test namespaces -global using NUnit.Framework; - -// Domain Asserts namespaces -global using FinancialHub.Core.Domain.Tests.Assertions.Models; - -// Common Models namespaces -global using FinancialHub.Common.Models; -global using FinancialHub.Common.Entities; - -// Domain Models namespaces -global using FinancialHub.Core.Domain.Models; -global using FinancialHub.Core.Domain.Entities; - -// Common Responses namespaces -global using FinancialHub.Common.Responses.Success; -global using FinancialHub.Common.Responses.Errors; - -// Common Builders namespaces -global using FinancialHub.Common.Tests.Builders.Models; -global using FinancialHub.Common.Tests.Builders.Entities; - -// Domain Builders namespaces -global using FinancialHub.Core.Domain.Tests.Builders.Models; -global using FinancialHub.Core.Domain.Tests.Builders.Entities; - -// Integration Tests SetUp namespaces -global using FinancialHub.Core.IntegrationTests.Base; -global using FinancialHub.Core.IntegrationTests.Setup; -global using FinancialHub.Core.IntegrationTests.Extensions; - -[assembly: Category("Integration")] \ No newline at end of file diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs deleted file mode 100644 index e6041c6..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.create.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class AccountsControllerTests - { - [Test] - [TestCase(Description = "Create account returns ok", Category = "Create")] - public async Task CreateAccount_ServiceSuccess_ReturnsOk() - { - var body = this.accountModelBuilder.Generate(); - var mockResult = new ServiceResult(body); - - this.mockAccountService - .Setup(x => x.CreateAsync(body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.CreateAccount(body); - - var result = response as ObjectResult; - - Assert.AreEqual(200, result?.StatusCode); - Assert.IsInstanceOf>(result?.Value); - - var listResponse = result?.Value as SaveResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockAccountService.Verify(x => x.CreateAsync(body), Times.Once); - } - - [Test] - [TestCase(Description = "Create account returns Bad Request", Category = "Create")] - public async Task CreateAccount_ServiceError_ReturnsBadRequest() - { - var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.accountModelBuilder.Generate(); - - var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - - this.mockAccountService - .Setup(x => x.CreateAsync(body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.CreateAccount(body); - - var result = response as ObjectResult; - - Assert.AreEqual(400, result?.StatusCode); - Assert.IsInstanceOf(result?.Value); - - var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); - - this.mockAccountService.Verify(x => x.CreateAsync(body), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs deleted file mode 100644 index 7045a5c..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.cs +++ /dev/null @@ -1,28 +0,0 @@ -using FinancialHub.Core.WebApi.Controllers; -using FinancialHub.Core.Domain.Interfaces.Services; - -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class AccountsControllerTests - { - private Random random; - - private AccountModelBuilder accountModelBuilder; - - private AccountsController controller; - private Mock mockService; - private Mock mockAccountService; - - [SetUp] - public void Setup() - { - this.random = new Random(); - - this.accountModelBuilder = new AccountModelBuilder(); - - this.mockService = new Mock(); - this.mockAccountService = new Mock(); - this.controller = new AccountsController(mockAccountService.Object ,this.mockService.Object); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs deleted file mode 100644 index 40488ef..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.delete.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class AccountsControllerTests - { - [Test] - [TestCase(Description = "Delete Account returns NoContent", Category = "Delete")] - public async Task DeleteMyAccounts_ServiceSuccess_ReturnsNoContent() - { - var mock = this.accountModelBuilder.Generate(); - var response = await this.controller.DeleteAccount(mock.Id.GetValueOrDefault()); - - var result = response as ObjectResult; - - Assert.IsNull(result?.Value); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs deleted file mode 100644 index 6a5d7ad..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.get.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class AccountsControllerTests - { - [Test] - [TestCase(Description = "Get Accounts returns ok", Category = "Get")] - public async Task GetMyAccounts_ServiceSuccess_ReturnsOk() - { - var mockResult = new ServiceResult>( - accountModelBuilder.Generate(random.Next(0, 10)) - ); - - this.mockService - .Setup(x => x.GetAllByUserAsync(It.IsAny())) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.GetMyAccounts(); - var result = (ObjectResult)response; - - Assert.AreEqual(200, result.StatusCode); - Assert.IsInstanceOf>(result.Value); - - var listResponse = result.Value as ListResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockService.Verify(x => x.GetAllByUserAsync(It.IsAny()), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs deleted file mode 100644 index 2c1ca6c..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Accounts/AccountsControllerTests.update.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class AccountsControllerTests - { - [Test] - [TestCase(Description = "Update account existing Returns Ok", Category = "Update")] - public async Task UpdateAccount_Valid_ReturnsOk() - { - var body = this.accountModelBuilder.Generate(); - var guid = body.Id.GetValueOrDefault(); - var mockResult = new ServiceResult(body); - - this.mockService - .Setup(x => x.UpdateAsync(guid, body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.UpdateAccount(guid, body); - - var result = response as ObjectResult; - - Assert.AreEqual(200, result?.StatusCode); - Assert.IsInstanceOf>(result?.Value); - - var listResponse = result?.Value as SaveResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); - } - - [Test] - [TestCase(Description = "Update Account invalid account returns BadRequest", Category = "Update")] - public async Task UpdateAccount_Invalid_ReturnsBadRequest() - { - var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.accountModelBuilder.Generate(); - var guid = body.Id.GetValueOrDefault(); - - var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - - this.mockService - .Setup(x => x.UpdateAsync(guid,body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.UpdateAccount(guid,body); - - var result = response as ObjectResult; - - Assert.AreEqual(400, result?.StatusCode); - Assert.IsInstanceOf(result?.Value); - - var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error.Message, listResponse?.Message); - - this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs deleted file mode 100644 index cdc5303..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.create.cs +++ /dev/null @@ -1,57 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class BalancesControllerTests - { - [Test] - public async Task CreateBalance_ServiceSuccess_ReturnsOk() - { - var body = this.balanceModelBuilder.Generate(); - var mockResult = new ServiceResult(body); - - this.mockService - .Setup(x => x.CreateAsync(body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.CreateBalance(body); - - var result = response as ObjectResult; - - Assert.AreEqual(200, result?.StatusCode); - Assert.IsInstanceOf>(result?.Value); - - var listResponse = result?.Value as SaveResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockService.Verify(x => x.CreateAsync(body), Times.Once); - } - - [Test] - [TestCase(Description = "Create account returns Bad Request", Category = "Create")] - public async Task CreateBalance_ServiceError_ReturnsBadRequest() - { - var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.balanceModelBuilder.Generate(); - - var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - - this.mockService - .Setup(x => x.CreateAsync(body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.CreateBalance(body); - - var result = response as ObjectResult; - - Assert.AreEqual(400, result?.StatusCode); - Assert.IsInstanceOf(result?.Value); - - var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); - - this.mockService.Verify(x => x.CreateAsync(body), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs deleted file mode 100644 index c676348..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -using FinancialHub.Core.WebApi.Controllers; -using FinancialHub.Core.Domain.Interfaces.Services; - -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class BalancesControllerTests - { - private Random random; - - private BalanceModelBuilder balanceModelBuilder; - - private BalancesController controller; - private Mock mockService; - - [SetUp] - public void Setup() - { - this.random = new Random(); - - this.balanceModelBuilder = new BalanceModelBuilder(); - - this.mockService = new Mock(); - this.controller = new BalancesController(this.mockService.Object); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs deleted file mode 100644 index 7fbcdbd..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.delete.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class BalancesControllerTests - { - [Test] - public async Task DeleteMyBalances_ServiceSuccess_ReturnsNoContent() - { - var mock = this.balanceModelBuilder.Generate(); - var response = await this.controller.DeleteBalance(mock.Id.GetValueOrDefault()); - - var result = response as ObjectResult; - - Assert.IsNull(result?.Value); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs deleted file mode 100644 index 9a145bb..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Balances/BalancesControllerTests.update.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class BalancesControllerTests - { - [Test] - public async Task UpdateBalance_Valid_ReturnsOk() - { - var body = this.balanceModelBuilder.Generate(); - var guid = body.Id.GetValueOrDefault(); - var mockResult = new ServiceResult(body); - - this.mockService - .Setup(x => x.UpdateAsync(guid, body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.UpdateBalance(guid, body); - - var result = response as ObjectResult; - - Assert.AreEqual(200, result?.StatusCode); - Assert.IsInstanceOf>(result?.Value); - - var listResponse = result?.Value as SaveResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); - } - - [Test] - public async Task UpdateBalance_Invalid_ReturnsBadRequest() - { - var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.balanceModelBuilder.Generate(); - var guid = body.Id.GetValueOrDefault(); - - var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - - this.mockService - .Setup(x => x.UpdateAsync(guid,body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.UpdateBalance(guid,body); - - var result = response as ObjectResult; - - Assert.AreEqual(400, result?.StatusCode); - Assert.IsInstanceOf(result?.Value); - - var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); - - this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs deleted file mode 100644 index 1c24772..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.create.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class CategoriesControllerTests - { - [Test] - [TestCase(Description = "Create valid category returns Ok", Category = "Create")] - public async Task CreateCategory_Valid_ReturnsOk() - { - var body = this.categoryModelBuilder.Generate(); - var mockResult = new ServiceResult(body); - - this.mockService - .Setup(x => x.CreateAsync(body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.CreateCategory(body); - - var result = response as ObjectResult; - - Assert.AreEqual(200, result?.StatusCode); - Assert.IsInstanceOf>(result?.Value); - - var listResponse = result?.Value as SaveResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockService.Verify(x => x.CreateAsync(body), Times.Once); - } - - [Test] - [TestCase(Description = "Create invalid Category returns BadRequest", Category = "Create")] - public async Task CreateCategory_Invalid_ReturnsBadRequest() - { - var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.categoryModelBuilder.Generate(); - - var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - - this.mockService - .Setup(x => x.CreateAsync(body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.CreateCategory(body); - - var result = response as ObjectResult; - - Assert.AreEqual(400, result?.StatusCode); - Assert.IsInstanceOf(result?.Value); - - var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); - - this.mockService.Verify(x => x.CreateAsync(body), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs deleted file mode 100644 index f2f3bee..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FinancialHub.Core.WebApi.Controllers; -using FinancialHub.Core.Domain.Interfaces.Services; - -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class CategoriesControllerTests - { - private Random random; - private CategoryModelBuilder categoryModelBuilder; - - private CategoriesController controller; - private Mock mockService; - - [SetUp] - public void Setup() - { - this.random = new Random(); - this.categoryModelBuilder = new CategoryModelBuilder(); - - this.mockService = new Mock(); - this.controller = new CategoriesController(this.mockService.Object); - } - } -} \ No newline at end of file diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs deleted file mode 100644 index c32fb45..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.delete.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class CategoriesControllerTests - { - [Test] - [TestCase(Description = "Delete Returns NoContent", Category = "Delete")] - public async Task DeleteMyCategories_ServiceSuccess_ReturnsNoContent() - { - var mock = this.categoryModelBuilder.Generate(); - var response = await this.controller.DeleteCategory(mock.Id.GetValueOrDefault()); - - var result = response as ObjectResult; - - Assert.IsNull(result?.Value); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs deleted file mode 100644 index d5c41a8..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.get.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class CategoriesControllerTests - { - [Test] - [TestCase(Description = "Get returns Ok", Category = "Create")] - public async Task GetMyCategories_ServiceSuccess_ReturnsOk() - { - var mockResult = new ServiceResult>( - categoryModelBuilder.Generate(random.Next(0, 10)) - ); - - this.mockService - .Setup(x => x.GetAllByUserAsync(It.IsAny())) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.GetMyCategories(); - var result = (ObjectResult)response; - - Assert.AreEqual(200, result.StatusCode); - Assert.IsInstanceOf>(result.Value); - - var listResponse = result.Value as ListResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockService.Verify(x => x.GetAllByUserAsync(It.IsAny()), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs deleted file mode 100644 index 31e163b..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Categories/CategoriesControllerTests.update.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class CategoriesControllerTests - { - [Test] - [TestCase(Description = "Update valid Category returns Ok", Category = "Update")] - public async Task UpdateCategory_Valid_ReturnsOk() - { - var body = this.categoryModelBuilder.Generate(); - var guid = body.Id.GetValueOrDefault(); - var mockResult = new ServiceResult(body); - - this.mockService - .Setup(x => x.UpdateAsync(guid, body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.UpdateCategory(guid, body); - - var result = response as ObjectResult; - - Assert.AreEqual(200, result?.StatusCode); - Assert.IsInstanceOf>(result?.Value); - - var listResponse = result?.Value as SaveResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); - } - - [Test] - [TestCase(Description = "Update invalid Category returns BadRequest", Category = "Update")] - public async Task UpdateCategory_Invalid_ReturnsBadRequest() - { - var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.categoryModelBuilder.Generate(); - var guid = body.Id.GetValueOrDefault(); - - var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - - this.mockService - .Setup(x => x.UpdateAsync(guid,body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.UpdateCategory(guid,body); - - var result = response as ObjectResult; - - Assert.AreEqual(400, result?.StatusCode); - Assert.IsInstanceOf(result?.Value); - - var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); - - this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs deleted file mode 100644 index 86c48f8..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.create.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class TransactionsControllerTests - { - [Test] - [TestCase(Description = "Create valid transaction Return Ok", Category = "Create")] - public async Task CreateTransaction_Valid_ReturnsOk() - { - var body = this.transactionModelBuilder.Generate(); - var mockResult = new ServiceResult(body); - - this.mockTransactionBalanceServiceService - .Setup(x => x.CreateTransactionAsync(body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.CreateTransaction(body); - - var result = response as ObjectResult; - - Assert.AreEqual(200, result?.StatusCode); - Assert.IsInstanceOf>(result?.Value); - - var listResponse = result?.Value as SaveResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockTransactionBalanceServiceService.Verify(x => x.CreateTransactionAsync(body), Times.Once); - } - - [Test] - [TestCase(Description = "Create invalid Transaction Return BadRequest", Category = "Create")] - public async Task CreateTransaction_Invalid_ReturnsBadRequest() - { - var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.transactionModelBuilder.Generate(); - - var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - - this.mockTransactionBalanceServiceService - .Setup(x => x.CreateTransactionAsync(body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.CreateTransaction(body); - - var result = response as ObjectResult; - - Assert.AreEqual(400, result?.StatusCode); - Assert.IsInstanceOf(result?.Value); - - var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); - - this.mockTransactionBalanceServiceService.Verify(x => x.CreateTransactionAsync(body), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs deleted file mode 100644 index a62f90a..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -using FinancialHub.Core.WebApi.Controllers; -using FinancialHub.Core.Domain.Interfaces.Services; - -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class TransactionsControllerTests - { - private Random random; - private TransactionModelBuilder transactionModelBuilder; - - private TransactionsController controller; - private Mock mockService; - private Mock mockTransactionBalanceServiceService; - - [SetUp] - public void Setup() - { - this.random = new Random(); - this.transactionModelBuilder = new TransactionModelBuilder(); - - this.mockService = new Mock(); - this.mockTransactionBalanceServiceService = new Mock(); - this.controller = new TransactionsController(this.mockService.Object, this.mockTransactionBalanceServiceService.Object); - } - } -} \ No newline at end of file diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs deleted file mode 100644 index 0266e37..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.delete.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class TransactionsControllerTests - { - [Test] - [TestCase(Description = "Delete Transaction Returns NoContent", Category = "Delete")] - public async Task DeleteMyTransactions_ServiceSuccess_ReturnsNoContent() - { - var mock = this.transactionModelBuilder.Generate(); - var response = await this.controller.DeleteTransaction(mock.Id.GetValueOrDefault()); - - var result = response as ObjectResult; - - Assert.IsNull(result?.Value); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs deleted file mode 100644 index 5feeb8b..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.get.cs +++ /dev/null @@ -1,32 +0,0 @@ -using FinancialHub.Core.Domain.Filters; - -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class TransactionsControllerTests - { - [Test] - [TestCase(Description = "Get Transactions return Ok", Category = "Create")] - public async Task GetMyTransactions_ServiceSuccess_ReturnsOk() - { - var mockResult = new ServiceResult>(transactionModelBuilder.Generate(random.Next(0, 10))); - - var filter = new TransactionFilter(); - - this.mockService - .Setup(x => x.GetAllByUserAsync(It.IsAny(),filter)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.GetMyTransactions(filter); - var result = (ObjectResult)response; - - Assert.AreEqual(200, result.StatusCode); - Assert.IsInstanceOf>(result.Value); - - var listResponse = result.Value as ListResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockService.Verify(x => x.GetAllByUserAsync(It.IsAny(),filter), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs deleted file mode 100644 index 767a634..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Controllers/Transactions/TransactionsControllerTests.update.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace FinancialHub.Core.WebApi.Tests.Controllers -{ - public partial class TransactionsControllerTests - { - [Test] - [TestCase(Description = "Update valid Transaction returns Ok", Category = "Update")] - public async Task UpdateTransaction_Valid_ReturnsOk() - { - var body = this.transactionModelBuilder.Generate(); - var guid = body.Id.GetValueOrDefault(); - var mockResult = new ServiceResult(body); - - this.mockService - .Setup(x => x.UpdateAsync(guid, body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.UpdateTransaction(guid, body); - - var result = response as ObjectResult; - - Assert.AreEqual(200, result?.StatusCode); - Assert.IsInstanceOf>(result?.Value); - - var listResponse = result?.Value as SaveResponse; - Assert.AreEqual(mockResult.Data, listResponse?.Data); - - this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); - } - - [Test] - [TestCase(Description = "Update Transaction invalid returns BadRequest", Category = "Update")] - public async Task UpdateTransaction_Invalid_ReturnsBadRequest() - { - var errorMessage = $"Invalid thing : {Guid.NewGuid()}"; - var body = this.transactionModelBuilder.Generate(); - var guid = body.Id.GetValueOrDefault(); - - var mockResult = new ServiceResult(body, new InvalidDataError(errorMessage)); - - this.mockService - .Setup(x => x.UpdateAsync(guid,body)) - .ReturnsAsync(mockResult) - .Verifiable(); - - var response = await this.controller.UpdateTransaction(guid,body); - - var result = response as ObjectResult; - - Assert.AreEqual(400, result?.StatusCode); - Assert.IsInstanceOf(result?.Value); - - var listResponse = result?.Value as ValidationErrorResponse; - Assert.AreEqual(mockResult.Error!.Code, listResponse?.Code); - Assert.AreEqual(mockResult.Error!.Message, listResponse?.Message); - - this.mockService.Verify(x => x.UpdateAsync(guid, body), Times.Once); - } - } -} diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj b/tests/core/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj deleted file mode 100644 index 2213eb9..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/FinancialHub.Core.WebApi.Tests.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net6.0 - enable - - false - - - - - - - - - - - - - - - - diff --git a/tests/core/FinancialHub.Core.WebApi.Tests/Usings.cs b/tests/core/FinancialHub.Core.WebApi.Tests/Usings.cs deleted file mode 100644 index eeb88a2..0000000 --- a/tests/core/FinancialHub.Core.WebApi.Tests/Usings.cs +++ /dev/null @@ -1,27 +0,0 @@ -// System namespaces -global using System; -global using System.Collections.Generic; -global using System.Threading.Tasks; - -// Asp.Net namespaces -global using Microsoft.AspNetCore.Mvc; - -// 3rd party test namespaces -global using Moq; -global using NUnit.Framework; - -// Domain Project tests namespaces -global using FinancialHub.Core.Domain.Tests.Builders.Models; - -// Domain Model namespaces -global using FinancialHub.Core.Domain.Models; - -// Common Result namespaces -global using FinancialHub.Common.Results; -global using FinancialHub.Common.Results.Errors; - -// Common Response namespaces -global using FinancialHub.Common.Responses.Errors; -global using FinancialHub.Common.Responses.Success; - -[assembly: Category("Unit")] \ No newline at end of file From b90e069bce091eea5bee1874ccafe5be58a37537 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Date: Sat, 24 Feb 2024 02:23:13 -0300 Subject: [PATCH 28/30] Removes All core docs --- CHANGELOG.md | 8 - README.md | 34 +- .../financial-hub-api-dev.postman_environment | 15 - docs/api/financial-hub-api.postman_collection | 1261 ----------------- docs/database/database.drawio | 1 - src/database/financial-hub_DDL.sql | 52 - 6 files changed, 1 insertion(+), 1370 deletions(-) delete mode 100644 docs/api/environments/financial-hub-api-dev.postman_environment delete mode 100644 docs/api/financial-hub-api.postman_collection delete mode 100644 docs/database/database.drawio delete mode 100644 src/database/financial-hub_DDL.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index a478e7c..e69de29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +0,0 @@ -* ### [v0.3.1](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.3.1) -* ### [v0.3.0](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.3.0) -* ### [v0.2.4](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.4) -* ### [v0.2.3](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.3) -* ### [v0.2.2](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.2) -* ### [v0.2.1](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.1) -* ### [v0.2.0](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.2.0) -* ### [v0.1.0](https://github.com/Chingling152/my-financial-hub-api/releases/tag/v0.1.0) diff --git a/README.md b/README.md index f544a9e..45f454d 100644 --- a/README.md +++ b/README.md @@ -1,33 +1 @@ -# My Financial Hub -This is a completely experimental project, a lot of stuff here was not made with the purpose of being used in production environment. -Until v1 release, everything of this project could be changed. - -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Chingling152_my-financial-hub&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Chingling152_my-financial-hub) - -## What's planned for the future -- **[Monthly Milestones](https://github.com/Chingling152/my-financial-hub/issues/9)** -- **[Earns/Expenses Portion](https://github.com/Chingling152/my-financial-hub/issues/10)** -- **Transaction relatories** -- **Dashboards** -- **Earns/Expenses average** -- **Earns/Expenses predictions** - -## Requeriments - * Docker (optional) - * .NET 6.0 - * SQL Server - -## How to Start -* Run the Dockerfile in root project to create the database (optional) -* Configure the **ConnectionStrings** in the file **appsettings.Development.json** with your SQL Server database -* Initial configuration (pick one) - * #### Visual Studio - Open : Project solution and build the project - Open : Tools -> NuGet Package Manager -> Package Manager Console - Type : Update-Database - * ### Dotnet Cli - Open : WebApi Project directory - Type : dotnet build - Type : dotnet tool install --global dotnet-ef - Type : dotnet ef database update -* After that, you'll be able to run the project +# My Financial Hub Auth Api diff --git a/docs/api/environments/financial-hub-api-dev.postman_environment b/docs/api/environments/financial-hub-api-dev.postman_environment deleted file mode 100644 index a008aad..0000000 --- a/docs/api/environments/financial-hub-api-dev.postman_environment +++ /dev/null @@ -1,15 +0,0 @@ -{ - "id": "b25ada13-3e88-4b39-94c1-e3eb1bc394aa", - "name": "Financial Hub Api", - "values": [ - { - "key": "baseUrl", - "value": "http://localhost:62772/", - "type": "default", - "enabled": true - } - ], - "_postman_variable_scope": "environment", - "_postman_exported_at": "2022-04-29T18:21:42.984Z", - "_postman_exported_using": "Postman/9.14.14" -} \ No newline at end of file diff --git a/docs/api/financial-hub-api.postman_collection b/docs/api/financial-hub-api.postman_collection deleted file mode 100644 index caa4b60..0000000 --- a/docs/api/financial-hub-api.postman_collection +++ /dev/null @@ -1,1261 +0,0 @@ -{ - "info": { - "_postman_id": "38685a83-5b92-4a6a-93f3-ee9ece5cbb4b", - "name": "Financial Hub WebApi", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Accounts", - "item": [ - { - "name": "{id}", - "item": [ - { - "name": "/Accounts/:id", - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Accept", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Accounts/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Accounts/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"data\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n }\n}" - }, - { - "name": "Bad Request", - "originalRequest": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Accounts/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "Bad Request", - "code": 400, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" - }, - { - "name": "Not Found", - "originalRequest": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Accounts/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "Not Found", - "code": 404, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" - } - ] - }, - { - "name": "/Accounts/:id", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{baseUrl}}/Accounts/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{baseUrl}}/Accounts/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "text", - "header": [ - { - "key": "Content-Type", - "value": "text/plain" - } - ], - "cookie": [], - "body": "" - } - ] - } - ] - }, - { - "name": "/Accounts", - "request": { - "method": "GET", - "header": [ - { - "key": "Accept", - "value": "application/json" - } - ], - "url": { - "raw": "{{baseUrl}}/Accounts", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts" - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{baseUrl}}/Accounts", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"data\": [\n {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n }\n ]\n}" - } - ] - }, - { - "name": "/Accounts", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Accept", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Accounts", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts" - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Accounts", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"data\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n }\n}" - }, - { - "name": "Bad Request", - "originalRequest": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Accounts", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Accounts" - ] - } - }, - "status": "Bad Request", - "code": 400, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" - } - ] - } - ] - }, - { - "name": "Categories", - "item": [ - { - "name": "{id}", - "item": [ - { - "name": "/Categories/:id", - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Accept", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Categories/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Categories", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Categories/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Categories", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"data\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n }\n}" - }, - { - "name": "Bad Request", - "originalRequest": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Categories/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Categories", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "Bad Request", - "code": 400, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" - } - ] - }, - { - "name": "/Categories/:id", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{baseUrl}}/Categories/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Categories", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "DELETE", - "header": [], - "url": { - "raw": "http://localhost:62772//Categories/:id", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "62772", - "path": [ - "", - "Categories", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "text", - "header": [ - { - "key": "Content-Type", - "value": "text/plain" - } - ], - "cookie": [], - "body": "" - } - ] - } - ] - }, - { - "name": "/Categories", - "request": { - "method": "GET", - "header": [ - { - "key": "Accept", - "value": "application/json" - } - ], - "url": { - "raw": "{{baseUrl}}/Categories", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Categories" - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://localhost:62772//Categories", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "62772", - "path": [ - "", - "Categories" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"data\": [\n {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n }\n ]\n}" - } - ] - }, - { - "name": "/Categories", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Accept", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Categories", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Categories" - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "http://localhost:62772//Categories", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "62772", - "path": [ - "", - "Categories" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"data\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n }\n}" - }, - { - "name": "Bad Request", - "originalRequest": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Categories", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Categories" - ] - } - }, - "status": "Bad Request", - "code": 400, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" - } - ] - } - ] - }, - { - "name": "Transactions", - "item": [ - { - "name": "{id}", - "item": [ - { - "name": "/Transactions/:id", - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Accept", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Transactions/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Transactions", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "http://localhost:62772//Transactions/:id", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "62772", - "path": [ - "", - "Transactions", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"data\": {\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n }\n}" - }, - { - "name": "Bad Request", - "originalRequest": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Transactions/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Transactions", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "Bad Request", - "code": 400, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" - } - ] - }, - { - "name": "/Transactions/:id", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{baseUrl}}/Transactions/:id", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Transactions", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "DELETE", - "header": [], - "url": { - "raw": "http://localhost:62772//Transactions/:id", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "62772", - "path": [ - "", - "Transactions", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "", - "description": "(Required) " - } - ] - } - }, - "status": "No Content", - "code": 204, - "_postman_previewlanguage": "text", - "header": [ - { - "key": "Content-Type", - "value": "text/plain" - } - ], - "cookie": [], - "body": "" - } - ] - } - ] - }, - { - "name": "/Transactions", - "request": { - "method": "GET", - "header": [ - { - "key": "Accept", - "value": "application/json" - } - ], - "url": { - "raw": "{{baseUrl}}/Transactions?StartDate=&EndDate=&Types=&Types=&Status=&Status=&Accounts=&Accounts=&Categories=&Categories=", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Transactions" - ], - "query": [ - { - "key": "StartDate", - "value": "" - }, - { - "key": "EndDate", - "value": "" - }, - { - "key": "Types", - "value": "" - }, - { - "key": "Types", - "value": "" - }, - { - "key": "Status", - "value": "" - }, - { - "key": "Status", - "value": "" - }, - { - "key": "Accounts", - "value": "" - }, - { - "key": "Accounts", - "value": "" - }, - { - "key": "Categories", - "value": "" - }, - { - "key": "Categories", - "value": "" - } - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "http://localhost:62772//Transactions?StartDate=&EndDate=&Types=&Types=&Status=&Status=&Accounts=&Accounts=&Categories=&Categories=", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "62772", - "path": [ - "", - "Transactions" - ], - "query": [ - { - "key": "StartDate", - "value": "" - }, - { - "key": "EndDate", - "value": "" - }, - { - "key": "Types", - "value": "" - }, - { - "key": "Types", - "value": "" - }, - { - "key": "Status", - "value": "" - }, - { - "key": "Status", - "value": "" - }, - { - "key": "Accounts", - "value": "" - }, - { - "key": "Accounts", - "value": "" - }, - { - "key": "Categories", - "value": "" - }, - { - "key": "Categories", - "value": "" - } - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"data\": [\n {\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n },\n {\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n }\n ]\n}" - } - ] - }, - { - "name": "/Transactions", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Accept", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Transactions", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Transactions" - ] - } - }, - "response": [ - { - "name": "Success", - "originalRequest": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "http://localhost:62772//Transactions", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "62772", - "path": [ - "", - "Transactions" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"data\": {\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n }\n}" - }, - { - "name": "Bad Request", - "originalRequest": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": \"\",\n \"description\": \"\",\n \"amount\": \"\",\n \"targetDate\": \"\",\n \"finishDate\": \"\",\n \"accountId\": \"\",\n \"account\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"currency\": \"\",\n \"isActive\": \"\"\n },\n \"categoryId\": \"\",\n \"category\": {\n \"id\": \"\",\n \"name\": \"\",\n \"description\": \"\",\n \"isActive\": \"\"\n },\n \"isActive\": \"\",\n \"status\": \"\",\n \"type\": \"\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/Transactions", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "Transactions" - ] - } - }, - "status": "Bad Request", - "code": 400, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"code\": \"\",\n \"message\": \"\"\n}" - } - ] - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ] -} \ No newline at end of file diff --git a/docs/database/database.drawio b/docs/database/database.drawio deleted file mode 100644 index 462b4b6..0000000 --- a/docs/database/database.drawio +++ /dev/null @@ -1 +0,0 @@ -7V1bd6I6GP01PnaWoNj2sdrrGp2Z0+v0vHSlEJE5SFghttJfPwkEb4lUD4g2ZC0fyJcQwrd3Nkk+go1Wbzy9wiAcDZAD/YbZdKaN1nnDNI22aTbYr+nEqeW4ww0u9hxeaG648z4gNza5deI5MFoqSBDyiRcuG20UBNAmSzaAMXpfLjZE/vJVQ+BCwXBnA1+0PnkOGaXWE6s5t19Dzx1lVzaaPOcV2P+5GE0Cfr0ABTDNGYOsGl40GgEHvS+YWheNVg8jRNKj8bQHfebWzGPpeZdrcmdNxjAgm5xwDm78dwCcl3br6MdT3HSfW89HvJY34E+4K85sm94OiXijSZz5iLY/ZIcEvDJTNyIAEw5lq0kNFBwCvABiajCStO+DMPKS4qll5PlOH8RoQrKKslR36E2hc5siycpSUPu0MpZklQ9p5Xe8MSwb+J4b0GOb3j27YhfDiLalDyLCS4j+yW4WYgKnCyburyuIxpDgmBbhuW0OHWd1iyff5xQxTrhttEiPDjcCTkt3VvMcH3rAIdoCLlOAay1M9MaJB/xb2l1A4CaILQPCvOpgFN4D7ELCDSHymD8v3iCjAHe95/s95COGa8LvVpegkGf6cJid+4oIQeMMPu6OWaWJK6wu/VHn9JrfrIZFm9ujaWOepj9WHJMeCiKCKZtYHZCC+g4ZsBJQc2n9OdJbQtvaFbItAdlf37fDNlFGMMd2a9iaK7CtdjlE3Tn0EwkbeY4Dg83xMDfGYwGA1pb+55XNvbJ1bcCn3A8AgV2m6JEA6qyd/x/ntoAzLb5fnDMpTct2oxDYXuD20zM7K0SwqiLCdH3HtEolxkbVVcAM60to+yp5voC2d/at7Z2CyJbe46HjZfUVFHZrYzBUF/ZjAeQAjOGhS3sl0Kss5dY1fIq/o7NpfN5/iC1rgM1XyaxKS3kpUn5aoZRLkS06ATsMKc8lba2kXOoJcS7mwMjGXkg8FKih6AUZoLKiS5XqRCv6bhTdMPc9Oj9VQtJzWVsrSZfzsimgDGzivak8QN8cfZXlvHOD+je9R/v6/eTHWWAfDX+2A8kAvUev5yLsQR34oDmzgTZX6Y3XUEoJfUgh06EPAdZcah9k6EPaYmVCH7m8rdUzWOqJ+oQ+ChKhdo9jHfrYkbZXGfqQtliN0EcuabWwqxz6KAh97aRcL5TtSMqrDH1IW6zGOlkuabWUS9bJlIt9FKRA7STdECduWtNL0fRKgx/yJhedeh2wqs94q2XdEOdhKoU/isKvsqSf/nt9Ow4ex4/Hd2+Df0Cz/fFhSOIf9xgEEeMElcC1pKhRBKST7fDJIiAbKrV5UoJUSzHTARAB1VxuH2QARNpiZQIgubyt1VNY6on6BEAKEqF2z2O9arYjba8yACJtsRqrZrmk1cJeh1WzghSonaTrVbNdaXqVkRB5i9VYNMunrVZ12aLZmH0bQ2FB14tmOfMXPUrfkaJXGgeRY6vwON3UA/XZSps4UB96gReNXhx6XYV1fQsO1E/XRVJoXS9H162967oY6brc99p6icre3BgR1ZU967MLQL8CHwQ2fDn8RfZqKFA7YTfEF5O1sJcj7Cf7FnZDnIwpJOwz5mphN8SZmZ3u1Y3VVvYtOFA7ZTf1jrEdKfvsk8z7G7KrsWcsn7da101xcBYRQCbr3z78+pK+Bfy1k3RDfzRvV5Le3rekG+LkXBlJNzbHQ3VJN8QXWVXaZVAU/tpJutkWgIeOC7PXSakUjpCLAuBfzK3d5M80oMOhm5fpowRz1lv/QEJivv0ATAiiphEZ+zyX4oXj31k/Z4lnlvhmZcnz6WLmecxTyaaGM/ZnItRwcZsSLTFeeuy++SnOUpF7NABBnGYsFBPJw2kSoQm2uS/yvhJCsgfXWt7x4RNzaC7rMPRB0gcXm1FE4Y8BubMe0cvxfTxy3J/+6cPZlWRDSTddfV3b9Wu0l2T1a1qbbjgo5WNaUriKPo8V3EuSS+uD3EsibbEye0lyeVursZbUE/XZS1KQCCqPuqSu0UujO9L2KveSSFusxsJoLmm1sKv8Ma2C0NdOyvULxzuS8iq3kEhbrMbrxrmk1VIu2RZoTzB1nx0rrOf6TeP1hNAxrh0JeqU7SORNFtfUvuYLafnM1aoujXIl/5mtzPtoRSmgsrBPwvAP/HF2G/3yB6dH1w+98dXvTK+qDXSVH7BaCSZ9GsHK+4vfxQhWDp8qCFhJERMfvIeKWElY5S2jfhptTJ+u5WNFkxghstgZMQhHA+RAVuIv \ No newline at end of file diff --git a/src/database/financial-hub_DDL.sql b/src/database/financial-hub_DDL.sql deleted file mode 100644 index 464c825..0000000 --- a/src/database/financial-hub_DDL.sql +++ /dev/null @@ -1,52 +0,0 @@ -CREATE DATABASE financial_hub; -USE financial_hub; - -CREATE TABLE categories( - id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), - name VARCHAR(200) NOT NULL, - description VARCHAR(500) NULL, - active BIT DEFAULT 1, - - update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), - creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), -); - -CREATE TABLE accounts( - id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), - name VARCHAR(200) NOT NULL, - description VARCHAR(500) NULL, - active BIT DEFAULT 1, - - update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), - creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), -); - -CREATE TABLE balances( - id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), - name VARCHAR(200) NOT NULL, - amount MONEY NOT NULL, - - account_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES accounts(id) NOT NULL, - - update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), - creation_time DATETIMEOFFSET DEFAULT GETUTCDATE() -); - -CREATE TABLE transactions( - id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID(), - description VARCHAR(500) NULL, - - amount MONEY NOT NULL, - target_date DATETIMEOFFSET NOT NULL, - finish_date DATETIMEOFFSET NOT NULL, - - balance_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES balances(id) NOT NULL, - category_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES categories(id) NOT NULL, - - status INT NOT NULL, - type INT NOT NULL, - active BIT DEFAULT 1, - - update_time DATETIMEOFFSET DEFAULT GETUTCDATE(), - creation_time DATETIMEOFFSET DEFAULT GETUTCDATE(), -); From f07027cb1e1a17c9fd79f091d4f0076c046d3360 Mon Sep 17 00:00:00 2001 From: Franklin Bitencourt Date: Sat, 24 Feb 2024 02:30:10 -0300 Subject: [PATCH 29/30] Removes coverage --- .github/actions/cache-sonar/action.yml | 25 ------- .github/workflows/archived/sonarcloud.yml | 91 ----------------------- .github/workflows/branch_main_ci.yml | 9 --- .github/workflows/branch_release_ci.yml | 9 --- .github/workflows/coverage_report.yml | 90 ---------------------- 5 files changed, 224 deletions(-) delete mode 100644 .github/actions/cache-sonar/action.yml delete mode 100644 .github/workflows/archived/sonarcloud.yml delete mode 100644 .github/workflows/coverage_report.yml diff --git a/.github/actions/cache-sonar/action.yml b/.github/actions/cache-sonar/action.yml deleted file mode 100644 index ffebd46..0000000 --- a/.github/actions/cache-sonar/action.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Cache Sonar Package & Sonar Scanner -description: This is just to make - -inputs: - os: - description: 'operational system' - required: true - -runs: - using: "composite" - steps: - - name: Cache SonarCloud packages - uses: actions/cache@v1 - with: - path: ~\sonar\cache - key: ${{ inputs.os }}-sonar - restore-keys: ${{ inputs.os }}-sonar - - - name: Cache SonarCloud scanner - id: cache-sonar-scanner - uses: actions/cache@v1 - with: - path: .\.sonar\scanner - key: ${{ inputs.os }}-sonar-scanner - restore-keys: ${{ inputs.os }}-sonar-scanner \ No newline at end of file diff --git a/.github/workflows/archived/sonarcloud.yml b/.github/workflows/archived/sonarcloud.yml deleted file mode 100644 index 4507f8f..0000000 --- a/.github/workflows/archived/sonarcloud.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: SonarCloud analysis - -on: - push: - branches: - - 'main' - paths: - - 'src/FinancialHub/*' - - 'src/FinancialHub/**' - pull_request: - branches: - - 'main' - - 'release/**' - paths: - - 'src/FinancialHub/*' - - 'src/FinancialHub/**' - -permissions: - pull-requests: read - -jobs: - code_analysis: - name: Code Analysis - runs-on: windows-latest - - defaults: - run: - working-directory: ./src/FinancialHub/ - - steps: - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 1.11 - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Cache SonarCloud packages - uses: actions/cache@v1 - with: - path: ~\sonar\cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - - name: Cache SonarCloud scanner - id: cache-sonar-scanner - uses: actions/cache@v1 - with: - path: .\.sonar\scanner - key: ${{ runner.os }}-sonar-scanner - restore-keys: ${{ runner.os }}-sonar-scanner - - - name: Install SonarCloud scanner - if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' - run: | - New-Item -Path .\.sonar\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 6.0.x - - - name: Restore dependencies - run: dotnet restore - - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - .\.sonar\scanner\dotnet-sonarscanner begin ` - /k:"Chingling152_my-financial-hub" ` - /o:"chingling-152" ` - /d:sonar.login="${{ secrets.SONAR_TOKEN }}" ` - /d:sonar.host.url="https://sonarcloud.io" ` - /d:sonar.coverage.exclusions="**/Migrations/." ` - /d:sonar.cs.opencover.reportsPaths="/TestResults/**/coverage.opencover.xml" - - echo "build project" - dotnet build --configuration Release --no-restore - - echo "running code coverage" - dotnet test ` - --collect:"XPlat Code Coverage" ` - --results-directory TestResults/ ` - --configuration release ` - -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover ` - - .\.sonar\scanner\dotnet-sonarscanner end ` - /d:sonar.login="${{ secrets.SONAR_TOKEN }}" diff --git a/.github/workflows/branch_main_ci.yml b/.github/workflows/branch_main_ci.yml index e9519a3..6013de1 100644 --- a/.github/workflows/branch_main_ci.yml +++ b/.github/workflows/branch_main_ci.yml @@ -23,15 +23,6 @@ jobs: name: Tests uses: ./.github/workflows/matrix_test_result.yml secrets: inherit - with: - dir: ./src/api/ - dotnet-version: 6.0.x - - code_analysis: - name: Code Analysis - needs: tests - uses: ./.github/workflows/coverage_report.yml - secrets: inherit with: dir: ./src/api/ dotnet-version: 6.0.x \ No newline at end of file diff --git a/.github/workflows/branch_release_ci.yml b/.github/workflows/branch_release_ci.yml index 7c0c7d2..13f1c63 100644 --- a/.github/workflows/branch_release_ci.yml +++ b/.github/workflows/branch_release_ci.yml @@ -17,15 +17,6 @@ jobs: name: Tests uses: ./.github/workflows/matrix_test_result.yml secrets: inherit - with: - dir: ./src/api/ - dotnet-version: 6.0.x - - code_analysis: - name: Code Analysis - needs: tests - uses: ./.github/workflows/coverage_report.yml - secrets: inherit with: dir: ./src/api/ dotnet-version: 6.0.x \ No newline at end of file diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml deleted file mode 100644 index 976a841..0000000 --- a/.github/workflows/coverage_report.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Api Coverage - -on: - workflow_call: - inputs: - dir: - type: string - required: true - dotnet-version: - type: string - default: 6.0.x - -permissions: - pull-requests: read - -jobs: - code_analysis: - name: Code coverage - runs-on: ubuntu-latest - - defaults: - run: - working-directory: ${{ inputs.dir }} - - services: - sql-database: - image: mcr.microsoft.com/mssql/server:2019-latest - env: - SA_PASSWORD: "P@ssw0rd!" - ACCEPT_EULA: "Y" - ports: - - 1450:1433 - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Setup Project - uses: ./.github/actions/build-dotnet-project - with: - project-dir: ${{ inputs.dir }} - dotnet-version: ${{ inputs.dotnet-version }} - - - name: Dotnet restore tools - run: dotnet tool restore - - - name: Cache SonarCloud packages - uses: actions/cache@v1 - with: - path: ~\sonar\cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - - name: Cache SonarCloud scanner - id: cache-sonar-scanner - uses: actions/cache@v1 - with: - path: .\.sonar\scanner - key: ${{ runner.os }}-sonar-scanner - restore-keys: ${{ runner.os }}-sonar-scanner - - - name: Begin Coverage Report - run: - dotnet tool run dotnet-sonarscanner begin - /k:"Chingling152_my-financial-hub" - /o:"chingling-152" - /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - /d:sonar.host.url="https://sonarcloud.io" - /d:sonar.coverage.exclusions="**/Migrations/." - /d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml" - - - name: Build Project - run: dotnet build - --configuration Release - --no-restore - - - name: Run Coverage Report - continue-on-error: true - run: dotnet test - --collect:"XPlat Code Coverage;Format=opencover" - --results-directory TestResults/ - --filter "TestCategory=Unit|TestCategory=Integration" - --configuration Release - - - name: Send Coverage Report - run: - dotnet tool run dotnet-sonarscanner end - /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - \ No newline at end of file From 6c4ea1496ca9306e5152a826dff063d4ab9c1096 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 24 Feb 2024 05:38:03 +0000 Subject: [PATCH 30/30] Bump the nuget group across 1 directories with 1 update Bumps the nuget group with 1 update in the /src/api/auth/FinancialHub.Auth.Application directory: [System.IdentityModel.Tokens.Jwt](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet). Updates `System.IdentityModel.Tokens.Jwt` from 6.12.1 to 6.34.0 - [Release notes](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/releases) - [Changelog](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/dev/CHANGELOG.md) - [Commits](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/compare/6.12.1...6.34.0) --- updated-dependencies: - dependency-name: System.IdentityModel.Tokens.Jwt dependency-type: direct:production dependency-group: nuget-security-group ... Signed-off-by: dependabot[bot] --- .../FinancialHub.Auth.Application.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/auth/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj b/src/api/auth/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj index 968318d..13acf3c 100644 --- a/src/api/auth/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj +++ b/src/api/auth/FinancialHub.Auth.Application/FinancialHub.Auth.Application.csproj @@ -17,7 +17,7 @@ - +