Skip to content

Commit

Permalink
chore: removed duplicate method
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWhittington committed Dec 3, 2024
1 parent 11eeb1b commit 915b319
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async Task<IActionResult> Index(string qualificationId)
private async Task QualificationLevel3OrAboveMightBeRelevantAtLevel2(QualificationDetailsModel model, Qualification qualification)
{
// Check if the qualification is not full and relevant and was started between Sept 2014 and Aug 2019 and is above a level 2 qualification
if (model.RatioRequirements.IsNotFullAndRelevant && userJourneyCookieService.WasStartedBetweenSept2014AndAug2019() && qualification.QualificationLevel > 2)
if (model.RatioRequirements.IsNotFullAndRelevant && userJourneyCookieService.WasStartedBetweenSeptember2014AndAugust2019() && qualification.QualificationLevel > 2)
{
await QualIsNotLevel2NotApprovedAndStartedBetweenSept2014AndAug2019(model, qualification);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ public interface IUserJourneyCookieService
Dictionary<string, string>? GetAdditionalQuestionsAnswers();
bool UserHasAnsweredAdditionalQuestions();
YesOrNo GetQualificationWasSelectedFromList();
bool WasStartedBetweenSept2014AndAug2019();
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,6 @@ public bool WasStartedOnOrAfterSeptember2014()
return date >= new DateOnly(2014, 9, 1);
}

public bool WasStartedBetweenSept2014AndAug2019()
{
var (startDateMonth, startDateYear) = GetWhenWasQualificationStarted();

if (startDateMonth is null || startDateYear is null)
{
throw new
InvalidOperationException("Unable to determine whether qualification was started on or after 09-2014");
}

var date = new DateOnly(startDateYear.Value, startDateMonth.Value, 1);
return date >= new DateOnly(2014, 9, 1) && date <= new DateOnly(2019, 8,31);
}

public int? GetLevelOfQualification()
{
lock (_lockObject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public async Task Index_BuildUpRatioRequirements_CantFindLevel6_LogsAndThrows()
await Assert.ThrowsExceptionAsync<NullReferenceException>(() => controller.Index(qualificationId));
mockLogger.VerifyError($"Could not find property: FullAndRelevantForLevel{level}After2014 within Level 6 Ratio Requirements for qualification: {qualificationId}");
}

[TestMethod]
[DataRow(9, 2014, 3)]
[DataRow(8, 2019, 3)]
Expand Down Expand Up @@ -664,8 +664,7 @@ public async Task Index_BuildUpRatioRequirements_NotRelevantButLevel3OrAboveStar
});

mockUserJourneyCookieService.Setup(x => x.GetWhenWasQualificationStarted()).Returns((startMonth, startYear));
mockUserJourneyCookieService.Setup(x => x.WasStartedBetweenSept2014AndAug2019())
.Returns(true);
mockUserJourneyCookieService.Setup(x => x.WasStartedBetweenSeptember2014AndAugust2019()).Returns(true);

var controller =
new QualificationDetailsController(mockLogger.Object,
Expand Down Expand Up @@ -717,7 +716,7 @@ public async Task
const int level = 6;
const int startMonth = 6;
const int startYear = 2016;

var additionalRequirementQuestions = new List<AdditionalRequirementQuestion>
{
new()
Expand All @@ -730,13 +729,13 @@ public async Task
AnswerToBeFullAndRelevant = true
}
};

//Answer here makes this qual not full and relevant
var listOfAdditionalReqsAnswered = new Dictionary<string, string>
{
{ "Have they got pediatric first aid?", "no" }
};

var ratioRequirements = new List<RatioRequirement>
{
new()
Expand Down Expand Up @@ -791,9 +790,8 @@ public async Task
});

mockUserJourneyCookieService.Setup(x => x.GetWhenWasQualificationStarted()).Returns((startMonth, startYear));
mockUserJourneyCookieService.Setup(x => x.WasStartedBetweenSept2014AndAug2019())
.Returns(true);

mockUserJourneyCookieService.Setup(x => x.WasStartedBetweenSeptember2014AndAugust2019()).Returns(true);

mockUserJourneyCookieService.Setup(x => x.GetAdditionalQuestionsAnswers())
.Returns(listOfAdditionalReqsAnswered);

Expand Down

0 comments on commit 915b319

Please sign in to comment.