From 630f2a0b96d43cdb253aff706cd4c1433d6c4e2a Mon Sep 17 00:00:00 2001 From: codewolf86 Date: Thu, 8 Oct 2020 08:25:47 +0100 Subject: [PATCH 1/2] Remove Restrictions on search endpoint --- .../GetApprenticeshipsQueryValidator.cs | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/src/CommitmentsV2/SFA.DAS.CommitmentsV2/Application/Queries/GetApprenticeships/GetApprenticeshipsQueryValidator.cs b/src/CommitmentsV2/SFA.DAS.CommitmentsV2/Application/Queries/GetApprenticeships/GetApprenticeshipsQueryValidator.cs index ede667a8ca..86279ec357 100644 --- a/src/CommitmentsV2/SFA.DAS.CommitmentsV2/Application/Queries/GetApprenticeships/GetApprenticeshipsQueryValidator.cs +++ b/src/CommitmentsV2/SFA.DAS.CommitmentsV2/Application/Queries/GetApprenticeships/GetApprenticeshipsQueryValidator.cs @@ -9,38 +9,6 @@ public class GetApprenticeshipsQueryValidator : AbstractValidator request.EmployerAccountId.HasValue && request.EmployerAccountId.Value > 0, () => - { - RuleFor(request => request.ProviderId) - .Must(id => id.HasValue && id.Value > 0) - .WithMessage("The provider id must be set"); - }); - - Unless(request => request.ProviderId.HasValue && request.ProviderId.Value > 0, () => - { - RuleFor(request => request.EmployerAccountId) - .Must(id => id.HasValue && id.Value > 0) - .WithMessage("The employer account id must be set"); - }); - - When(request => request.ProviderId.HasValue && request.EmployerAccountId.HasValue, () => - { - Unless(request => request.EmployerAccountId.Value == 0, () => - { - RuleFor(request => request.ProviderId) - .Must(id => id.Value == 0) - .WithMessage("The provider id must be zero if employer account id is set"); - }); - - Unless(request => request.ProviderId.Value == 0, () => - { - RuleFor(request => request.EmployerAccountId) - .Must(id => id.Value == 0) - .WithMessage("The employer account id must be zero if provider id is set"); - }); - }); - - RuleFor(request => request.SortField) .Must(field => string.IsNullOrEmpty(field) || typeof(Apprenticeship).GetProperties().Select(c => c.Name).Contains(field) || @@ -51,3 +19,4 @@ public GetApprenticeshipsQueryValidator() } } } + From ad122a740487945b7c58973a767c3abb4df44005 Mon Sep 17 00:00:00 2001 From: codewolf86 Date: Thu, 8 Oct 2020 10:49:29 +0100 Subject: [PATCH 2/2] Remove validation unit tests --- .../GetApprenticeshipsValidationTests.cs | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/src/CommitmentsV2/SFA.DAS.CommitmentsV2.UnitTests/Application/Queries/GetApprenticeships/GetApprenticeshipsValidationTests.cs b/src/CommitmentsV2/SFA.DAS.CommitmentsV2.UnitTests/Application/Queries/GetApprenticeships/GetApprenticeshipsValidationTests.cs index e5f838e7d1..64d9f7628a 100644 --- a/src/CommitmentsV2/SFA.DAS.CommitmentsV2.UnitTests/Application/Queries/GetApprenticeships/GetApprenticeshipsValidationTests.cs +++ b/src/CommitmentsV2/SFA.DAS.CommitmentsV2.UnitTests/Application/Queries/GetApprenticeships/GetApprenticeshipsValidationTests.cs @@ -7,34 +7,6 @@ namespace SFA.DAS.CommitmentsV2.UnitTests.Application.Queries.GetApprenticeships [TestFixture] public class GetApprenticeshipsValidationTests { - [TestCase(0, 1, true)] - [TestCase(1, 0, true)] - [TestCase(null, 1, true)] - [TestCase(1, null, true)] - [TestCase(1, 1, false)] - [TestCase(0, 0, false)] - [TestCase(null, null, false)] - [TestCase(null, 0, false)] - [TestCase(0, null, false)] - public void Validate_WithSpecifiedProviderAndEmployerId_ShouldSetIsValidCorrectly(long? providerId, long? employerId, bool expectedIsValid) - { - // arrange - var validator = new GetApprenticeshipsQueryValidator(); - var validationResults = validator.Validate(new GetApprenticeshipsQuery - { - EmployerAccountId = employerId, - ProviderId = providerId, - PageNumber = 1, - PageItemCount = 1 - }); - - // act - var actualIsValid = validationResults.IsValid; - - // Assert - Assert.AreEqual(expectedIsValid, actualIsValid); - } - [TestCase("test",false)] [TestCase(null,true)] [TestCase("",true)]