Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FV2404 as EdifactFormatVersion Enum Member #117

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions EDILibrary/EdifactFormatVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ public enum EdifactFormatVersion
/// <summary>
/// Format Version October 2023 (aka MaKo2023)
/// </summary>
FV2310
FV2310,

/// <summary>
/// Format Version April 2024
/// </summary>
FV2404,
}

public class EdifactFormatVersionComparer : IComparer<EdifactFormatVersion>
Expand Down Expand Up @@ -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.")
};
}
Expand Down Expand Up @@ -347,9 +353,16 @@ public class EdifactFormatVersionHelper : IEdifactFormatVersionProvider
/// </summary>
private static readonly DateTime KeyDate2310 = new(2023, 09, 30, 22, 0, 0, DateTimeKind.Utc);


/// <summary>
/// validity date of <see cref="EdifactFormatVersion.FV2310"/>
/// </summary>
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;
Expand Down Expand Up @@ -544,4 +557,3 @@ public EdifactFormatVersion GetFormatVersion(EdifactFormat format, string versio
}
}
}

9 changes: 8 additions & 1 deletion EDILibraryTests/EdifactFormatVersionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)));
}
}
}
Loading