diff --git a/SabreTools.Core/SabreTools.Core.csproj b/SabreTools.Core/SabreTools.Core.csproj index 83429f0d..0f080476 100644 --- a/SabreTools.Core/SabreTools.Core.csproj +++ b/SabreTools.Core/SabreTools.Core.csproj @@ -4,6 +4,10 @@ net6.0;net7.0 + + + + diff --git a/SabreTools.Core/Tools/Converters.cs b/SabreTools.Core/Tools/Converters.cs index 0ec1fdf4..9843f0b3 100644 --- a/SabreTools.Core/Tools/Converters.cs +++ b/SabreTools.Core/Tools/Converters.cs @@ -317,7 +317,7 @@ namespace SabreTools.Core.Tools /// String value to parse/param> /// Enum type that is expected /// Enum value representing the input, default on error - private static T AsEnumValue(string value) + internal static T AsEnumValue(string value) { // Get the mapping dictionary var mappings = GenerateToEnum(); @@ -334,13 +334,13 @@ namespace SabreTools.Core.Tools // Otherwise, return the default value for the enum return default; } - + /// /// Get a set of mappings from strings to enum values /// /// Enum type that is expected /// Dictionary of string to enum values - private static Dictionary GenerateToEnum() + internal static Dictionary GenerateToEnum() { try { @@ -565,7 +565,7 @@ namespace SabreTools.Core.Tools /// True to use the second mapping option, if it exists /// Enum type that is expected /// String value representing the input, default on error - private static string? AsStringValue(T value, bool useSecond = false) + internal static string? AsStringValue(T value, bool useSecond = false) { // Get the mapping dictionary var mappings = GenerateToString(useSecond); @@ -577,14 +577,14 @@ namespace SabreTools.Core.Tools // Otherwise, return null return null; } - + /// /// Get a set of mappings from enum values to string /// /// True to use the second mapping option, if it exists /// Enum type that is expected /// Dictionary of enum to string values - private static Dictionary GenerateToString(bool useSecond) + internal static Dictionary GenerateToString(bool useSecond) { try { diff --git a/SabreTools.Test/Core/ConvertersTests.cs b/SabreTools.Test/Core/ConvertersTests.cs index 2f8dd620..8d994c23 100644 --- a/SabreTools.Test/Core/ConvertersTests.cs +++ b/SabreTools.Test/Core/ConvertersTests.cs @@ -857,5 +857,41 @@ namespace SabreTools.Test.Core } #endregion + + #region Generators + + [Theory] + [InlineData(ChipType.NULL, 2)] + [InlineData(ControlType.NULL, 15)] + [InlineData(DatHeaderField.NULL, 94)] + [InlineData(DatItemField.NULL, 197)] + [InlineData(DeviceType.NULL, 21)] + [InlineData(DisplayType.NULL, 5)] + [InlineData(Endianness.NULL, 2)] + [InlineData(FeatureStatus.NULL, 2)] + [InlineData(FeatureType.NULL, 14)] + [InlineData(ItemStatus.NULL, 7)] + [InlineData(ItemType.NULL, 51)] + [InlineData(LoadFlag.NULL, 14)] + [InlineData(LogLevel.VERBOSE, 4)] + [InlineData(MachineField.NULL, 68)] + [InlineData(MachineType.None, 6)] + [InlineData(MergingFlag.None, 12)] + [InlineData(NodumpFlag.None, 4)] + [InlineData(OpenMSXSubType.NULL, 3)] + [InlineData(PackingFlag.None, 7)] + [InlineData(Relation.NULL, 6)] + [InlineData(Runnable.NULL, 3)] + [InlineData(SoftwareListStatus.None, 3)] + [InlineData(Supported.NULL, 5)] + [InlineData(SupportStatus.NULL, 3)] + public void GenerateToEnumTest(T value, int expected) + { + var actual = Converters.GenerateToEnum(); + Assert.Equal(default, value); + Assert.Equal(expected, actual.Keys.Count); + } + + #endregion } } \ No newline at end of file