diff --git a/src/Employer/Employer.Web/ViewModels/Part1/Training/ConfirmTrainingViewModel.cs b/src/Employer/Employer.Web/ViewModels/Part1/Training/ConfirmTrainingViewModel.cs index 354fb654a3..8462f997b0 100644 --- a/src/Employer/Employer.Web/ViewModels/Part1/Training/ConfirmTrainingViewModel.cs +++ b/src/Employer/Employer.Web/ViewModels/Part1/Training/ConfirmTrainingViewModel.cs @@ -6,7 +6,7 @@ namespace Esfa.Recruit.Employer.Web.ViewModels.Part1.Training public class ConfirmTrainingViewModel { public string TrainingTitle { get; set; } - public ProgrammeLevel Level { get; set; } + public ApprenticeshipLevel Level { get; set; } public int DurationMonths { get; set; } public string ProgrammeType {get; set; } public string ProgrammeId { get; set; } diff --git a/src/Employer/Employer.Web/ViewModels/VacancyPreview/VacancyPreviewViewModel.cs b/src/Employer/Employer.Web/ViewModels/VacancyPreview/VacancyPreviewViewModel.cs index ea809eabc9..071485bc59 100644 --- a/src/Employer/Employer.Web/ViewModels/VacancyPreview/VacancyPreviewViewModel.cs +++ b/src/Employer/Employer.Web/ViewModels/VacancyPreview/VacancyPreviewViewModel.cs @@ -114,7 +114,7 @@ private bool IsEditRequired(string fieldIdentifier) }.Count(s => s == VacancyPreviewSectionState.Incomplete || s == VacancyPreviewSectionState.InvalidIncomplete); public string IncompleteRequiredSectionText => "section".ToQuantity(IncompleteRequiredSectionCount, ShowQuantityAs.None); - public ProgrammeLevel Level { get; set; } + public ApprenticeshipLevel Level { get; set; } public IList OrderedFieldNames => new List { diff --git a/src/Provider/Provider.Web/ViewModels/Part1/Training/ConfirmTrainingViewModel.cs b/src/Provider/Provider.Web/ViewModels/Part1/Training/ConfirmTrainingViewModel.cs index e0e2b068f7..0c4e2f8cc8 100644 --- a/src/Provider/Provider.Web/ViewModels/Part1/Training/ConfirmTrainingViewModel.cs +++ b/src/Provider/Provider.Web/ViewModels/Part1/Training/ConfirmTrainingViewModel.cs @@ -6,7 +6,7 @@ namespace Esfa.Recruit.Provider.Web.ViewModels.Part1.Training public class ConfirmTrainingViewModel { public string TrainingTitle { get; set; } - public ProgrammeLevel Level { get; set; } + public ApprenticeshipLevel Level { get; set; } public string EducationLevelName { get; set; } public int DurationMonths { get; set; } public string ProgrammeType {get; set; } diff --git a/src/Provider/Provider.Web/ViewModels/VacancyPreview/VacancyPreviewViewModel.cs b/src/Provider/Provider.Web/ViewModels/VacancyPreview/VacancyPreviewViewModel.cs index c6215295fd..6dcd728722 100644 --- a/src/Provider/Provider.Web/ViewModels/VacancyPreview/VacancyPreviewViewModel.cs +++ b/src/Provider/Provider.Web/ViewModels/VacancyPreview/VacancyPreviewViewModel.cs @@ -114,7 +114,7 @@ public class VacancyPreviewViewModel : DisplayVacancyViewModel public bool VacancyDescriptionRequiresEdit => IsEditRequired(FieldIdentifiers.VacancyDescription); public bool WageRequiresEdit => IsEditRequired(FieldIdentifiers.Wage); public bool WorkingWeekRequiresEdit => IsEditRequired(FieldIdentifiers.WorkingWeek); - public ProgrammeLevel Level { get; set; } + public ApprenticeshipLevel Level { get; set; } private bool IsEditRequired(string fieldIdentifier) { return Review.FieldIndicators.Any(f => f.ReviewFieldIdentifier == fieldIdentifier); diff --git a/src/QA/QA.Web/ViewModels/ReviewViewModel.cs b/src/QA/QA.Web/ViewModels/ReviewViewModel.cs index fca4bb1a5e..2360328e3b 100644 --- a/src/QA/QA.Web/ViewModels/ReviewViewModel.cs +++ b/src/QA/QA.Web/ViewModels/ReviewViewModel.cs @@ -121,6 +121,6 @@ private string GetFieldIdentifierCssClass(string fieldIdentifer) { return FieldIdentifiers.Single(f => f.FieldIdentifier == fieldIdentifer).FieldValueHasChanged ? CssFieldChanged : null; } - public ProgrammeLevel Level { get; set; } + public ApprenticeshipLevel Level { get; set; } } } \ No newline at end of file diff --git a/src/Shared/Recruit.Shared.Web/ViewModels/VacancySummaryViewModel.cs b/src/Shared/Recruit.Shared.Web/ViewModels/VacancySummaryViewModel.cs index 94153b7afa..b335e8e486 100644 --- a/src/Shared/Recruit.Shared.Web/ViewModels/VacancySummaryViewModel.cs +++ b/src/Shared/Recruit.Shared.Web/ViewModels/VacancySummaryViewModel.cs @@ -16,7 +16,7 @@ public class VacancySummaryViewModel public string ProgrammeId { get; set; } public string TrainingTitle { get; set; } public TrainingType TrainingType { get; set; } - public ProgrammeLevel TrainingLevel { get; set; } + public ApprenticeshipLevel TrainingLevel { get; set; } public bool IsTransferred { get; set; } public int NoOfNewApplications { get; set; } public int NoOfSuccessfulApplications { get; set; } diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ProgrammeLevel.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ApprenticeshipLevel.cs similarity index 54% rename from src/Shared/Recruit.Vacancies.Client/Domain/Entities/ProgrammeLevel.cs rename to src/Shared/Recruit.Vacancies.Client/Domain/Entities/ApprenticeshipLevel.cs index 1f8cab0514..d4565cd231 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ProgrammeLevel.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ApprenticeshipLevel.cs @@ -1,8 +1,6 @@ -using System; - -namespace Esfa.Recruit.Vacancies.Client.Domain.Entities +namespace Esfa.Recruit.Vacancies.Client.Domain.Entities { - public enum ProgrammeLevel + public enum ApprenticeshipLevel { Unknown = 0, Intermediate = 2, diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ApprenticeshipLevelHelper.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ApprenticeshipLevelHelper.cs new file mode 100644 index 0000000000..fb7d7c6d67 --- /dev/null +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ApprenticeshipLevelHelper.cs @@ -0,0 +1,38 @@ +using System; + +namespace Esfa.Recruit.Vacancies.Client.Domain.Entities +{ + public static class ApprenticeshipLevelHelper + { + //TODO: PeteM - TryRemapFromEducationLevel + public static bool TryRemapFromInt(int value, out ApprenticeshipLevel result) + { + switch (value) + { + case 5: // Foundation Degree + value = (int)ApprenticeshipLevel.Higher; + break; + + case 7: // Masters + value = (int)ApprenticeshipLevel.Degree; + break; + } + if (Enum.IsDefined(typeof(ApprenticeshipLevel), value)) + { + result = (ApprenticeshipLevel)value; + return true; + } + result = ApprenticeshipLevel.Unknown; + return false; + } + + //TODO: PeteM - RemapFromEducationLevel + public static ApprenticeshipLevel RemapFromInt(int value) + { + if (TryRemapFromInt(value, out ApprenticeshipLevel result)) + return result; + throw new ArgumentException($"Cannot convert from int {value} to {nameof(ApprenticeshipLevel)}"); + } + } + +} diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/IApprenticeshipProgramme.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/IApprenticeshipProgramme.cs index c585908f6d..d158aa5b24 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/IApprenticeshipProgramme.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/IApprenticeshipProgramme.cs @@ -9,7 +9,7 @@ public interface IApprenticeshipProgramme string Title { get; } DateTime? EffectiveFrom { get; } DateTime? EffectiveTo { get; } - ProgrammeLevel Level { get; } + ApprenticeshipLevel Level { get; } int Duration { get; } bool IsActive { get; set; } int? EducationLevelNumber { get; set; } diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ProgrammeLevelHelper.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ProgrammeLevelHelper.cs deleted file mode 100644 index 989cc5e2b2..0000000000 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/ProgrammeLevelHelper.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace Esfa.Recruit.Vacancies.Client.Domain.Entities -{ - public static class ProgrammeLevelHelper - { - public static bool TryRemapFromInt(int value, out ProgrammeLevel result) - { - switch (value) - { - case 5: // Foundation Degree - value = (int)ProgrammeLevel.Higher; - break; - - case 7: // Masters - value = (int)ProgrammeLevel.Degree; - break; - } - if (Enum.IsDefined(typeof(ProgrammeLevel), value)) - { - result = (ProgrammeLevel)value; - return true; - } - result = ProgrammeLevel.Unknown; - return false; - } - - public static ProgrammeLevel RemapFromInt(int value) - { - if (TryRemapFromInt(value, out ProgrammeLevel result)) - return result; - throw new ArgumentException($"Cannot convert from int {value} to {nameof(ProgrammeLevel)}"); - } - } - -} diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/VacancySummary/VacancySummary.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/VacancySummary/VacancySummary.cs index 7923d125e6..b6a3022a1a 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/VacancySummary/VacancySummary.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/VacancySummary/VacancySummary.cs @@ -25,7 +25,7 @@ public class VacancySummary public DateTime? StartDate { get; set; } public string TrainingTitle { get; set; } public TrainingType TrainingType { get; set; } - public ProgrammeLevel TrainingLevel { get; set; } + public ApprenticeshipLevel TrainingLevel { get; set; } public long? TransferInfoUkprn { get; set; } public string TransferInfoProviderName { get; set; } public TransferReason? TransferInfoReason { get; set; } diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/ReferenceData/ApprenticeshipProgrammes/ApprenticeshipApiCollectionExtensions.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/ReferenceData/ApprenticeshipProgrammes/ApprenticeshipApiCollectionExtensions.cs index 8ec56476f2..ec8070ab1f 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/ReferenceData/ApprenticeshipProgrammes/ApprenticeshipApiCollectionExtensions.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/ReferenceData/ApprenticeshipProgrammes/ApprenticeshipApiCollectionExtensions.cs @@ -21,7 +21,7 @@ public static IEnumerable FilterAndMapToApprenticeshipP IsActive = IsStandardActive(x), EffectiveFrom = x.EffectiveFrom, EffectiveTo = x.EffectiveTo, - Level = ProgrammeLevelHelper.RemapFromInt(x.Level), + Level = ApprenticeshipLevelHelper.RemapFromInt(x.Level), EducationLevelNumber = x.Level, Duration = x.Duration }); @@ -40,7 +40,7 @@ public static IEnumerable FilterAndMapToApprenticeshipP IsActive = IsFrameworkActive(x), EffectiveFrom = x.EffectiveFrom, EffectiveTo = x.EffectiveTo, - Level = ProgrammeLevelHelper.RemapFromInt(x.Level), + Level = ApprenticeshipLevelHelper.RemapFromInt(x.Level), EducationLevelNumber = x.Level, Duration = x.Duration }); diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/ReferenceData/ApprenticeshipProgrammes/ApprenticeshipProgramme.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/ReferenceData/ApprenticeshipProgrammes/ApprenticeshipProgramme.cs index 1cab529645..3f613692c5 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/ReferenceData/ApprenticeshipProgrammes/ApprenticeshipProgramme.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/ReferenceData/ApprenticeshipProgrammes/ApprenticeshipProgramme.cs @@ -15,7 +15,7 @@ public class ApprenticeshipProgramme : IApprenticeshipProgramme public DateTime? EffectiveTo { get; set; } - public ProgrammeLevel Level { get; set; } + public ApprenticeshipLevel Level { get; set; } public int Duration { get; set; } diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryResponseDto.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryResponseDto.cs index a01e011971..945db46d09 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryResponseDto.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryResponseDto.cs @@ -33,7 +33,7 @@ internal class VacancySummaryDetails public DurationUnit DurationUnit { get; set; } public string TrainingTitle { get; set; } public TrainingType TrainingType { get; set; } - public ProgrammeLevel TrainingLevel { get; set; } + public ApprenticeshipLevel TrainingLevel { get; set; } public long? TransferInfoUkprn { get; set; } public string TransferInfoProviderName { get; set; } public DateTime? TransferInfoTransferredDate { get; set; } diff --git a/src/Shared/UnitTests/Vacancies.Client/Application/VacancyValidation/CrossField/TestApprenticeshipProgramme.cs b/src/Shared/UnitTests/Vacancies.Client/Application/VacancyValidation/CrossField/TestApprenticeshipProgramme.cs index 6a49c26fa5..4a4ecb7ec0 100644 --- a/src/Shared/UnitTests/Vacancies.Client/Application/VacancyValidation/CrossField/TestApprenticeshipProgramme.cs +++ b/src/Shared/UnitTests/Vacancies.Client/Application/VacancyValidation/CrossField/TestApprenticeshipProgramme.cs @@ -15,7 +15,7 @@ public class TestApprenticeshipProgramme : IApprenticeshipProgramme public DateTime? EffectiveTo { get; set; } - public ProgrammeLevel Level { get; set; } + public ApprenticeshipLevel Level { get; set; } public int Duration { get; set; } diff --git a/src/Shared/UnitTests/Vacancies.Client/Domain/Entities/ApprenticeshipLevelHelperTests.cs b/src/Shared/UnitTests/Vacancies.Client/Domain/Entities/ApprenticeshipLevelHelperTests.cs new file mode 100644 index 0000000000..c667072580 --- /dev/null +++ b/src/Shared/UnitTests/Vacancies.Client/Domain/Entities/ApprenticeshipLevelHelperTests.cs @@ -0,0 +1,86 @@ +using System; +using System.Linq; +using Esfa.Recruit.Vacancies.Client.Domain.Entities; +using FluentAssertions; +using Xunit; + +namespace Esfa.Recruit.Vacancies.Client.UnitTests.Vacancies.Client.Domain.Entities +{ + public class ApprenticeshipLevelHelperTests + { + [Fact] + public void RemapFromInt_ShouldReturnHigher_WhenConvertingFromFoundation5() + { + ApprenticeshipLevel result = ApprenticeshipLevelHelper.RemapFromInt(5); + result.Should().Be(ApprenticeshipLevel.Higher); + } + + [Fact] + public void RemapFromInt_ShouldReturnDegree_WhenConvertingFromMasters7() + { + ApprenticeshipLevel result = ApprenticeshipLevelHelper.RemapFromInt(7); + result.Should().Be(ApprenticeshipLevel.Degree); + } + + [Fact] + public void RemapFromInt_ShouldReturnCorrectEnum_WhenPassedAnIntWithCorrespondingValue() + { + var enumValues = Enum.GetValues(typeof(ApprenticeshipLevel)) + .OfType(); + foreach (ApprenticeshipLevel enumValue in enumValues) + { + ApprenticeshipLevel result = ApprenticeshipLevelHelper.RemapFromInt((int)enumValue); + result.Should().Be(enumValue); + } + } + + [Fact] + public void RemapFromInt_ShouldThrowArgumentException_WhenPassedAnIntWithNoCorrespondingValue() + { + int intValueToConvert = (int)ApprenticeshipLevel.Degree + 2; + Assert.Throws(() => + { + ApprenticeshipLevelHelper.RemapFromInt(intValueToConvert); + }); + } + + [Fact] + public void TryRemapFromInt_ShouldSucceedAndReturnHigher_WhenConvertingFromFoundation5() + { + bool success = ApprenticeshipLevelHelper.TryRemapFromInt(5, out ApprenticeshipLevel result); + success.Should().Be(true); + result.Should().Be(ApprenticeshipLevel.Higher); + } + + [Fact] + public void TryRemapFromInt_ShouldSucceedAndReturnDegree_WhenConvertingFromMasters7() + { + bool success = ApprenticeshipLevelHelper.TryRemapFromInt(7, out ApprenticeshipLevel result); + success.Should().Be(true); + result.Should().Be(ApprenticeshipLevel.Degree); + } + + [Fact] + public void TryRemapFromInt_ShouldSucceedAndReturnEnum_WhenPassedAnIntWithCorrespondingValue() + { + var enumValues = Enum.GetValues(typeof(ApprenticeshipLevel)) + .OfType(); + foreach (ApprenticeshipLevel enumValue in enumValues) + { + bool success = ApprenticeshipLevelHelper.TryRemapFromInt((int)enumValue, out ApprenticeshipLevel result); + success.Should().Be(true); + result.Should().Be(enumValue); + } + } + + [Fact] + public void TryRemapFromInt_ShouldFail_WhenPassedAnIntWithNoCorrespondingValue() + { + int intValueToConvert = (int)ApprenticeshipLevel.Degree + 2; + bool success = ApprenticeshipLevelHelper.TryRemapFromInt(intValueToConvert, out ApprenticeshipLevel result); + success.Should().Be(false); + result.Should().Be(ApprenticeshipLevel.Unknown); + } + + } +} diff --git a/src/Shared/UnitTests/Vacancies.Client/Domain/Entities/ProgrammeLevelHelperTests.cs b/src/Shared/UnitTests/Vacancies.Client/Domain/Entities/ProgrammeLevelHelperTests.cs deleted file mode 100644 index c91b575ca1..0000000000 --- a/src/Shared/UnitTests/Vacancies.Client/Domain/Entities/ProgrammeLevelHelperTests.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Linq; -using Esfa.Recruit.Vacancies.Client.Domain.Entities; -using FluentAssertions; -using Xunit; - -namespace Esfa.Recruit.Vacancies.Client.UnitTests.Vacancies.Client.Domain.Entities -{ - public class ProgrammeLevelHelperTests - { - [Fact] - public void RemapFromInt_ShouldReturnHigher_WhenConvertingFromFoundation5() - { - ProgrammeLevel result = ProgrammeLevelHelper.RemapFromInt(5); - result.Should().Be(ProgrammeLevel.Higher); - } - - [Fact] - public void RemapFromInt_ShouldReturnDegree_WhenConvertingFromMasters7() - { - ProgrammeLevel result = ProgrammeLevelHelper.RemapFromInt(7); - result.Should().Be(ProgrammeLevel.Degree); - } - - [Fact] - public void RemapFromInt_ShouldReturnCorrectEnum_WhenPassedAnIntWithCorrespondingValue() - { - var enumValues = Enum.GetValues(typeof(ProgrammeLevel)) - .OfType(); - foreach (ProgrammeLevel enumValue in enumValues) - { - ProgrammeLevel result = ProgrammeLevelHelper.RemapFromInt((int)enumValue); - result.Should().Be(enumValue); - } - } - - [Fact] - public void RemapFromInt_ShouldThrowArgumentException_WhenPassedAnIntWithNoCorrespondingValue() - { - int intValueToConvert = (int)ProgrammeLevel.Degree + 2; - Assert.Throws(() => - { - ProgrammeLevelHelper.RemapFromInt(intValueToConvert); - }); - } - - [Fact] - public void TryRemapFromInt_ShouldSucceedAndReturnHigher_WhenConvertingFromFoundation5() - { - bool success = ProgrammeLevelHelper.TryRemapFromInt(5, out ProgrammeLevel result); - success.Should().Be(true); - result.Should().Be(ProgrammeLevel.Higher); - } - - [Fact] - public void TryRemapFromInt_ShouldSucceedAndReturnDegree_WhenConvertingFromMasters7() - { - bool success = ProgrammeLevelHelper.TryRemapFromInt(7, out ProgrammeLevel result); - success.Should().Be(true); - result.Should().Be(ProgrammeLevel.Degree); - } - - [Fact] - public void TryRemapFromInt_ShouldSucceedAndReturnEnum_WhenPassedAnIntWithCorrespondingValue() - { - var enumValues = Enum.GetValues(typeof(ProgrammeLevel)) - .OfType(); - foreach (ProgrammeLevel enumValue in enumValues) - { - bool success = ProgrammeLevelHelper.TryRemapFromInt((int)enumValue, out ProgrammeLevel result); - success.Should().Be(true); - result.Should().Be(enumValue); - } - } - - [Fact] - public void TryRemapFromInt_ShouldFail_WhenPassedAnIntWithNoCorrespondingValue() - { - int intValueToConvert = (int)ProgrammeLevel.Degree + 2; - bool success = ProgrammeLevelHelper.TryRemapFromInt(intValueToConvert, out ProgrammeLevel result); - success.Should().Be(false); - result.Should().Be(ProgrammeLevel.Unknown); - } - - } -} diff --git a/src/Shared/UnitTests/Vacancies.Client/Infrastructure/Extensions/VacancyExtensionsTests.cs b/src/Shared/UnitTests/Vacancies.Client/Infrastructure/Extensions/VacancyExtensionsTests.cs index d588adb8ab..b85aa5c96c 100644 --- a/src/Shared/UnitTests/Vacancies.Client/Infrastructure/Extensions/VacancyExtensionsTests.cs +++ b/src/Shared/UnitTests/Vacancies.Client/Infrastructure/Extensions/VacancyExtensionsTests.cs @@ -19,7 +19,7 @@ public class VacancyExtensionsTests private DateTime _now = DateTime.UtcNow; private ApprenticeshipProgramme _programme = new ApprenticeshipProgramme { - Level = ProgrammeLevel.Advanced, + Level = ApprenticeshipLevel.Advanced, ApprenticeshipType = TrainingType.Standard, EducationLevelNumber = 7 };