From 0edb51090cbb3e911f23331f06af864d967497d4 Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Mon, 20 Nov 2023 16:42:54 +0000 Subject: [PATCH] Updated tests for educational performance --- .../TagHelpers/KeyStageDataTagHelperTests.cs | 16 ++++++++-------- .../Utils/KeyStageDataStatusHelper.cs | 6 ++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/TagHelpers/KeyStageDataTagHelperTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/TagHelpers/KeyStageDataTagHelperTests.cs index 640d2aa55..ff7cdbb38 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/TagHelpers/KeyStageDataTagHelperTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/TagHelpers/KeyStageDataTagHelperTests.cs @@ -15,10 +15,10 @@ public KeyStageDataTagHelperTests(IntegrationTestingWebApplicationFactory factor [Theory] [InlineData(0, StatusType.Provisional, "YearIndex 0 would be the current year, thus, status is provisional based on the currentDate variables month")] - [InlineData(1, StatusType.Final, "YearIndex 1 would be a year ago, thus, status is Final")] + [InlineData(1, StatusType.Provisional, "YearIndex 1 would be a year ago, thus, status is Final")] [InlineData(2, StatusType.Final, "YearIndex 2 would be two years ago, thus, status is Final")] [InlineData(3, StatusType.Final, "Edge case: If greater than our expected (Likely due to extending the number of years served in the future)")] - [InlineData(-1, StatusType.Final, "Edge case: Default to Final")] + [InlineData(-1, StatusType.Final, "Edge case: Default to Final")] public void KeyStageHeader_ReturnsExpectedStatusHeader(int yearIndex, StatusType expectedStatusType, string reason) { // Arrange @@ -94,17 +94,17 @@ public static IEnumerable ProvisionalDates() public static IEnumerable RevisedDates() { - yield return new object[] { new DateTime(DateTime.Now.Year, 1, 3) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 2, 11) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 3, 21) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 4, 14) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 1, 3) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 2, 11) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 3, 21) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 4, 14) }; } public static IEnumerable FinalDates() { yield return new object[] { new DateTime(DateTime.Now.Year - 2, 1, 3) }; yield return new object[] { new DateTime(DateTime.Now.Year - 2, 2, 11) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 5, 21) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 6, 14) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 5, 21) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 6, 14) }; } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs index 6a9df0e14..ae9f53b64 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs @@ -111,10 +111,8 @@ static DateTime ConvertToDateTime(string input) { return new DateTime(endYear, 8, 31); // Last day of Aug to mark end of academic year } - else - { - throw new ArgumentException("Invalid input format."); - } + // Default to current year if the year isn't in the expected value + return DateTime.UtcNow; } public static string KeyStageHeader(int yearIndex, KeyStages keyStage) {