Skip to content

Commit

Permalink
Rename ProgrammeLevel to ApprenticeshipLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpmorris committed Sep 6, 2019
1 parent 4f73742 commit b1f869b
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> OrderedFieldNames => new List<string>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/QA/QA.Web/ViewModels/ReviewViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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)}");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static IEnumerable<ApprenticeshipProgramme> 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
});
Expand All @@ -40,7 +40,7 @@ public static IEnumerable<ApprenticeshipProgramme> 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
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
Original file line number Diff line number Diff line change
@@ -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<ApprenticeshipLevel>();
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<ArgumentException>(() =>
{
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<ApprenticeshipLevel>();
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);
}

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down

0 comments on commit b1f869b

Please sign in to comment.