-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename ProgrammeLevel to ApprenticeshipLevel
- Loading branch information
Showing
18 changed files
with
140 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
....Client/Domain/Entities/ProgrammeLevel.cs → ...nt/Domain/Entities/ApprenticeshipLevel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/Shared/Recruit.Vacancies.Client/Domain/Entities/ApprenticeshipLevelHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)}"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
src/Shared/Recruit.Vacancies.Client/Domain/Entities/ProgrammeLevelHelper.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/Shared/UnitTests/Vacancies.Client/Domain/Entities/ApprenticeshipLevelHelperTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} | ||
} |
86 changes: 0 additions & 86 deletions
86
src/Shared/UnitTests/Vacancies.Client/Domain/Entities/ProgrammeLevelHelperTests.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters