From 6ee1d82a7a46df95fbf0ce2b3964fadad15eeaf5 Mon Sep 17 00:00:00 2001 From: jasonmwebb-lv <97196139+jasonmwebb-lv@users.noreply.github.com> Date: Tue, 7 May 2024 21:49:13 -0600 Subject: [PATCH] Validation example (#133) (#134) * Updated all dependencies. Removed deprecated dependencies. * Removing deprecated identity dependency. * Removing codebloat unit testing projects. * Added validation example * Revised examples to include new validation abstractions/implementation. --- Build/Build.cs | 2 +- .../HR.LeaveManagement.API.csproj | 4 +- .../Middleware/ExceptionMiddleware.cs | 2 +- .../HR.LeaveManagement.API/Program.cs | 8 ++- ...aveManagement.Application.UnitTests.csproj | 2 +- .../CreateLeaveTypeCommandHandlerTests.cs | 4 +- .../Exceptions/ValidationException.cs | 20 -------- .../CreateLeaveAllocationCommandHandler.cs | 9 ++-- .../UpdateLeaveAllocationCommandHandler.cs | 11 ++-- .../GetLeaveAllocationListRequestHandler.cs | 2 +- .../CreateLeaveRequestCommandHandler.cs | 16 +++--- .../UpdateLeaveRequestCommandHandler.cs | 11 ++-- .../Commands/CreateLeaveTypeCommandHandler.cs | 9 ++-- .../Commands/UpdateLeaveTypeCommandHandler.cs | 10 ++-- .../HR.LeaveManagement.Application.csproj | 6 ++- .../HR.LeaveManagement.Identity.csproj | 9 ++-- .../HR.LeaveManagement.Persistence.csproj | 2 +- Examples/Examples.sln | 31 ++++------- .../ConfigurationContainer.cs | 14 +++++ ...xamples.Validation.FluentValidation.csproj | 14 +++++ .../ITestApplicationService.cs | 10 ++++ .../Program.cs | 51 +++++++++++++++++++ .../TestApplicationService.cs | 27 ++++++++++ .../TestDto.cs | 18 +++++++ .../Validators/TestDtoValidator.cs | 17 +++++++ Src/RCommon.Dapper/RCommon.Dapper.csproj | 6 +-- Src/RCommon.EfCore/RCommon.EFCore.csproj | 4 +- Src/RCommon.Linq2Db/RCommon.Linq2Db.csproj | 12 ++--- .../RCommon.MassTransit.csproj | 2 +- Src/RCommon.SendGrid/RCommon.SendGrid.csproj | 2 +- .../Attributes/JsonModelBinderAttribute.cs | 33 ------------ Src/RCommon.Web/RCommon.Web.csproj | 5 +- .../RCommon.Wolverine.csproj | 2 +- Tests/RCommon.DotNet6.Tests/DotNetTests.cs | 21 -------- .../RCommon.DotNet6.Tests.csproj | 39 -------------- Tests/RCommon.DotNet7.Tests/DotNetTests.cs | 12 ----- .../RCommon.DotNet7.Tests.csproj | 44 ---------------- Tests/RCommon.DotNet7.Tests/Usings.cs | 1 - Tests/RCommon.DotNet8.Tests/DotNetTests.cs | 12 ----- Tests/RCommon.DotNet8.Tests/GlobalUsings.cs | 1 - .../RCommon.DotNet8.Tests.csproj | 45 ---------------- .../RCommon.Emailing.SendGrid.Tests.csproj | 6 +-- .../RCommon.Emailing.Tests.csproj | 6 +-- .../RCommon.Mediator.MediatR.Tests.csproj | 8 +-- ...RCommon.Messaging.MassTransit.Tests.csproj | 2 +- .../RCommon.Messaging.Wolverine.Tests.csproj | 2 +- .../RCommon.Persistence.Dapper.Tests.csproj | 8 +-- .../RCommon.Persistence.EFCore.Tests.csproj | 6 +-- .../RCommon.Persistence.Linq2Db.Tests.csproj | 4 +- .../RCommon.Security.Tests.csproj | 2 +- .../RCommon.TestBase.Data.csproj | 6 +-- .../RCommon.TestBase/RCommon.TestBase.csproj | 2 +- 52 files changed, 271 insertions(+), 331 deletions(-) delete mode 100644 Examples/CleanWithCQRS/HR.LeaveManagement.Application/Exceptions/ValidationException.cs create mode 100644 Examples/Validation/Examples.Validation.FluentValidation/ConfigurationContainer.cs create mode 100644 Examples/Validation/Examples.Validation.FluentValidation/Examples.Validation.FluentValidation.csproj create mode 100644 Examples/Validation/Examples.Validation.FluentValidation/ITestApplicationService.cs create mode 100644 Examples/Validation/Examples.Validation.FluentValidation/Program.cs create mode 100644 Examples/Validation/Examples.Validation.FluentValidation/TestApplicationService.cs create mode 100644 Examples/Validation/Examples.Validation.FluentValidation/TestDto.cs create mode 100644 Examples/Validation/Examples.Validation.FluentValidation/Validators/TestDtoValidator.cs delete mode 100644 Src/RCommon.Web/Attributes/JsonModelBinderAttribute.cs delete mode 100644 Tests/RCommon.DotNet6.Tests/DotNetTests.cs delete mode 100644 Tests/RCommon.DotNet6.Tests/RCommon.DotNet6.Tests.csproj delete mode 100644 Tests/RCommon.DotNet7.Tests/DotNetTests.cs delete mode 100644 Tests/RCommon.DotNet7.Tests/RCommon.DotNet7.Tests.csproj delete mode 100644 Tests/RCommon.DotNet7.Tests/Usings.cs delete mode 100644 Tests/RCommon.DotNet8.Tests/DotNetTests.cs delete mode 100644 Tests/RCommon.DotNet8.Tests/GlobalUsings.cs delete mode 100644 Tests/RCommon.DotNet8.Tests/RCommon.DotNet8.Tests.csproj diff --git a/Build/Build.cs b/Build/Build.cs index 6a08dcee..b375ea9e 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -135,7 +135,7 @@ protected override void OnBuildInitialized() { Log.Information("Generating NuGet packages for projects in solution"); int commitNum = 0; - string NuGetVersionCustom = "2.0.0.877"; + string NuGetVersionCustom = "2.0.0.878"; //if it's not a tagged release - append the commit number to the package version diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.API/HR.LeaveManagement.API.csproj b/Examples/CleanWithCQRS/HR.LeaveManagement.API/HR.LeaveManagement.API.csproj index 5171fc20..018c1cb6 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.API/HR.LeaveManagement.API.csproj +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.API/HR.LeaveManagement.API.csproj @@ -8,7 +8,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -16,8 +16,10 @@ + + diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.API/Middleware/ExceptionMiddleware.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.API/Middleware/ExceptionMiddleware.cs index 0a1697ff..ab1f88ab 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.API/Middleware/ExceptionMiddleware.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.API/Middleware/ExceptionMiddleware.cs @@ -42,7 +42,7 @@ private Task HandleExceptionAsync(HttpContext context, Exception exception) case BadRequestException badRequestException: statusCode = HttpStatusCode.BadRequest; break; - case ValidationException validationException: + case RCommon.ApplicationServices.Validation.ValidationException validationException: statusCode = HttpStatusCode.BadRequest; result = JsonConvert.SerializeObject(validationException.Errors); break; diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.API/Program.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.API/Program.cs index cdb56a83..4dd50d09 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.API/Program.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.API/Program.cs @@ -29,6 +29,8 @@ using HR.LeaveManagement.Application.Features.LeaveTypes.Requests.Queries; using HR.LeaveManagement.Application.Features.LeaveTypes.Handlers.Queries; using HR.LeaveManagement.Application.DTOs.LeaveType; +using RCommon.ApplicationServices; +using RCommon.FluentValidation; var builder = WebApplication.CreateBuilder(args); @@ -56,7 +58,7 @@ mediator.AddRequest(); mediator.AddRequest, GetLeaveAllocationListRequestHandler>(); mediator.AddRequest(); - mediator.AddRequest(); + mediator.AddRequest(); mediator.AddRequest(); mediator.AddRequest(); mediator.AddRequest(); @@ -96,6 +98,10 @@ options.AutoCompleteScope = true; options.DefaultIsolation = IsolationLevel.ReadCommitted; }); + }) + .WithValidation(validation => + { + validation.AddValidatorsFromAssemblyContaining(typeof(ApplicationServicesRegistration)); }); // Add services to the container. diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application.UnitTests/HR.LeaveManagement.Application.UnitTests.csproj b/Examples/CleanWithCQRS/HR.LeaveManagement.Application.UnitTests/HR.LeaveManagement.Application.UnitTests.csproj index 7a2ac640..8488f286 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application.UnitTests/HR.LeaveManagement.Application.UnitTests.csproj +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application.UnitTests/HR.LeaveManagement.Application.UnitTests.csproj @@ -9,7 +9,7 @@ - + diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application.UnitTests/LeaveTypes/Commands/CreateLeaveTypeCommandHandlerTests.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.Application.UnitTests/LeaveTypes/Commands/CreateLeaveTypeCommandHandlerTests.cs index a37e551b..14512b7f 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application.UnitTests/LeaveTypes/Commands/CreateLeaveTypeCommandHandlerTests.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application.UnitTests/LeaveTypes/Commands/CreateLeaveTypeCommandHandlerTests.cs @@ -10,6 +10,7 @@ using HR.LeaveManagement.Domain; using Moq; using NUnit.Framework; +using RCommon.ApplicationServices.Validation; using RCommon.Persistence; using RCommon.Persistence.Crud; using Shouldly; @@ -42,9 +43,10 @@ public CreateLeaveTypeCommandHandlerTests() var testData = new List(); var mock = new Mock>(); + var validationMock = new Mock(); mock.Setup(x => x.AddAsync(TestDataActions.CreateLeaveTypeStub(), CancellationToken.None)) .Returns(() => Task.FromResult(new BaseCommandResponse())); - _handler = new CreateLeaveTypeCommandHandler(_mapper, mock.Object); + _handler = new CreateLeaveTypeCommandHandler(_mapper, mock.Object, validationMock.Object); _leaveTypeDto = new CreateLeaveTypeDto { diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Exceptions/ValidationException.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Exceptions/ValidationException.cs deleted file mode 100644 index 41149468..00000000 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Exceptions/ValidationException.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentValidation.Results; -using System; -using System.Collections.Generic; -using System.Text; - -namespace HR.LeaveManagement.Application.Exceptions -{ - public class ValidationException : ApplicationException - { - public List Errors { get; set; } = new List(); - - public ValidationException(ValidationResult validationResult) - { - foreach (var error in validationResult.Errors) - { - Errors.Add(error.ErrorMessage); - } - } - } -} diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Commands/CreateLeaveAllocationCommandHandler.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Commands/CreateLeaveAllocationCommandHandler.cs index 4d2fc4eb..780a6755 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Commands/CreateLeaveAllocationCommandHandler.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Commands/CreateLeaveAllocationCommandHandler.cs @@ -16,6 +16,7 @@ using RCommon.Persistence; using HR.LeaveManagement.Domain.Specifications; using RCommon.Persistence.Crud; +using RCommon.ApplicationServices.Validation; namespace HR.LeaveManagement.Application.Features.LeaveAllocations.Handlers.Commands { @@ -25,11 +26,13 @@ public class CreateLeaveAllocationCommandHandler : IAppRequestHandler _leaveAllocationRepository; private readonly IUserService _userService; private readonly IMapper _mapper; + private readonly IValidationService _validationService; public CreateLeaveAllocationCommandHandler(IGraphRepository leaveTypeRepository, IGraphRepository leaveAllocationRepository, IUserService userService, - IMapper mapper) + IMapper mapper, + IValidationService validationService) { this._leaveTypeRepository = leaveTypeRepository; this._leaveAllocationRepository = leaveAllocationRepository; @@ -37,13 +40,13 @@ public CreateLeaveAllocationCommandHandler(IGraphRepository leaveType this._leaveTypeRepository.DataStoreName = DataStoreNamesConst.LeaveManagement; this._userService = userService; _mapper = mapper; + _validationService = validationService; } public async Task HandleAsync(CreateLeaveAllocationCommand request, CancellationToken cancellationToken) { var response = new BaseCommandResponse(); - var validator = new CreateLeaveAllocationDtoValidator(_leaveTypeRepository); - var validationResult = await validator.ValidateAsync(request.LeaveAllocationDto); + var validationResult = await _validationService.ValidateAsync(request.LeaveAllocationDto); if (validationResult.IsValid == false) { diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Commands/UpdateLeaveAllocationCommandHandler.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Commands/UpdateLeaveAllocationCommandHandler.cs index 23a28fe6..f67537e3 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Commands/UpdateLeaveAllocationCommandHandler.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Commands/UpdateLeaveAllocationCommandHandler.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using RCommon.Persistence; using RCommon.Persistence.Crud; +using RCommon.ApplicationServices.Validation; namespace HR.LeaveManagement.Application.Features.LeaveAllocations.Handlers.Commands { @@ -20,25 +21,27 @@ public class UpdateLeaveAllocationCommandHandler : IAppRequestHandler _leaveAllocationRepository; private readonly IReadOnlyRepository _leaveTypeRepository; private readonly IMapper _mapper; + private readonly IValidationService _validationService; public UpdateLeaveAllocationCommandHandler(IGraphRepository leaveAllocationRepository, IReadOnlyRepository leaveTypeRepository, - IMapper mapper) + IMapper mapper, + IValidationService validationService) { this._leaveAllocationRepository = leaveAllocationRepository; this._leaveTypeRepository = leaveTypeRepository; this._leaveAllocationRepository.DataStoreName = DataStoreNamesConst.LeaveManagement; this._leaveTypeRepository.DataStoreName = DataStoreNamesConst.LeaveManagement; _mapper = mapper; + _validationService = validationService; } public async Task HandleAsync(UpdateLeaveAllocationCommand request, CancellationToken cancellationToken) { - var validator = new UpdateLeaveAllocationDtoValidator(this._leaveTypeRepository); - var validationResult = await validator.ValidateAsync(request.LeaveAllocationDto); + var validationResult = await _validationService.ValidateAsync(request.LeaveAllocationDto); if (validationResult.IsValid == false) - throw new ValidationException(validationResult); + throw new ValidationException(validationResult.Errors); var leaveAllocation = await _leaveAllocationRepository.FindAsync(request.LeaveAllocationDto.Id); diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Queries/GetLeaveAllocationListRequestHandler.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Queries/GetLeaveAllocationListRequestHandler.cs index 73614759..2622e4ac 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Queries/GetLeaveAllocationListRequestHandler.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveAllocations/Handlers/Queries/GetLeaveAllocationListRequestHandler.cs @@ -6,13 +6,13 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using HR.LeaveManagement.Application.Contracts.Identity; using HR.LeaveManagement.Domain; using HR.LeaveManagement.Application.Constants; using RCommon.Persistence; using System.Collections; using RCommon.Persistence.Crud; +using Microsoft.AspNetCore.Http; namespace HR.LeaveManagement.Application.Features.LeaveAllocations.Handlers.Queries { diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveRequests/Handlers/Commands/CreateLeaveRequestCommandHandler.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveRequests/Handlers/Commands/CreateLeaveRequestCommandHandler.cs index 30aa9696..4e11cb32 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveRequests/Handlers/Commands/CreateLeaveRequestCommandHandler.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveRequests/Handlers/Commands/CreateLeaveRequestCommandHandler.cs @@ -23,6 +23,7 @@ using Microsoft.Extensions.Options; using RCommon.Emailing.SendGrid; using RCommon.Persistence.Crud; +using RCommon.ApplicationServices.Validation; namespace HR.LeaveManagement.Application.Features.LeaveRequests.Handlers.Commands { @@ -32,6 +33,7 @@ public class CreateLeaveRequestCommandHandler : IAppRequestHandler _emailSettings; private readonly IMapper _mapper; + private readonly IValidationService _validationService; private readonly IReadOnlyRepository _leaveTypeRepository; private readonly IGraphRepository _leaveAllocationRepository; private readonly IGraphRepository _leaveRequestRepository; @@ -43,7 +45,8 @@ public CreateLeaveRequestCommandHandler( IEmailService emailSender, ICurrentUser currentUser, IOptions emailSettings, - IMapper mapper) + IMapper mapper, + IValidationService validationService) { _leaveTypeRepository = leaveTypeRepository; _leaveAllocationRepository = leaveAllocationRepository; @@ -55,21 +58,19 @@ public CreateLeaveRequestCommandHandler( this._currentUser = currentUser; _emailSettings=emailSettings; _mapper = mapper; + _validationService = validationService; } public async Task HandleAsync(CreateLeaveRequestCommand request, CancellationToken cancellationToken) { var response = new BaseCommandResponse(); - var validator = new CreateLeaveRequestDtoValidator(_leaveTypeRepository); - var validationResult = await validator.ValidateAsync(request.LeaveRequestDto); + var validationResult = await _validationService.ValidateAsync(request.LeaveRequestDto); var userId = _currentUser.FindClaimValue(CustomClaimTypes.Uid); - //_httpContextAccessor.HttpContext.User.Claims.FirstOrDefault( - //q => q.Type == CustomClaimTypes.Uid)?.Value; var allocation = _leaveAllocationRepository.FirstOrDefault(x=>x.EmployeeId == userId && x.LeaveTypeId == request.LeaveRequestDto.LeaveTypeId); if(allocation is null) { - validationResult.Errors.Add(new FluentValidation.Results.ValidationFailure(nameof(request.LeaveRequestDto.LeaveTypeId), + validationResult.Errors.Add(new ValidationFault(nameof(request.LeaveRequestDto.LeaveTypeId), "You do not have any allocations for this leave type.")); } else @@ -77,7 +78,7 @@ public async Task HandleAsync(CreateLeaveRequestCommand req int daysRequested = (int)(request.LeaveRequestDto.EndDate - request.LeaveRequestDto.StartDate).TotalDays; if (daysRequested > allocation.NumberOfDays) { - validationResult.Errors.Add(new FluentValidation.Results.ValidationFailure( + validationResult.Errors.Add(new ValidationFault( nameof(request.LeaveRequestDto.EndDate), "You do not have enough days for this request")); } } @@ -102,7 +103,6 @@ public async Task HandleAsync(CreateLeaveRequestCommand req try { var emailAddress = _currentUser.FindClaimValue(ClaimTypes.Email); - //_httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Email).Value; var email = new MailMessage(new MailAddress(this._emailSettings.Value.FromEmailDefault, this._emailSettings.Value.FromNameDefault), new MailAddress(emailAddress)) diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveRequests/Handlers/Commands/UpdateLeaveRequestCommandHandler.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveRequests/Handlers/Commands/UpdateLeaveRequestCommandHandler.cs index 628945b1..93f6af47 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveRequests/Handlers/Commands/UpdateLeaveRequestCommandHandler.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveRequests/Handlers/Commands/UpdateLeaveRequestCommandHandler.cs @@ -13,6 +13,7 @@ using System.Threading.Tasks; using RCommon.Persistence; using RCommon.Persistence.Crud; +using RCommon.ApplicationServices.Validation; namespace HR.LeaveManagement.Application.Features.LeaveRequests.Handlers.Commands { @@ -22,12 +23,14 @@ public class UpdateLeaveRequestCommandHandler : IAppRequestHandler _leaveTypeRepository; private readonly IGraphRepository _leaveAllocationRepository; private readonly IMapper _mapper; + private readonly IValidationService _validationService; public UpdateLeaveRequestCommandHandler( IGraphRepository leaveRequestRepository, IReadOnlyRepository leaveTypeRepository, IGraphRepository leaveAllocationRepository, - IMapper mapper) + IMapper mapper, + IValidationService validationService) { this._leaveRequestRepository = leaveRequestRepository; _leaveTypeRepository = leaveTypeRepository; @@ -36,6 +39,7 @@ public UpdateLeaveRequestCommandHandler( this._leaveTypeRepository.DataStoreName = DataStoreNamesConst.LeaveManagement; this._leaveRequestRepository.DataStoreName = DataStoreNamesConst.LeaveManagement; _mapper = mapper; + _validationService = validationService; } public async Task HandleAsync(UpdateLeaveRequestCommand request, CancellationToken cancellationToken) @@ -47,10 +51,9 @@ public async Task HandleAsync(UpdateLeaveRequestCommand request, CancellationTok if (request.LeaveRequestDto != null) { - var validator = new UpdateLeaveRequestDtoValidator(_leaveTypeRepository); - var validationResult = await validator.ValidateAsync(request.LeaveRequestDto); + var validationResult = await _validationService.ValidateAsync(request.LeaveRequestDto); if (validationResult.IsValid == false) - throw new ValidationException(validationResult); + throw new ValidationException(validationResult.Errors); _mapper.Map(request.LeaveRequestDto, leaveRequest); diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveTypes/Handlers/Commands/CreateLeaveTypeCommandHandler.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveTypes/Handlers/Commands/CreateLeaveTypeCommandHandler.cs index 523b5482..87a89b01 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveTypes/Handlers/Commands/CreateLeaveTypeCommandHandler.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveTypes/Handlers/Commands/CreateLeaveTypeCommandHandler.cs @@ -13,6 +13,7 @@ using System.Linq; using RCommon.Persistence; using RCommon.Persistence.Crud; +using RCommon.ApplicationServices.Validation; namespace HR.LeaveManagement.Application.Features.LeaveTypes.Handlers.Commands { @@ -20,18 +21,20 @@ public class CreateLeaveTypeCommandHandler : IAppRequestHandler _leaveTypeRepository; - public CreateLeaveTypeCommandHandler(IMapper mapper, IGraphRepository leaveTypeRepository) + private readonly IValidationService _validationService; + + public CreateLeaveTypeCommandHandler(IMapper mapper, IGraphRepository leaveTypeRepository, IValidationService validationService) { _mapper = mapper; _leaveTypeRepository = leaveTypeRepository; + _validationService = validationService; this._leaveTypeRepository.DataStoreName = DataStoreNamesConst.LeaveManagement; } public async Task HandleAsync(CreateLeaveTypeCommand request, CancellationToken cancellationToken) { var response = new BaseCommandResponse(); - var validator = new CreateLeaveTypeDtoValidator(); - var validationResult = await validator.ValidateAsync(request.LeaveTypeDto); + var validationResult = await _validationService.ValidateAsync(request.LeaveTypeDto); if (validationResult.IsValid == false) { diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveTypes/Handlers/Commands/UpdateLeaveTypeCommandHandler.cs b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveTypes/Handlers/Commands/UpdateLeaveTypeCommandHandler.cs index c5ab679a..331a23da 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveTypes/Handlers/Commands/UpdateLeaveTypeCommandHandler.cs +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/Features/LeaveTypes/Handlers/Commands/UpdateLeaveTypeCommandHandler.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using RCommon.Persistence; using RCommon.Persistence.Crud; +using RCommon.ApplicationServices.Validation; namespace HR.LeaveManagement.Application.Features.LeaveTypes.Handlers.Commands { @@ -18,21 +19,22 @@ public class UpdateLeaveTypeCommandHandler : IAppRequestHandler _leaveTypeRepository; + private readonly IValidationService _validationService; - public UpdateLeaveTypeCommandHandler(IMapper mapper, IGraphRepository leaveTypeRepository) + public UpdateLeaveTypeCommandHandler(IMapper mapper, IGraphRepository leaveTypeRepository, IValidationService validationService) { _mapper = mapper; _leaveTypeRepository = leaveTypeRepository; + _validationService = validationService; this._leaveTypeRepository.DataStoreName = DataStoreNamesConst.LeaveManagement; } public async Task HandleAsync(UpdateLeaveTypeCommand request, CancellationToken cancellationToken) { - var validator = new UpdateLeaveTypeDtoValidator(); - var validationResult = await validator.ValidateAsync(request.LeaveTypeDto); + var validationResult = await _validationService.ValidateAsync(request.LeaveTypeDto); if (validationResult.IsValid == false) - throw new ValidationException(validationResult); + throw new ValidationException(validationResult.Errors); var leaveType = await _leaveTypeRepository.FindAsync(request.LeaveTypeDto.Id); diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/HR.LeaveManagement.Application.csproj b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/HR.LeaveManagement.Application.csproj index 40b332ce..f86b01d1 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Application/HR.LeaveManagement.Application.csproj +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Application/HR.LeaveManagement.Application.csproj @@ -5,10 +5,12 @@ enable disable + + + - - + diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Identity/HR.LeaveManagement.Identity.csproj b/Examples/CleanWithCQRS/HR.LeaveManagement.Identity/HR.LeaveManagement.Identity.csproj index dc53618a..b014398b 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Identity/HR.LeaveManagement.Identity.csproj +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Identity/HR.LeaveManagement.Identity.csproj @@ -7,13 +7,12 @@ - - - + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Examples/CleanWithCQRS/HR.LeaveManagement.Persistence/HR.LeaveManagement.Persistence.csproj b/Examples/CleanWithCQRS/HR.LeaveManagement.Persistence/HR.LeaveManagement.Persistence.csproj index e98800f9..bdcd402a 100644 --- a/Examples/CleanWithCQRS/HR.LeaveManagement.Persistence/HR.LeaveManagement.Persistence.csproj +++ b/Examples/CleanWithCQRS/HR.LeaveManagement.Persistence/HR.LeaveManagement.Persistence.csproj @@ -7,7 +7,7 @@ - + diff --git a/Examples/Examples.sln b/Examples/Examples.sln index 41758b7e..781531d6 100644 --- a/Examples/Examples.sln +++ b/Examples/Examples.sln @@ -91,12 +91,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Messaging", "Messaging", "{ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Providers", "Providers", "{3199F749-0082-41D0-91D3-ECED117F8B08}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.DotNet6.Tests", "..\Tests\RCommon.DotNet6.Tests\RCommon.DotNet6.Tests.csproj", "{B93C2373-7ADD-4D1F-B8CB-8FF32EAF364E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.DotNet7.Tests", "..\Tests\RCommon.DotNet7.Tests\RCommon.DotNet7.Tests.csproj", "{CABBB120-77E7-4C1D-B706-D934BE1C035C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.DotNet8.Tests", "..\Tests\RCommon.DotNet8.Tests\RCommon.DotNet8.Tests.csproj", "{75F1593B-B15D-41E5-B404-020B35A3F691}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.Wolverine", "..\Src\RCommon.Wolverine\RCommon.Wolverine.csproj", "{90B4A098-01AB-4B35-987E-838F2241DA17}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventHandling", "EventHandling", "{FCC70943-06B2-4743-A99D-82F5122297F3}" @@ -119,6 +113,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mediator", "Mediator", "{90 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.FluentValidation", "..\Src\RCommon.FluentValidation\RCommon.FluentValidation.csproj", "{BBBCCC2B-2218-4C32-96EE-C2153A23F643}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Validation", "Validation", "{0F54DCE2-27A5-4D07-B542-6D2A7B50D0EC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples.Validation.FluentValidation", "Validation\Examples.Validation.FluentValidation\Examples.Validation.FluentValidation.csproj", "{256821F9-8160-4819-B0A1-B769C5BBBBB6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -265,18 +263,6 @@ Global {38508541-4429-4A30-9D84-B151250E08B8}.Debug|Any CPU.Build.0 = Debug|Any CPU {38508541-4429-4A30-9D84-B151250E08B8}.Release|Any CPU.ActiveCfg = Release|Any CPU {38508541-4429-4A30-9D84-B151250E08B8}.Release|Any CPU.Build.0 = Release|Any CPU - {B93C2373-7ADD-4D1F-B8CB-8FF32EAF364E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B93C2373-7ADD-4D1F-B8CB-8FF32EAF364E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B93C2373-7ADD-4D1F-B8CB-8FF32EAF364E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B93C2373-7ADD-4D1F-B8CB-8FF32EAF364E}.Release|Any CPU.Build.0 = Release|Any CPU - {CABBB120-77E7-4C1D-B706-D934BE1C035C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CABBB120-77E7-4C1D-B706-D934BE1C035C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CABBB120-77E7-4C1D-B706-D934BE1C035C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CABBB120-77E7-4C1D-B706-D934BE1C035C}.Release|Any CPU.Build.0 = Release|Any CPU - {75F1593B-B15D-41E5-B404-020B35A3F691}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {75F1593B-B15D-41E5-B404-020B35A3F691}.Debug|Any CPU.Build.0 = Debug|Any CPU - {75F1593B-B15D-41E5-B404-020B35A3F691}.Release|Any CPU.ActiveCfg = Release|Any CPU - {75F1593B-B15D-41E5-B404-020B35A3F691}.Release|Any CPU.Build.0 = Release|Any CPU {90B4A098-01AB-4B35-987E-838F2241DA17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {90B4A098-01AB-4B35-987E-838F2241DA17}.Debug|Any CPU.Build.0 = Debug|Any CPU {90B4A098-01AB-4B35-987E-838F2241DA17}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -309,6 +295,10 @@ Global {BBBCCC2B-2218-4C32-96EE-C2153A23F643}.Debug|Any CPU.Build.0 = Debug|Any CPU {BBBCCC2B-2218-4C32-96EE-C2153A23F643}.Release|Any CPU.ActiveCfg = Release|Any CPU {BBBCCC2B-2218-4C32-96EE-C2153A23F643}.Release|Any CPU.Build.0 = Release|Any CPU + {256821F9-8160-4819-B0A1-B769C5BBBBB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {256821F9-8160-4819-B0A1-B769C5BBBBB6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {256821F9-8160-4819-B0A1-B769C5BBBBB6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {256821F9-8160-4819-B0A1-B769C5BBBBB6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -345,9 +335,6 @@ Global {86B19A1B-17F9-410F-8B97-74FE3EE7A4BE} = {0AF37317-F10E-47E8-A4C8-9EA886E00E40} {38508541-4429-4A30-9D84-B151250E08B8} = {86B19A1B-17F9-410F-8B97-74FE3EE7A4BE} {35AE0870-0A6D-4F27-B534-B8DCDFD11A36} = {3234C3BB-1632-4684-838E-9D6D382D4D4D} - {B93C2373-7ADD-4D1F-B8CB-8FF32EAF364E} = {788A01F9-0510-441A-B05B-0CDA0EE87507} - {CABBB120-77E7-4C1D-B706-D934BE1C035C} = {788A01F9-0510-441A-B05B-0CDA0EE87507} - {75F1593B-B15D-41E5-B404-020B35A3F691} = {788A01F9-0510-441A-B05B-0CDA0EE87507} {90B4A098-01AB-4B35-987E-838F2241DA17} = {3199F749-0082-41D0-91D3-ECED117F8B08} {FCC70943-06B2-4743-A99D-82F5122297F3} = {3234C3BB-1632-4684-838E-9D6D382D4D4D} {213F2EFE-F1DF-471C-A518-94D107DD543F} = {FCC70943-06B2-4743-A99D-82F5122297F3} @@ -359,6 +346,8 @@ Global {05B6EF05-8053-45D1-8649-1779B0D7D6C7} = {9085B4F5-E26A-471D-B25D-5D69B0337B02} {9085B4F5-E26A-471D-B25D-5D69B0337B02} = {3234C3BB-1632-4684-838E-9D6D382D4D4D} {BBBCCC2B-2218-4C32-96EE-C2153A23F643} = {3199F749-0082-41D0-91D3-ECED117F8B08} + {0F54DCE2-27A5-4D07-B542-6D2A7B50D0EC} = {3234C3BB-1632-4684-838E-9D6D382D4D4D} + {256821F9-8160-4819-B0A1-B769C5BBBBB6} = {0F54DCE2-27A5-4D07-B542-6D2A7B50D0EC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0B0CD26D-8067-4667-863E-6B0EE7EDAA42} diff --git a/Examples/Validation/Examples.Validation.FluentValidation/ConfigurationContainer.cs b/Examples/Validation/Examples.Validation.FluentValidation/ConfigurationContainer.cs new file mode 100644 index 00000000..f2e109d6 --- /dev/null +++ b/Examples/Validation/Examples.Validation.FluentValidation/ConfigurationContainer.cs @@ -0,0 +1,14 @@ +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Examples.Validation.FluentValidation +{ + internal static class ConfigurationContainer + { + public static IConfiguration Configuration { get; set; } + } +} diff --git a/Examples/Validation/Examples.Validation.FluentValidation/Examples.Validation.FluentValidation.csproj b/Examples/Validation/Examples.Validation.FluentValidation/Examples.Validation.FluentValidation.csproj new file mode 100644 index 00000000..406bb106 --- /dev/null +++ b/Examples/Validation/Examples.Validation.FluentValidation/Examples.Validation.FluentValidation.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/Examples/Validation/Examples.Validation.FluentValidation/ITestApplicationService.cs b/Examples/Validation/Examples.Validation.FluentValidation/ITestApplicationService.cs new file mode 100644 index 00000000..83936c12 --- /dev/null +++ b/Examples/Validation/Examples.Validation.FluentValidation/ITestApplicationService.cs @@ -0,0 +1,10 @@ +using RCommon.ApplicationServices.ExecutionResults; +using RCommon.ApplicationServices.Validation; + +namespace Examples.Validation.FluentValidation +{ + public interface ITestApplicationService + { + Task ExecuteTestMethod(TestDto dto); + } +} diff --git a/Examples/Validation/Examples.Validation.FluentValidation/Program.cs b/Examples/Validation/Examples.Validation.FluentValidation/Program.cs new file mode 100644 index 00000000..dfe42b64 --- /dev/null +++ b/Examples/Validation/Examples.Validation.FluentValidation/Program.cs @@ -0,0 +1,51 @@ +using Examples.Validation.FluentValidation; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using RCommon; +using RCommon.ApplicationServices; +using RCommon.ApplicationServices.ExecutionResults; +using RCommon.FluentValidation; +using System.Diagnostics; + +try +{ + var host = Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration((context, builder) => + { + + ConfigurationContainer.Configuration = builder + .Build(); + }) + .ConfigureServices(services => + { + // Configure RCommon + services.AddRCommon() + .WithValidation(validation => + { + validation.AddValidatorsFromAssemblyContaining(typeof(TestDto)); + }); + Console.WriteLine(services.GenerateServiceDescriptorsString()); + services.AddTransient(); + + }).Build(); + + Console.WriteLine("Example Starting"); + var appService = host.Services.GetRequiredService(); + var validationOutcome1 = await appService.ExecuteTestMethod(new TestDto("")); // Will fail + var validationOutcome2 = await appService.ExecuteTestMethod(new TestDto("test")); // Will pass + + Console.WriteLine(validationOutcome1.ToString()); + Console.WriteLine("Validation Outcome 1 complete..."); + Console.WriteLine(validationOutcome2.ToString()); + Console.WriteLine("Validation Outcome 2 complete..."); + + Console.WriteLine("Example Complete"); + Console.ReadLine(); +} +catch (Exception ex) +{ + Console.WriteLine(ex.ToString()); + +} + diff --git a/Examples/Validation/Examples.Validation.FluentValidation/TestApplicationService.cs b/Examples/Validation/Examples.Validation.FluentValidation/TestApplicationService.cs new file mode 100644 index 00000000..9005fb27 --- /dev/null +++ b/Examples/Validation/Examples.Validation.FluentValidation/TestApplicationService.cs @@ -0,0 +1,27 @@ +using RCommon.ApplicationServices.Commands; +using RCommon.ApplicationServices.ExecutionResults; +using RCommon.ApplicationServices.Queries; +using RCommon.ApplicationServices.Validation; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Examples.Validation.FluentValidation +{ + public class TestApplicationService : ITestApplicationService + { + private readonly IValidationService _validationService; + + public TestApplicationService(IValidationService validationService) + { + _validationService = validationService; + } + + public async Task ExecuteTestMethod(TestDto dto) + { + return await _validationService.ValidateAsync(dto); + } + } +} diff --git a/Examples/Validation/Examples.Validation.FluentValidation/TestDto.cs b/Examples/Validation/Examples.Validation.FluentValidation/TestDto.cs new file mode 100644 index 00000000..147f1d85 --- /dev/null +++ b/Examples/Validation/Examples.Validation.FluentValidation/TestDto.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Examples.Validation.FluentValidation +{ + public record TestDto + { + public TestDto(string message) + { + Message = message; + } + + public string Message { get; } + } +} diff --git a/Examples/Validation/Examples.Validation.FluentValidation/Validators/TestDtoValidator.cs b/Examples/Validation/Examples.Validation.FluentValidation/Validators/TestDtoValidator.cs new file mode 100644 index 00000000..34dbe6f0 --- /dev/null +++ b/Examples/Validation/Examples.Validation.FluentValidation/Validators/TestDtoValidator.cs @@ -0,0 +1,17 @@ +using FluentValidation; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Examples.Validation.FluentValidation.Validators +{ + public class TestDtoValidator : AbstractValidator + { + public TestDtoValidator() + { + RuleFor(command => command.Message).NotNull().NotEmpty(); + } + } +} diff --git a/Src/RCommon.Dapper/RCommon.Dapper.csproj b/Src/RCommon.Dapper/RCommon.Dapper.csproj index da80940f..3dfc4d50 100644 --- a/Src/RCommon.Dapper/RCommon.Dapper.csproj +++ b/Src/RCommon.Dapper/RCommon.Dapper.csproj @@ -7,21 +7,21 @@ - + - + - + diff --git a/Src/RCommon.EfCore/RCommon.EFCore.csproj b/Src/RCommon.EfCore/RCommon.EFCore.csproj index 0098010b..a1cd1602 100644 --- a/Src/RCommon.EfCore/RCommon.EFCore.csproj +++ b/Src/RCommon.EfCore/RCommon.EFCore.csproj @@ -21,8 +21,8 @@ - - + + diff --git a/Src/RCommon.Linq2Db/RCommon.Linq2Db.csproj b/Src/RCommon.Linq2Db/RCommon.Linq2Db.csproj index c1882fca..b038ed79 100644 --- a/Src/RCommon.Linq2Db/RCommon.Linq2Db.csproj +++ b/Src/RCommon.Linq2Db/RCommon.Linq2Db.csproj @@ -7,18 +7,18 @@ - - + + - - + + - - + + diff --git a/Src/RCommon.MassTransit/RCommon.MassTransit.csproj b/Src/RCommon.MassTransit/RCommon.MassTransit.csproj index 14779471..53f58dd4 100644 --- a/Src/RCommon.MassTransit/RCommon.MassTransit.csproj +++ b/Src/RCommon.MassTransit/RCommon.MassTransit.csproj @@ -7,7 +7,7 @@ - + diff --git a/Src/RCommon.SendGrid/RCommon.SendGrid.csproj b/Src/RCommon.SendGrid/RCommon.SendGrid.csproj index 53b8315b..c4c9b662 100644 --- a/Src/RCommon.SendGrid/RCommon.SendGrid.csproj +++ b/Src/RCommon.SendGrid/RCommon.SendGrid.csproj @@ -7,7 +7,7 @@ - + diff --git a/Src/RCommon.Web/Attributes/JsonModelBinderAttribute.cs b/Src/RCommon.Web/Attributes/JsonModelBinderAttribute.cs deleted file mode 100644 index fec881f8..00000000 --- a/Src/RCommon.Web/Attributes/JsonModelBinderAttribute.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Mvc.ModelBinding; -using Newtonsoft.Json; -using System.Threading.Tasks; - -namespace RCommon.Web.Attributes -{ - public class JsonModelBinderAttribute : IModelBinder - { - //TODO: Modify this to IJsonSerializer - public Task BindModelAsync(ModelBindingContext bindingContext) - { - if (!bindingContext.HttpContext.Request.Query.ContainsKey(bindingContext.ModelName)) - { - bindingContext.Result = ModelBindingResult.Failed(); - return Task.CompletedTask; - } - - var json = bindingContext.HttpContext.Request.Query[bindingContext.ModelName][0]; - - if (json == null) - { - bindingContext.Result = ModelBindingResult.Failed(); - } - else - { - bindingContext.Result = ModelBindingResult.Success( - JsonConvert.DeserializeObject(json, bindingContext.ModelType)); - } - - return Task.CompletedTask; - } - } -} diff --git a/Src/RCommon.Web/RCommon.Web.csproj b/Src/RCommon.Web/RCommon.Web.csproj index 74b42579..43c10087 100644 --- a/Src/RCommon.Web/RCommon.Web.csproj +++ b/Src/RCommon.Web/RCommon.Web.csproj @@ -3,7 +3,6 @@ net6.0;net7.0;net8.0; - @@ -12,4 +11,8 @@ + + + + diff --git a/Src/RCommon.Wolverine/RCommon.Wolverine.csproj b/Src/RCommon.Wolverine/RCommon.Wolverine.csproj index cb171cec..ebfd7023 100644 --- a/Src/RCommon.Wolverine/RCommon.Wolverine.csproj +++ b/Src/RCommon.Wolverine/RCommon.Wolverine.csproj @@ -17,7 +17,7 @@ - + diff --git a/Tests/RCommon.DotNet6.Tests/DotNetTests.cs b/Tests/RCommon.DotNet6.Tests/DotNetTests.cs deleted file mode 100644 index 82c94de3..00000000 --- a/Tests/RCommon.DotNet6.Tests/DotNetTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using NUnit.Framework; - -namespace RCommon.DotNet6.Tests -{ - public class Tests - { - [SetUp] - public void Setup() - { - } - - [Test] - public void Can_Use_Dapper() - { - var services = new ServiceCollection(); - var target = new DapperPersistenceBuilder(services); - Assert.That(target, Is.Not.Null); - } - } -} diff --git a/Tests/RCommon.DotNet6.Tests/RCommon.DotNet6.Tests.csproj b/Tests/RCommon.DotNet6.Tests/RCommon.DotNet6.Tests.csproj deleted file mode 100644 index 97872e38..00000000 --- a/Tests/RCommon.DotNet6.Tests/RCommon.DotNet6.Tests.csproj +++ /dev/null @@ -1,39 +0,0 @@ - - - - net6.0 - enable - - false - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tests/RCommon.DotNet7.Tests/DotNetTests.cs b/Tests/RCommon.DotNet7.Tests/DotNetTests.cs deleted file mode 100644 index 2206456f..00000000 --- a/Tests/RCommon.DotNet7.Tests/DotNetTests.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace RCommon.DotNet7.Tests -{ - public class Tests - { - [SetUp] - public void Setup() - { - } - - - } -} diff --git a/Tests/RCommon.DotNet7.Tests/RCommon.DotNet7.Tests.csproj b/Tests/RCommon.DotNet7.Tests/RCommon.DotNet7.Tests.csproj deleted file mode 100644 index 1bc66911..00000000 --- a/Tests/RCommon.DotNet7.Tests/RCommon.DotNet7.Tests.csproj +++ /dev/null @@ -1,44 +0,0 @@ - - - - net7.0 - enable - enable - - false - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tests/RCommon.DotNet7.Tests/Usings.cs b/Tests/RCommon.DotNet7.Tests/Usings.cs deleted file mode 100644 index cefced49..00000000 --- a/Tests/RCommon.DotNet7.Tests/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; \ No newline at end of file diff --git a/Tests/RCommon.DotNet8.Tests/DotNetTests.cs b/Tests/RCommon.DotNet8.Tests/DotNetTests.cs deleted file mode 100644 index 93f0b9da..00000000 --- a/Tests/RCommon.DotNet8.Tests/DotNetTests.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace RCommon.DotNet8.Tests -{ - public class Tests - { - [SetUp] - public void Setup() - { - } - - - } -} diff --git a/Tests/RCommon.DotNet8.Tests/GlobalUsings.cs b/Tests/RCommon.DotNet8.Tests/GlobalUsings.cs deleted file mode 100644 index cefced49..00000000 --- a/Tests/RCommon.DotNet8.Tests/GlobalUsings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; \ No newline at end of file diff --git a/Tests/RCommon.DotNet8.Tests/RCommon.DotNet8.Tests.csproj b/Tests/RCommon.DotNet8.Tests/RCommon.DotNet8.Tests.csproj deleted file mode 100644 index 8359d838..00000000 --- a/Tests/RCommon.DotNet8.Tests/RCommon.DotNet8.Tests.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - net8.0 - enable - enable - - false - true - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tests/RCommon.Emailing.SendGrid.Tests/RCommon.Emailing.SendGrid.Tests.csproj b/Tests/RCommon.Emailing.SendGrid.Tests/RCommon.Emailing.SendGrid.Tests.csproj index cb97ddd7..f0c89c46 100644 --- a/Tests/RCommon.Emailing.SendGrid.Tests/RCommon.Emailing.SendGrid.Tests.csproj +++ b/Tests/RCommon.Emailing.SendGrid.Tests/RCommon.Emailing.SendGrid.Tests.csproj @@ -8,11 +8,11 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/RCommon.Emailing.Tests/RCommon.Emailing.Tests.csproj b/Tests/RCommon.Emailing.Tests/RCommon.Emailing.Tests.csproj index dd4053af..33e4599c 100644 --- a/Tests/RCommon.Emailing.Tests/RCommon.Emailing.Tests.csproj +++ b/Tests/RCommon.Emailing.Tests/RCommon.Emailing.Tests.csproj @@ -8,10 +8,10 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/RCommon.Mediator.MediatR.Tests/RCommon.Mediator.MediatR.Tests.csproj b/Tests/RCommon.Mediator.MediatR.Tests/RCommon.Mediator.MediatR.Tests.csproj index 34c53a27..ee16bd06 100644 --- a/Tests/RCommon.Mediator.MediatR.Tests/RCommon.Mediator.MediatR.Tests.csproj +++ b/Tests/RCommon.Mediator.MediatR.Tests/RCommon.Mediator.MediatR.Tests.csproj @@ -9,11 +9,11 @@ - - + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/RCommon.Messaging.MassTransit.Tests/RCommon.Messaging.MassTransit.Tests.csproj b/Tests/RCommon.Messaging.MassTransit.Tests/RCommon.Messaging.MassTransit.Tests.csproj index cac74dca..08094516 100644 --- a/Tests/RCommon.Messaging.MassTransit.Tests/RCommon.Messaging.MassTransit.Tests.csproj +++ b/Tests/RCommon.Messaging.MassTransit.Tests/RCommon.Messaging.MassTransit.Tests.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/RCommon.Messaging.Wolverine.Tests/RCommon.Messaging.Wolverine.Tests.csproj b/Tests/RCommon.Messaging.Wolverine.Tests/RCommon.Messaging.Wolverine.Tests.csproj index 1b033561..0b673168 100644 --- a/Tests/RCommon.Messaging.Wolverine.Tests/RCommon.Messaging.Wolverine.Tests.csproj +++ b/Tests/RCommon.Messaging.Wolverine.Tests/RCommon.Messaging.Wolverine.Tests.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/RCommon.Persistence.Dapper.Tests/RCommon.Persistence.Dapper.Tests.csproj b/Tests/RCommon.Persistence.Dapper.Tests/RCommon.Persistence.Dapper.Tests.csproj index 41c7122b..09ab3a13 100644 --- a/Tests/RCommon.Persistence.Dapper.Tests/RCommon.Persistence.Dapper.Tests.csproj +++ b/Tests/RCommon.Persistence.Dapper.Tests/RCommon.Persistence.Dapper.Tests.csproj @@ -7,7 +7,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -15,14 +15,14 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Tests/RCommon.Persistence.EFCore.Tests/RCommon.Persistence.EFCore.Tests.csproj b/Tests/RCommon.Persistence.EFCore.Tests/RCommon.Persistence.EFCore.Tests.csproj index a26fc29a..eccd452e 100644 --- a/Tests/RCommon.Persistence.EFCore.Tests/RCommon.Persistence.EFCore.Tests.csproj +++ b/Tests/RCommon.Persistence.EFCore.Tests/RCommon.Persistence.EFCore.Tests.csproj @@ -9,12 +9,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Tests/RCommon.Persistence.Linq2Db.Tests/RCommon.Persistence.Linq2Db.Tests.csproj b/Tests/RCommon.Persistence.Linq2Db.Tests/RCommon.Persistence.Linq2Db.Tests.csproj index f44c9aef..688a803f 100644 --- a/Tests/RCommon.Persistence.Linq2Db.Tests/RCommon.Persistence.Linq2Db.Tests.csproj +++ b/Tests/RCommon.Persistence.Linq2Db.Tests/RCommon.Persistence.Linq2Db.Tests.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/Tests/RCommon.Security.Tests/RCommon.Security.Tests.csproj b/Tests/RCommon.Security.Tests/RCommon.Security.Tests.csproj index 85046e8b..deca01cb 100644 --- a/Tests/RCommon.Security.Tests/RCommon.Security.Tests.csproj +++ b/Tests/RCommon.Security.Tests/RCommon.Security.Tests.csproj @@ -8,7 +8,7 @@ - + diff --git a/Tests/RCommon.TestBase.Data/RCommon.TestBase.Data.csproj b/Tests/RCommon.TestBase.Data/RCommon.TestBase.Data.csproj index 93d92847..46843673 100644 --- a/Tests/RCommon.TestBase.Data/RCommon.TestBase.Data.csproj +++ b/Tests/RCommon.TestBase.Data/RCommon.TestBase.Data.csproj @@ -7,12 +7,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Tests/RCommon.TestBase/RCommon.TestBase.csproj b/Tests/RCommon.TestBase/RCommon.TestBase.csproj index dbe1c7da..14b6f848 100644 --- a/Tests/RCommon.TestBase/RCommon.TestBase.csproj +++ b/Tests/RCommon.TestBase/RCommon.TestBase.csproj @@ -7,7 +7,7 @@ - +