From 95d8c70b3f8d8f1237484b9306f8ed67ddefc853 Mon Sep 17 00:00:00 2001 From: konstantin Date: Tue, 1 Aug 2023 11:42:18 +0200 Subject: [PATCH] Add `FV2404` as EdifactFormatVersion Enum Member --- EDILibrary/EdifactFormatVersion.cs | 18 +++++++++++++++--- EDILibraryTests/EdifactFormatVersionTests.cs | 9 ++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/EDILibrary/EdifactFormatVersion.cs b/EDILibrary/EdifactFormatVersion.cs index 5c5c7fa..20c4acc 100644 --- a/EDILibrary/EdifactFormatVersion.cs +++ b/EDILibrary/EdifactFormatVersion.cs @@ -187,7 +187,12 @@ public enum EdifactFormatVersion /// /// Format Version October 2023 (aka MaKo2023) /// - FV2310 + FV2310, + + /// + /// Format Version April 2024 + /// + FV2404, } public class EdifactFormatVersionComparer : IComparer @@ -223,6 +228,7 @@ public static string ToLegacyVersionString(this EdifactFormatVersion edifactForm EdifactFormatVersion.FV2210 => "10/22", EdifactFormatVersion.FV2304 => "04/23", EdifactFormatVersion.FV2310 => "10/23", + EdifactFormatVersion.FV2404 => "04/24", _ => throw new NotImplementedException($"The legacy format for {edifactFormatVersion} is not yet implemented.") }; } @@ -347,9 +353,16 @@ public class EdifactFormatVersionHelper : IEdifactFormatVersionProvider /// private static readonly DateTime KeyDate2310 = new(2023, 09, 30, 22, 0, 0, DateTimeKind.Utc); - + /// + /// validity date of + /// + private static readonly DateTime KeyDate2404 = new(2024, 03, 31, 22, 0, 0, DateTimeKind.Utc); public EdifactFormatVersion GetFormatVersion(DateTimeOffset keydate) { + if (keydate >= KeyDate2404) + { + return EdifactFormatVersion.FV2404; + } if (keydate >= KeyDate2310) { return EdifactFormatVersion.FV2310; @@ -544,4 +557,3 @@ public EdifactFormatVersion GetFormatVersion(EdifactFormat format, string versio } } } - diff --git a/EDILibraryTests/EdifactFormatVersionTests.cs b/EDILibraryTests/EdifactFormatVersionTests.cs index db46d96..c0cf467 100644 --- a/EDILibraryTests/EdifactFormatVersionTests.cs +++ b/EDILibraryTests/EdifactFormatVersionTests.cs @@ -55,7 +55,10 @@ public void TestFormatVersionOrder() EdifactFormatVersion.FV2004, EdifactFormatVersion.FV2104, EdifactFormatVersion.FV2110, - EdifactFormatVersion.FV2210 + EdifactFormatVersion.FV2210, + EdifactFormatVersion.FV2304, + EdifactFormatVersion.FV2310, + EdifactFormatVersion.FV2404, }; var comparer = new EdifactFormatVersionComparer(); for (int i = 0; i < expectedNaturalOrder.Count - 1; i++) @@ -93,6 +96,8 @@ public void UnmappedThrowsNotImplemented() [DataRow("FV1904", EdifactFormatVersion.FV1904)] [DataRow("10/17", EdifactFormatVersion.FV1710)] [DataRow("FV1710", EdifactFormatVersion.FV1710)] + [DataRow("FV2404", EdifactFormatVersion.FV2404)] + [DataRow("04/24", EdifactFormatVersion.FV2404)] public void TestLegacyStrings(string legacyString, EdifactFormatVersion expectedFormatVersion) { var actualFormatVersion = legacyString.ToEdifactFormatVersion(); @@ -140,6 +145,8 @@ public void TestFV2110() Assert.AreEqual(EdifactFormatVersion.FV2110, versionProvider.GetFormatVersion(new DateTimeOffset(2022, 3, 31, 22, 0, 0, TimeSpan.Zero))); Assert.AreEqual(EdifactFormatVersion.FV2110, versionProvider.GetFormatVersion(new DateTimeOffset(2022, 9, 30, 21, 59, 59, TimeSpan.Zero))); Assert.AreEqual(EdifactFormatVersion.FV2210, versionProvider.GetFormatVersion(new DateTimeOffset(2022, 9, 30, 22, 0, 0, TimeSpan.Zero))); + Assert.AreEqual(EdifactFormatVersion.FV2310, versionProvider.GetFormatVersion(new DateTimeOffset(2023, 9, 30, 22, 0, 0, TimeSpan.Zero))); + Assert.AreEqual(EdifactFormatVersion.FV2404, versionProvider.GetFormatVersion(new DateTimeOffset(2024, 3, 31, 22, 0, 0, TimeSpan.Zero))); } } }