diff --git a/SabreTools.Core.Test/Filter/FieldManipulatorTests.cs b/SabreTools.Core.Test/Filter/FieldManipulatorTests.cs
deleted file mode 100644
index e7351bbd..00000000
--- a/SabreTools.Core.Test/Filter/FieldManipulatorTests.cs
+++ /dev/null
@@ -1,192 +0,0 @@
-using SabreTools.Core.Filter;
-using SabreTools.Models.Metadata;
-using Xunit;
-
-namespace SabreTools.Core.Test.Filter
-{
- public class FieldManipulatorTests
- {
- #region RemoveField
-
- [Fact]
- public void RemoveField_NullItem_False()
- {
- DictionaryBase? dictionaryBase = null;
- string? fieldName = Sample.NameKey;
- bool actual = FieldManipulator.RemoveField(dictionaryBase, fieldName);
- Assert.False(actual);
- }
-
- [Fact]
- public void RemoveField_NullFieldName_False()
- {
- DictionaryBase? dictionaryBase = new Sample();
- string? fieldName = null;
- bool actual = FieldManipulator.RemoveField(dictionaryBase, fieldName);
- Assert.False(actual);
- }
-
- [Fact]
- public void RemoveField_EmptyFieldName_False()
- {
- DictionaryBase? dictionaryBase = new Sample();
- string? fieldName = string.Empty;
- bool actual = FieldManipulator.RemoveField(dictionaryBase, fieldName);
- Assert.False(actual);
- }
-
- [Fact]
- public void RemoveField_MissingKey_True()
- {
- DictionaryBase? dictionaryBase = new Sample();
- string? fieldName = Sample.NameKey;
- bool actual = FieldManipulator.RemoveField(dictionaryBase, fieldName);
- Assert.True(actual);
- Assert.DoesNotContain(fieldName, dictionaryBase.Keys);
- }
-
- [Fact]
- public void RemoveField_ValidKey_True()
- {
- DictionaryBase? dictionaryBase = new Sample { [Sample.NameKey] = "value" };
- string? fieldName = Sample.NameKey;
- bool actual = FieldManipulator.RemoveField(dictionaryBase, fieldName);
- Assert.True(actual);
- Assert.DoesNotContain(fieldName, dictionaryBase.Keys);
- }
-
- #endregion
-
- #region ReplaceField
-
- [Fact]
- public void ReplaceField_NullFrom_False()
- {
- DictionaryBase? from = null;
- DictionaryBase? to = new Sample();
- string? fieldName = Sample.NameKey;
- bool actual = FieldManipulator.ReplaceField(from, to, fieldName);
- Assert.False(actual);
- }
-
- [Fact]
- public void ReplaceField_NullTo_False()
- {
- DictionaryBase? from = null;
- DictionaryBase? to = new Sample();
- string? fieldName = Sample.NameKey;
- bool actual = FieldManipulator.ReplaceField(from, to, fieldName);
- Assert.False(actual);
- }
-
- [Fact]
- public void ReplaceField_NullFieldName_False()
- {
- DictionaryBase? from = new Sample();
- DictionaryBase? to = new Sample();
- string? fieldName = null;
- bool actual = FieldManipulator.ReplaceField(from, to, fieldName);
- Assert.False(actual);
- }
-
- [Fact]
- public void ReplaceField_EmptyFieldName_False()
- {
- DictionaryBase? from = new Sample();
- DictionaryBase? to = new Sample();
- string? fieldName = string.Empty;
- bool actual = FieldManipulator.ReplaceField(from, to, fieldName);
- Assert.False(actual);
- }
-
- [Fact]
- public void ReplaceField_MismatchedTypes_False()
- {
- DictionaryBase? from = new Sample();
- DictionaryBase? to = new Rom();
- string? fieldName = Sample.NameKey;
- bool actual = FieldManipulator.ReplaceField(from, to, fieldName);
- Assert.False(actual);
- }
-
- [Fact]
- public void ReplaceField_MissingKey_False()
- {
- DictionaryBase? from = new Sample();
- DictionaryBase? to = new Sample();
- string? fieldName = Sample.NameKey;
- bool actual = FieldManipulator.ReplaceField(from, to, fieldName);
- Assert.False(actual);
- }
-
- [Fact]
- public void ReplaceField_ValidKey_True()
- {
- DictionaryBase? from = new Sample { [Sample.NameKey] = "value" };
- DictionaryBase? to = new Sample();
- string? fieldName = Sample.NameKey;
- bool actual = FieldManipulator.ReplaceField(from, to, fieldName);
- Assert.True(actual);
- Assert.Contains(fieldName, to.Keys);
- Assert.Equal("value", to[Sample.NameKey]);
- }
-
- #endregion
-
- #region SetField
-
- [Fact]
- public void SetField_NullItem_False()
- {
- DictionaryBase? dictionaryBase = null;
- string? fieldName = Sample.NameKey;
- object value = "value";
- bool actual = FieldManipulator.SetField(dictionaryBase, fieldName, value);
- Assert.False(actual);
- }
-
- [Fact]
- public void SetField_NullFieldName_False()
- {
- DictionaryBase? dictionaryBase = new Sample();
- string? fieldName = null;
- object value = "value";
- bool actual = FieldManipulator.SetField(dictionaryBase, fieldName, value);
- Assert.False(actual);
- }
-
- [Fact]
- public void SetField_EmptyFieldName_False()
- {
- DictionaryBase? dictionaryBase = new Sample();
- string? fieldName = string.Empty;
- object value = "value";
- bool actual = FieldManipulator.SetField(dictionaryBase, fieldName, value);
- Assert.False(actual);
- }
-
- [Fact]
- public void SetField_MissingKey_False()
- {
- DictionaryBase? dictionaryBase = new Sample();
- string? fieldName = Rom.SHA1Key;
- object value = "value";
- bool actual = FieldManipulator.SetField(dictionaryBase, fieldName, value);
- Assert.False(actual);
- }
-
- [Fact]
- public void SetField_ValidKey_True()
- {
- DictionaryBase? dictionaryBase = new Sample { [Sample.NameKey] = "old" };
- string? fieldName = Sample.NameKey;
- object value = "value";
- bool actual = FieldManipulator.SetField(dictionaryBase, fieldName, value);
- Assert.True(actual);
- Assert.Contains(fieldName, dictionaryBase.Keys);
- Assert.Equal(value, dictionaryBase[fieldName]);
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/SabreTools.Core.Test/ModelBackedItemTests.cs b/SabreTools.Core.Test/ModelBackedItemTests.cs
new file mode 100644
index 00000000..6f5317dc
--- /dev/null
+++ b/SabreTools.Core.Test/ModelBackedItemTests.cs
@@ -0,0 +1,211 @@
+using SabreTools.Models.Metadata;
+using Xunit;
+
+namespace SabreTools.Core.Test
+{
+ public class ModelBackedItemTests
+ {
+ #region Private Testing Classes
+
+ ///
+ /// Testing implementation of DictionaryBase
+ ///
+ private class TestDictionaryBase : DictionaryBase
+ {
+ public const string NameKey = "__NAME__";
+ }
+
+ ///
+ /// Testing implementation of ModelBackedItem
+ ///
+ private class TestModelBackedItem : ModelBackedItem { }
+
+ #endregion
+
+ #region RemoveField
+
+ [Fact]
+ public void RemoveField_NullItem_False()
+ {
+ TestModelBackedItem? modelBackedItem = null;
+ string? fieldName = TestDictionaryBase.NameKey;
+ bool? actual = modelBackedItem?.RemoveField(fieldName);
+ Assert.Null(actual);
+ }
+
+ [Fact]
+ public void RemoveField_NullFieldName_False()
+ {
+ var modelBackedItem = new TestModelBackedItem();
+ string? fieldName = null;
+ bool? actual = modelBackedItem.RemoveField(fieldName);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void RemoveField_EmptyFieldName_False()
+ {
+ var modelBackedItem = new TestModelBackedItem();
+ string? fieldName = string.Empty;
+ bool actual = modelBackedItem.RemoveField(fieldName);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void RemoveField_MissingKey_True()
+ {
+ var modelBackedItem = new TestModelBackedItem();
+ string? fieldName = TestDictionaryBase.NameKey;
+ bool actual = modelBackedItem.RemoveField(fieldName);
+ Assert.True(actual);
+ Assert.Null(modelBackedItem.GetStringFieldValue(fieldName));
+ }
+
+ [Fact]
+ public void RemoveField_ValidKey_True()
+ {
+ var modelBackedItem = new TestModelBackedItem();
+ modelBackedItem.SetFieldValue(TestDictionaryBase.NameKey, "value");
+ string? fieldName = TestDictionaryBase.NameKey;
+ bool actual = modelBackedItem.RemoveField(fieldName);
+ Assert.True(actual);
+ Assert.Null(modelBackedItem.GetStringFieldValue(fieldName));
+ }
+
+ #endregion
+
+ #region ReplaceField
+
+ [Fact]
+ public void ReplaceField_NullFrom_False()
+ {
+ TestModelBackedItem? from = null;
+ var to = new TestModelBackedItem();
+ string? fieldName = TestDictionaryBase.NameKey;
+ bool actual = to.ReplaceField(from, fieldName);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void ReplaceField_NullTo_False()
+ {
+ TestModelBackedItem? from = null;
+ TestModelBackedItem? to = new TestModelBackedItem();
+ string? fieldName = TestDictionaryBase.NameKey;
+ bool actual = to.ReplaceField(from, fieldName);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void ReplaceField_NullFieldName_False()
+ {
+ TestModelBackedItem? from = new TestModelBackedItem();
+ TestModelBackedItem? to = new TestModelBackedItem();
+ string? fieldName = null;
+ bool actual = to.ReplaceField(from, fieldName);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void ReplaceField_EmptyFieldName_False()
+ {
+ TestModelBackedItem? from = new TestModelBackedItem();
+ TestModelBackedItem? to = new TestModelBackedItem();
+ string? fieldName = string.Empty;
+ bool actual = to.ReplaceField(from, fieldName);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void ReplaceField_MissingKey_False()
+ {
+ TestModelBackedItem? from = new TestModelBackedItem();
+ TestModelBackedItem? to = new TestModelBackedItem();
+ string? fieldName = TestDictionaryBase.NameKey;
+ bool actual = to.ReplaceField(from, fieldName);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void ReplaceField_ValidKey_True()
+ {
+ TestModelBackedItem? from = new TestModelBackedItem();
+ from.SetFieldValue(TestDictionaryBase.NameKey, "value");
+ TestModelBackedItem? to = new TestModelBackedItem();
+ string? fieldName = TestDictionaryBase.NameKey;
+ bool actual = to.ReplaceField(from, fieldName);
+ Assert.True(actual);
+ Assert.Equal("value", to.GetStringFieldValue(TestDictionaryBase.NameKey));
+ }
+
+ #endregion
+
+ #region SetField
+
+ [Fact]
+ public void SetField_NullItem_False()
+ {
+ TestModelBackedItem? modelBackedItem = null;
+ string? fieldName = TestDictionaryBase.NameKey;
+ object value = "value";
+ bool? actual = modelBackedItem?.SetField(fieldName, value);
+ Assert.Null(actual);
+ }
+
+ [Fact]
+ public void SetField_NullFieldName_False()
+ {
+ TestModelBackedItem? modelBackedItem = new TestModelBackedItem();
+ string? fieldName = null;
+ object value = "value";
+ bool actual = modelBackedItem.SetField(fieldName, value);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void SetField_EmptyFieldName_False()
+ {
+ TestModelBackedItem? modelBackedItem = new TestModelBackedItem();
+ string? fieldName = string.Empty;
+ object value = "value";
+ bool actual = modelBackedItem.SetField(fieldName, value);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void SetField_MissingKey_False()
+ {
+ TestModelBackedItem? modelBackedItem = new TestModelBackedItem();
+ string? fieldName = Rom.SHA1Key;
+ object value = "value";
+ bool actual = modelBackedItem.SetField(fieldName, value);
+ Assert.False(actual);
+ }
+
+ [Fact]
+ public void SetField_InvalidKey_True()
+ {
+ TestModelBackedItem? modelBackedItem = new TestModelBackedItem();
+ modelBackedItem.SetFieldValue(TestDictionaryBase.NameKey, "old");
+ string? fieldName = "INVALID";
+ object value = "value";
+ bool actual = modelBackedItem.SetField(fieldName, value);
+ Assert.False(actual);
+ Assert.Null(modelBackedItem.GetStringFieldValue(fieldName));
+ }
+
+ [Fact]
+ public void SetField_ValidKey_True()
+ {
+ TestModelBackedItem? modelBackedItem = new TestModelBackedItem();
+ modelBackedItem.SetFieldValue(TestDictionaryBase.NameKey, "old");
+ string? fieldName = TestDictionaryBase.NameKey;
+ object value = "value";
+ bool actual = modelBackedItem.SetField(fieldName, value);
+ Assert.True(actual);
+ Assert.Equal(value, modelBackedItem.GetStringFieldValue(fieldName));
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/SabreTools.Core.Test/SabreTools.Core.Test.csproj b/SabreTools.Core.Test/SabreTools.Core.Test.csproj
index 9218aca3..329b48cc 100644
--- a/SabreTools.Core.Test/SabreTools.Core.Test.csproj
+++ b/SabreTools.Core.Test/SabreTools.Core.Test.csproj
@@ -10,7 +10,6 @@
-
diff --git a/SabreTools.Core.Test/Tools/ConvertersTests.cs b/SabreTools.Core.Test/Tools/ConvertersTests.cs
index 97006bc2..c53db42b 100644
--- a/SabreTools.Core.Test/Tools/ConvertersTests.cs
+++ b/SabreTools.Core.Test/Tools/ConvertersTests.cs
@@ -1,6 +1,5 @@
using SabreTools.Core.Tools;
using SabreTools.DatFiles;
-using SabreTools.DatItems;
using Xunit;
namespace SabreTools.Core.Test.Tools
@@ -10,235 +9,6 @@ namespace SabreTools.Core.Test.Tools
{
#region String to Enum
- [Theory]
- [InlineData(null, ChipType.NULL)]
- [InlineData("cpu", ChipType.CPU)]
- [InlineData("audio", ChipType.Audio)]
- public void AsChipTypeTest(string? field, ChipType expected)
- {
- ChipType actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, ControlType.NULL)]
- [InlineData("joy", ControlType.Joy)]
- [InlineData("stick", ControlType.Stick)]
- [InlineData("paddle", ControlType.Paddle)]
- [InlineData("pedal", ControlType.Pedal)]
- [InlineData("lightgun", ControlType.Lightgun)]
- [InlineData("positional", ControlType.Positional)]
- [InlineData("dial", ControlType.Dial)]
- [InlineData("trackball", ControlType.Trackball)]
- [InlineData("mouse", ControlType.Mouse)]
- [InlineData("only_buttons", ControlType.OnlyButtons)]
- [InlineData("keypad", ControlType.Keypad)]
- [InlineData("keyboard", ControlType.Keyboard)]
- [InlineData("mahjong", ControlType.Mahjong)]
- [InlineData("hanafuda", ControlType.Hanafuda)]
- [InlineData("gambling", ControlType.Gambling)]
- public void AsControlTypeTest(string? field, ControlType expected)
- {
- ControlType actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, DeviceType.NULL)]
- [InlineData("unknown", DeviceType.Unknown)]
- [InlineData("cartridge", DeviceType.Cartridge)]
- [InlineData("floppydisk", DeviceType.FloppyDisk)]
- [InlineData("harddisk", DeviceType.HardDisk)]
- [InlineData("cylinder", DeviceType.Cylinder)]
- [InlineData("cassette", DeviceType.Cassette)]
- [InlineData("punchcard", DeviceType.PunchCard)]
- [InlineData("punchtape", DeviceType.PunchTape)]
- [InlineData("printout", DeviceType.Printout)]
- [InlineData("serial", DeviceType.Serial)]
- [InlineData("parallel", DeviceType.Parallel)]
- [InlineData("snapshot", DeviceType.Snapshot)]
- [InlineData("quickload", DeviceType.QuickLoad)]
- [InlineData("memcard", DeviceType.MemCard)]
- [InlineData("cdrom", DeviceType.CDROM)]
- [InlineData("magtape", DeviceType.MagTape)]
- [InlineData("romimage", DeviceType.ROMImage)]
- [InlineData("midiin", DeviceType.MIDIIn)]
- [InlineData("midiout", DeviceType.MIDIOut)]
- [InlineData("picture", DeviceType.Picture)]
- [InlineData("vidfile", DeviceType.VidFile)]
- public void AsDeviceTypeTest(string? field, DeviceType expected)
- {
- DeviceType actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, DisplayType.NULL)]
- [InlineData("raster", DisplayType.Raster)]
- [InlineData("vector", DisplayType.Vector)]
- [InlineData("lcd", DisplayType.LCD)]
- [InlineData("svg", DisplayType.SVG)]
- [InlineData("unknown", DisplayType.Unknown)]
- public void AsDisplayTypeTest(string? field, DisplayType expected)
- {
- DisplayType actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, Endianness.NULL)]
- [InlineData("big", Endianness.Big)]
- [InlineData("little", Endianness.Little)]
- public void AsEndiannessTest(string? field, Endianness expected)
- {
- Endianness actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, FeatureStatus.NULL)]
- [InlineData("unemulated", FeatureStatus.Unemulated)]
- [InlineData("imperfect", FeatureStatus.Imperfect)]
- public void AsFeatureStatusTest(string? field, FeatureStatus expected)
- {
- FeatureStatus actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, FeatureType.NULL)]
- [InlineData("protection", FeatureType.Protection)]
- [InlineData("palette", FeatureType.Palette)]
- [InlineData("graphics", FeatureType.Graphics)]
- [InlineData("sound", FeatureType.Sound)]
- [InlineData("controls", FeatureType.Controls)]
- [InlineData("keyboard", FeatureType.Keyboard)]
- [InlineData("mouse", FeatureType.Mouse)]
- [InlineData("microphone", FeatureType.Microphone)]
- [InlineData("camera", FeatureType.Camera)]
- [InlineData("disk", FeatureType.Disk)]
- [InlineData("printer", FeatureType.Printer)]
- [InlineData("lan", FeatureType.Lan)]
- [InlineData("wan", FeatureType.Wan)]
- [InlineData("timing", FeatureType.Timing)]
- public void AsFeatureTypeTest(string? field, FeatureType expected)
- {
- FeatureType actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, ItemStatus.NULL)]
- [InlineData("none", ItemStatus.None)]
- [InlineData("no", ItemStatus.None)]
- [InlineData("good", ItemStatus.Good)]
- [InlineData("baddump", ItemStatus.BadDump)]
- [InlineData("nodump", ItemStatus.Nodump)]
- [InlineData("yes", ItemStatus.Nodump)]
- [InlineData("verified", ItemStatus.Verified)]
- public void AsItemStatusTest(string? field, ItemStatus expected)
- {
- ItemStatus actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, ItemType.NULL)]
- [InlineData("adjuster", ItemType.Adjuster)]
- [InlineData("analog", ItemType.Analog)]
- [InlineData("archive", ItemType.Archive)]
- [InlineData("biosset", ItemType.BiosSet)]
- [InlineData("blank", ItemType.Blank)]
- [InlineData("chip", ItemType.Chip)]
- [InlineData("condition", ItemType.Condition)]
- [InlineData("configuration", ItemType.Configuration)]
- [InlineData("conflocation", ItemType.ConfLocation)]
- [InlineData("confsetting", ItemType.ConfSetting)]
- [InlineData("control", ItemType.Control)]
- [InlineData("dataarea", ItemType.DataArea)]
- [InlineData("device", ItemType.Device)]
- [InlineData("deviceref", ItemType.DeviceRef)]
- [InlineData("device_ref", ItemType.DeviceRef)]
- [InlineData("diplocation", ItemType.DipLocation)]
- [InlineData("dipswitch", ItemType.DipSwitch)]
- [InlineData("dipvalue", ItemType.DipValue)]
- [InlineData("disk", ItemType.Disk)]
- [InlineData("diskarea", ItemType.DiskArea)]
- [InlineData("display", ItemType.Display)]
- [InlineData("driver", ItemType.Driver)]
- [InlineData("extension", ItemType.Extension)]
- [InlineData("feature", ItemType.Feature)]
- [InlineData("file", ItemType.File)]
- [InlineData("info", ItemType.Info)]
- [InlineData("input", ItemType.Input)]
- [InlineData("instance", ItemType.Instance)]
- [InlineData("media", ItemType.Media)]
- [InlineData("part", ItemType.Part)]
- [InlineData("partfeature", ItemType.PartFeature)]
- [InlineData("part_feature", ItemType.PartFeature)]
- [InlineData("port", ItemType.Port)]
- [InlineData("ramoption", ItemType.RamOption)]
- [InlineData("ram_option", ItemType.RamOption)]
- [InlineData("release", ItemType.Release)]
- [InlineData("releasedetails", ItemType.ReleaseDetails)]
- [InlineData("release_details", ItemType.ReleaseDetails)]
- [InlineData("rom", ItemType.Rom)]
- [InlineData("sample", ItemType.Sample)]
- [InlineData("serials", ItemType.Serials)]
- [InlineData("sharedfeat", ItemType.SharedFeat)]
- [InlineData("shared_feat", ItemType.SharedFeat)]
- [InlineData("sharedfeature", ItemType.SharedFeat)]
- [InlineData("shared_feature", ItemType.SharedFeat)]
- [InlineData("slot", ItemType.Slot)]
- [InlineData("slotoption", ItemType.SlotOption)]
- [InlineData("slot_option", ItemType.SlotOption)]
- [InlineData("softwarelist", ItemType.SoftwareList)]
- [InlineData("software_list", ItemType.SoftwareList)]
- [InlineData("sound", ItemType.Sound)]
- [InlineData("sourcedetails", ItemType.SourceDetails)]
- [InlineData("source_details", ItemType.SourceDetails)]
- public void AsItemTypeTest(string? field, ItemType expected)
- {
- ItemType actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, LoadFlag.NULL)]
- [InlineData("load16_byte", LoadFlag.Load16Byte)]
- [InlineData("load16_word", LoadFlag.Load16Word)]
- [InlineData("load16_word_swap", LoadFlag.Load16WordSwap)]
- [InlineData("load32_byte", LoadFlag.Load32Byte)]
- [InlineData("load32_word", LoadFlag.Load32Word)]
- [InlineData("load32_word_swap", LoadFlag.Load32WordSwap)]
- [InlineData("load32_dword", LoadFlag.Load32DWord)]
- [InlineData("load64_word", LoadFlag.Load64Word)]
- [InlineData("load64_word_swap", LoadFlag.Load64WordSwap)]
- [InlineData("reload", LoadFlag.Reload)]
- [InlineData("fill", LoadFlag.Fill)]
- [InlineData("continue", LoadFlag.Continue)]
- [InlineData("reload_plain", LoadFlag.ReloadPlain)]
- [InlineData("ignore", LoadFlag.Ignore)]
- public void AsLoadFlagTest(string? field, LoadFlag expected)
- {
- LoadFlag actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, MachineType.None)]
- [InlineData("none", MachineType.None)]
- [InlineData("bios", MachineType.Bios)]
- [InlineData("dev", MachineType.Device)]
- [InlineData("device", MachineType.Device)]
- [InlineData("mech", MachineType.Mechanical)]
- [InlineData("mechanical", MachineType.Mechanical)]
- public void AsMachineTypeTest(string? field, MachineType expected)
- {
- MachineType actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
[Theory]
[InlineData(null, MergingFlag.None)]
[InlineData("none", MergingFlag.None)]
@@ -271,17 +41,6 @@ namespace SabreTools.Core.Test.Tools
Assert.Equal(expected, actual);
}
- [Theory]
- [InlineData(null, OpenMSXSubType.NULL)]
- [InlineData("rom", OpenMSXSubType.Rom)]
- [InlineData("megarom", OpenMSXSubType.MegaRom)]
- [InlineData("sccpluscart", OpenMSXSubType.SCCPlusCart)]
- public void AsOpenMSXSubTypeTest(string? field, OpenMSXSubType expected)
- {
- OpenMSXSubType actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
[Theory]
[InlineData(null, PackingFlag.None)]
[InlineData("none", PackingFlag.None)]
@@ -298,66 +57,6 @@ namespace SabreTools.Core.Test.Tools
Assert.Equal(expected, actual);
}
- [Theory]
- [InlineData(null, Relation.NULL)]
- [InlineData("eq", Relation.Equal)]
- [InlineData("ne", Relation.NotEqual)]
- [InlineData("gt", Relation.GreaterThan)]
- [InlineData("le", Relation.LessThanOrEqual)]
- [InlineData("lt", Relation.LessThan)]
- [InlineData("ge", Relation.GreaterThanOrEqual)]
- public void AsRelationTest(string? field, Relation expected)
- {
- Relation actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, Runnable.NULL)]
- [InlineData("no", Runnable.No)]
- [InlineData("partial", Runnable.Partial)]
- [InlineData("yes", Runnable.Yes)]
- public void AsRunnableTest(string? field, Runnable expected)
- {
- Runnable actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, SoftwareListStatus.None)]
- [InlineData("none", SoftwareListStatus.None)]
- [InlineData("original", SoftwareListStatus.Original)]
- [InlineData("compatible", SoftwareListStatus.Compatible)]
- public void AsSoftwareListStatusTest(string? field, SoftwareListStatus expected)
- {
- SoftwareListStatus actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, Supported.NULL)]
- [InlineData("no", Supported.No)]
- [InlineData("unsupported", Supported.No)]
- [InlineData("partial", Supported.Partial)]
- [InlineData("yes", Supported.Yes)]
- [InlineData("supported", Supported.Yes)]
- public void AsSupportedTest(string? field, Supported expected)
- {
- Supported actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(null, SupportStatus.NULL)]
- [InlineData("good", SupportStatus.Good)]
- [InlineData("imperfect", SupportStatus.Imperfect)]
- [InlineData("preliminary", SupportStatus.Preliminary)]
- public void AsSupportStatusTest(string? field, SupportStatus expected)
- {
- SupportStatus actual = field.AsEnumValue();
- Assert.Equal(expected, actual);
- }
-
[Theory]
[InlineData(null, null)]
[InlineData("INVALID", null)]
@@ -375,230 +74,6 @@ namespace SabreTools.Core.Test.Tools
#region Enum to String
- [Theory]
- [InlineData(ChipType.NULL, null)]
- [InlineData(ChipType.CPU, "cpu")]
- [InlineData(ChipType.Audio, "audio")]
- public void FromChipTypeTest(ChipType field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(ControlType.NULL, null)]
- [InlineData(ControlType.Joy, "joy")]
- [InlineData(ControlType.Stick, "stick")]
- [InlineData(ControlType.Paddle, "paddle")]
- [InlineData(ControlType.Pedal, "pedal")]
- [InlineData(ControlType.Lightgun, "lightgun")]
- [InlineData(ControlType.Positional, "positional")]
- [InlineData(ControlType.Dial, "dial")]
- [InlineData(ControlType.Trackball, "trackball")]
- [InlineData(ControlType.Mouse, "mouse")]
- [InlineData(ControlType.OnlyButtons, "only_buttons")]
- [InlineData(ControlType.Keypad, "keypad")]
- [InlineData(ControlType.Keyboard, "keyboard")]
- [InlineData(ControlType.Mahjong, "mahjong")]
- [InlineData(ControlType.Hanafuda, "hanafuda")]
- [InlineData(ControlType.Gambling, "gambling")]
- public void FromControlTypeTest(ControlType field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(DeviceType.NULL, null)]
- [InlineData(DeviceType.Unknown, "unknown")]
- [InlineData(DeviceType.Cartridge, "cartridge")]
- [InlineData(DeviceType.FloppyDisk, "floppydisk")]
- [InlineData(DeviceType.HardDisk, "harddisk")]
- [InlineData(DeviceType.Cylinder, "cylinder")]
- [InlineData(DeviceType.Cassette, "cassette")]
- [InlineData(DeviceType.PunchCard, "punchcard")]
- [InlineData(DeviceType.PunchTape, "punchtape")]
- [InlineData(DeviceType.Printout, "printout")]
- [InlineData(DeviceType.Serial, "serial")]
- [InlineData(DeviceType.Parallel, "parallel")]
- [InlineData(DeviceType.Snapshot, "snapshot")]
- [InlineData(DeviceType.QuickLoad, "quickload")]
- [InlineData(DeviceType.MemCard, "memcard")]
- [InlineData(DeviceType.CDROM, "cdrom")]
- [InlineData(DeviceType.MagTape, "magtape")]
- [InlineData(DeviceType.ROMImage, "romimage")]
- [InlineData(DeviceType.MIDIIn, "midiin")]
- [InlineData(DeviceType.MIDIOut, "midiout")]
- [InlineData(DeviceType.Picture, "picture")]
- [InlineData(DeviceType.VidFile, "vidfile")]
- public void FromDeviceTypeTest(DeviceType field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(DisplayType.NULL, null)]
- [InlineData(DisplayType.Raster, "raster")]
- [InlineData(DisplayType.Vector, "vector")]
- [InlineData(DisplayType.LCD, "lcd")]
- [InlineData(DisplayType.SVG, "svg")]
- [InlineData(DisplayType.Unknown, "unknown")]
- public void FromDisplayTypeTest(DisplayType field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(Endianness.NULL, null)]
- [InlineData(Endianness.Big, "big")]
- [InlineData(Endianness.Little, "little")]
- public void FromEndiannessTest(Endianness field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(FeatureStatus.NULL, null)]
- [InlineData(FeatureStatus.Unemulated, "unemulated")]
- [InlineData(FeatureStatus.Imperfect, "imperfect")]
- public void FromFeatureStatusTest(FeatureStatus field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(FeatureType.NULL, null)]
- [InlineData(FeatureType.Protection, "protection")]
- [InlineData(FeatureType.Palette, "palette")]
- [InlineData(FeatureType.Graphics, "graphics")]
- [InlineData(FeatureType.Sound, "sound")]
- [InlineData(FeatureType.Controls, "controls")]
- [InlineData(FeatureType.Keyboard, "keyboard")]
- [InlineData(FeatureType.Mouse, "mouse")]
- [InlineData(FeatureType.Microphone, "microphone")]
- [InlineData(FeatureType.Camera, "camera")]
- [InlineData(FeatureType.Disk, "disk")]
- [InlineData(FeatureType.Printer, "printer")]
- [InlineData(FeatureType.Lan, "lan")]
- [InlineData(FeatureType.Wan, "wan")]
- [InlineData(FeatureType.Timing, "timing")]
- public void FromFeatureTypeTest(FeatureType field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(ItemStatus.NULL, true, null)]
- [InlineData(ItemStatus.NULL, false, null)]
- [InlineData(ItemStatus.None, true, "no")]
- [InlineData(ItemStatus.None, false, "none")]
- [InlineData(ItemStatus.Good, true, "good")]
- [InlineData(ItemStatus.Good, false, "good")]
- [InlineData(ItemStatus.BadDump, true, "baddump")]
- [InlineData(ItemStatus.BadDump, false, "baddump")]
- [InlineData(ItemStatus.Nodump, true, "yes")]
- [InlineData(ItemStatus.Nodump, false, "nodump")]
- [InlineData(ItemStatus.Verified, true, "verified")]
- [InlineData(ItemStatus.Verified, false, "verified")]
- public void FromItemStatusTest(ItemStatus field, bool useSecond, string? expected)
- {
- string? actual = field.AsStringValue(useSecond);
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(ItemType.NULL, null)]
- [InlineData(ItemType.Adjuster, "adjuster")]
- [InlineData(ItemType.Analog, "analog")]
- [InlineData(ItemType.Archive, "archive")]
- [InlineData(ItemType.BiosSet, "biosset")]
- [InlineData(ItemType.Blank, "blank")]
- [InlineData(ItemType.Chip, "chip")]
- [InlineData(ItemType.Condition, "condition")]
- [InlineData(ItemType.Configuration, "configuration")]
- [InlineData(ItemType.ConfLocation, "conflocation")]
- [InlineData(ItemType.ConfSetting, "confsetting")]
- [InlineData(ItemType.Control, "control")]
- [InlineData(ItemType.DataArea, "dataarea")]
- [InlineData(ItemType.Device, "device")]
- [InlineData(ItemType.DeviceRef, "device_ref")]
- [InlineData(ItemType.DipLocation, "diplocation")]
- [InlineData(ItemType.DipSwitch, "dipswitch")]
- [InlineData(ItemType.DipValue, "dipvalue")]
- [InlineData(ItemType.Disk, "disk")]
- [InlineData(ItemType.DiskArea, "diskarea")]
- [InlineData(ItemType.Display, "display")]
- [InlineData(ItemType.Driver, "driver")]
- [InlineData(ItemType.Extension, "extension")]
- [InlineData(ItemType.Feature, "feature")]
- [InlineData(ItemType.File, "file")]
- [InlineData(ItemType.Info, "info")]
- [InlineData(ItemType.Input, "input")]
- [InlineData(ItemType.Instance, "instance")]
- [InlineData(ItemType.Media, "media")]
- [InlineData(ItemType.Part, "part")]
- [InlineData(ItemType.PartFeature, "part_feature")]
- [InlineData(ItemType.Port, "port")]
- [InlineData(ItemType.RamOption, "ramoption")]
- [InlineData(ItemType.Release, "release")]
- [InlineData(ItemType.ReleaseDetails, "release_details")]
- [InlineData(ItemType.Rom, "rom")]
- [InlineData(ItemType.Sample, "sample")]
- [InlineData(ItemType.Serials, "serials")]
- [InlineData(ItemType.SharedFeat, "sharedfeat")]
- [InlineData(ItemType.Slot, "slot")]
- [InlineData(ItemType.SlotOption, "slotoption")]
- [InlineData(ItemType.SoftwareList, "softwarelist")]
- [InlineData(ItemType.Sound, "sound")]
- [InlineData(ItemType.SourceDetails, "source_details")]
- public void FromItemTypeTest(ItemType field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(LoadFlag.NULL, null)]
- [InlineData(LoadFlag.Load16Byte, "load16_byte")]
- [InlineData(LoadFlag.Load16Word, "load16_word")]
- [InlineData(LoadFlag.Load16WordSwap, "load16_word_swap")]
- [InlineData(LoadFlag.Load32Byte, "load32_byte")]
- [InlineData(LoadFlag.Load32Word, "load32_word")]
- [InlineData(LoadFlag.Load32WordSwap, "load32_word_swap")]
- [InlineData(LoadFlag.Load32DWord, "load32_dword")]
- [InlineData(LoadFlag.Load64Word, "load64_word")]
- [InlineData(LoadFlag.Load64WordSwap, "load64_word_swap")]
- [InlineData(LoadFlag.Reload, "reload")]
- [InlineData(LoadFlag.Fill, "fill")]
- [InlineData(LoadFlag.Continue, "continue")]
- [InlineData(LoadFlag.ReloadPlain, "reload_plain")]
- [InlineData(LoadFlag.Ignore, "ignore")]
- public void FromLoadFlagTest(LoadFlag field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(MachineType.None, true, "none")]
- [InlineData(MachineType.None, false, "none")]
- [InlineData(MachineType.Bios, true, "bios")]
- [InlineData(MachineType.Bios, false, "bios")]
- [InlineData(MachineType.Device, true, "dev")]
- [InlineData(MachineType.Device, false, "device")]
- [InlineData(MachineType.Mechanical, true, "mech")]
- [InlineData(MachineType.Mechanical, false, "mechanical")]
- public void FromMachineTypeTest(MachineType field, bool old, string? expected)
- {
- string? actual = field.AsStringValue(old);
- Assert.Equal(expected, actual);
- }
-
[Theory]
[InlineData(MergingFlag.None, true, "none")]
[InlineData(MergingFlag.None, false, "none")]
@@ -631,17 +106,6 @@ namespace SabreTools.Core.Test.Tools
Assert.Equal(expected, actual);
}
- [Theory]
- [InlineData(OpenMSXSubType.NULL, null)]
- [InlineData(OpenMSXSubType.Rom, "rom")]
- [InlineData(OpenMSXSubType.MegaRom, "megarom")]
- [InlineData(OpenMSXSubType.SCCPlusCart, "sccpluscart")]
- public void FromOpenMSXSubTypeTest(OpenMSXSubType field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
[Theory]
[InlineData(PackingFlag.None, true, "none")]
[InlineData(PackingFlag.None, false, "none")]
@@ -661,67 +125,6 @@ namespace SabreTools.Core.Test.Tools
Assert.Equal(expected, actual);
}
- [Theory]
- [InlineData(Relation.NULL, null)]
- [InlineData(Relation.Equal, "eq")]
- [InlineData(Relation.NotEqual, "ne")]
- [InlineData(Relation.GreaterThan, "gt")]
- [InlineData(Relation.LessThanOrEqual, "le")]
- [InlineData(Relation.LessThan, "lt")]
- [InlineData(Relation.GreaterThanOrEqual, "ge")]
- public void FromRelationTest(Relation field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(Runnable.NULL, null)]
- [InlineData(Runnable.No, "no")]
- [InlineData(Runnable.Partial, "partial")]
- [InlineData(Runnable.Yes, "yes")]
- public void FromRunnableTest(Runnable field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(SoftwareListStatus.None, "none")]
- [InlineData(SoftwareListStatus.Original, "original")]
- [InlineData(SoftwareListStatus.Compatible, "compatible")]
- public void FromSoftwareListStatusTest(SoftwareListStatus field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(Supported.NULL, true, null)]
- [InlineData(Supported.NULL, false, null)]
- [InlineData(Supported.No, true, "unsupported")]
- [InlineData(Supported.No, false, "no")]
- [InlineData(Supported.Partial, true, "partial")]
- [InlineData(Supported.Partial, false, "partial")]
- [InlineData(Supported.Yes, true, "supported")]
- [InlineData(Supported.Yes, false, "yes")]
- public void FromSupportedTest(Supported field, bool useSecond, string? expected)
- {
- string? actual = field.AsStringValue(useSecond);
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData(SupportStatus.NULL, null)]
- [InlineData(SupportStatus.Good, "good")]
- [InlineData(SupportStatus.Imperfect, "imperfect")]
- [InlineData(SupportStatus.Preliminary, "preliminary")]
- public void FromSupportStatusTest(SupportStatus field, string? expected)
- {
- string? actual = field.AsStringValue();
- Assert.Equal(expected, actual);
- }
-
[Theory]
[InlineData(null, null)]
[InlineData(true, "yes")]
@@ -737,26 +140,9 @@ namespace SabreTools.Core.Test.Tools
#region Generators
[Theory]
- [InlineData(ChipType.NULL, 2)]
- [InlineData(ControlType.NULL, 15)]
- [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, 54)]
- [InlineData(LoadFlag.NULL, 14)]
- [InlineData(MachineType.None, 6)]
[InlineData(MergingFlag.None, 12)]
[InlineData(NodumpFlag.None, 4)]
- [InlineData(OpenMSXSubType.NULL, 3)]
[InlineData(PackingFlag.None, 8)]
- [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();
diff --git a/SabreTools.Core/Filter/FieldManipulator.cs b/SabreTools.Core/Filter/FieldManipulator.cs
deleted file mode 100644
index 33c95700..00000000
--- a/SabreTools.Core/Filter/FieldManipulator.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using System;
-using SabreTools.Core.Tools;
-using SabreTools.Models.Metadata;
-
-namespace SabreTools.Core.Filter
-{
- public static class FieldManipulator
- {
- ///
- /// Remove a field from a given DictionaryBase
- ///
- public static bool RemoveField(DictionaryBase? dictionaryBase, string? fieldName)
- {
- // If the item or field name are missing, we can't do anything
- if (dictionaryBase == null || string.IsNullOrEmpty(fieldName))
- return false;
-
- // If the key doesn't exist, then it's already removed
- if (!dictionaryBase.ContainsKey(fieldName!))
- return true;
-
- // Remove the key
- dictionaryBase.Remove(fieldName!);
- return true;
- }
-
- ///
- /// Replace a field from one DictionaryBase to another
- ///
- public static bool ReplaceField(DictionaryBase? from, DictionaryBase? to, string? fieldName)
- {
- // If the items or field name are missing, we can't do anything
- if (from == null || to == null || string.IsNullOrEmpty(fieldName))
- return false;
-
- // If the types of the items are not the same, we can't do anything
- if (from.GetType() != to.GetType())
- return false;
-
- // If the key doesn't exist in the source, we can't do anything
- if (!from.ContainsKey(fieldName!))
- return false;
-
- // Set the key
- to[fieldName!] = from[fieldName!];
- return true;
- }
-
- ///
- /// Set a field in a given DictionaryBase
- ///
- public static bool SetField(DictionaryBase? dictionaryBase, string? fieldName, object value)
- {
- // If the item or field name are missing, we can't do anything
- if (dictionaryBase == null || string.IsNullOrEmpty(fieldName))
- return false;
-
- // Retrieve the list of valid fields for the item
- var constants = TypeHelper.GetConstants(dictionaryBase.GetType());
- if (constants == null)
- return false;
-
- // Get the value that matches the field name provided
- string? realField = Array.Find(constants, c => string.Equals(c, fieldName, StringComparison.OrdinalIgnoreCase));
- if (realField == null)
- return false;
-
- // Set the field with the new value
- dictionaryBase[realField] = value;
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/SabreTools.Core/ModelBackedItem.cs b/SabreTools.Core/ModelBackedItem.cs
index bda608a0..bdd0580b 100644
--- a/SabreTools.Core/ModelBackedItem.cs
+++ b/SabreTools.Core/ModelBackedItem.cs
@@ -149,5 +149,73 @@ namespace SabreTools.Core
}
#endregion
+
+ #region Manipulation
+
+ ///
+ /// Remove a field from the backing item
+ ///
+ public bool RemoveField(string? fieldName)
+ {
+ // If the item or field name are missing, we can't do anything
+ if (_internal == null || string.IsNullOrEmpty(fieldName))
+ return false;
+
+ // If the key doesn't exist, then it's already removed
+ if (!_internal.ContainsKey(fieldName!))
+ return true;
+
+ // Remove the key
+ _internal.Remove(fieldName!);
+ return true;
+ }
+
+ ///
+ /// Replace a field from another ModelBackedItem
+ ///
+ public bool ReplaceField(ModelBackedItem? from, string? fieldName)
+ {
+ // If the items or field name are missing, we can't do anything
+ if (from?._internal == null || _internal == null || string.IsNullOrEmpty(fieldName))
+ return false;
+
+ // If the types of the items are not the same, we can't do anything
+ if (from._internal.GetType() != _internal.GetType())
+ return false;
+
+ // If the key doesn't exist in the source, we can't do anything
+ if (!from._internal.ContainsKey(fieldName!))
+ return false;
+
+ // Set the key
+ _internal[fieldName!] = from._internal[fieldName!];
+ return true;
+ }
+
+ ///
+ /// Set a field from the backing item
+ ///
+ public bool SetField(string? fieldName, object value)
+ {
+ // If the item or field name are missing, we can't do anything
+ if (_internal == null || string.IsNullOrEmpty(fieldName))
+ return false;
+
+ // Retrieve the list of valid fields for the item
+ var constants = TypeHelper.GetConstants(_internal.GetType());
+ if (constants == null)
+ return false;
+
+ // Get the value that matches the field name provided
+ string? realField = Array.Find(constants, c => string.Equals(c, fieldName, StringComparison.OrdinalIgnoreCase));
+ if (realField == null)
+ return false;
+
+ // Set the field with the new value
+ _internal[realField] = value;
+ return true;
+ }
+
+ #endregion
}
}
diff --git a/SabreTools.Core/Tools/Converters.cs b/SabreTools.Core/Tools/Converters.cs
index fa9eeedc..e31b6b89 100644
--- a/SabreTools.Core/Tools/Converters.cs
+++ b/SabreTools.Core/Tools/Converters.cs
@@ -51,7 +51,7 @@ namespace SabreTools.Core.Tools
///
/// Enum type that is expected
/// Dictionary of string to enum values
- internal static Dictionary GenerateToEnum()
+ public static Dictionary GenerateToEnum()
{
try
{
diff --git a/SabreTools.DatFiles/DatHeader.cs b/SabreTools.DatFiles/DatHeader.cs
index dabb1567..e4f904e5 100644
--- a/SabreTools.DatFiles/DatHeader.cs
+++ b/SabreTools.DatFiles/DatHeader.cs
@@ -379,33 +379,6 @@ namespace SabreTools.DatFiles
/// True if the Machine passes the filter, false otherwise
public bool PassesFilter(FilterRunner filterRunner) => filterRunner.Run(_internal);
- ///
- /// Remove a field from the header
- ///
- /// Field to remove
- /// True if the removal was successful, false otherwise
- public bool RemoveField(string fieldName)
- => FieldManipulator.RemoveField(_internal, fieldName);
-
- ///
- /// Replace a field from another DatHeader
- ///
- /// DatHeader to replace field from
- /// Field to replace
- /// True if the replacement was successful, false otherwise
- public bool ReplaceField(DatHeader? other, string? fieldName)
- => FieldManipulator.ReplaceField(other?._internal, _internal, fieldName);
-
- ///
- /// Set a field in the header from a mapping string
- ///
- /// Field to set
- /// String representing the value to set
- /// True if the setting was successful, false otherwise
- /// This only performs minimal validation before setting
- public bool SetField(string? fieldName, string value)
- => FieldManipulator.SetField(_internal, fieldName, value);
-
#endregion
#region Writing
diff --git a/SabreTools.DatItems.Test/ConvertersTests.cs b/SabreTools.DatItems.Test/ConvertersTests.cs
new file mode 100644
index 00000000..6f873e74
--- /dev/null
+++ b/SabreTools.DatItems.Test/ConvertersTests.cs
@@ -0,0 +1,641 @@
+using SabreTools.Core.Tools;
+using Xunit;
+
+namespace SabreTools.DatItems.Test
+{
+ public class ConvertersTests
+ {
+ #region String to Enum
+
+ [Theory]
+ [InlineData(null, ChipType.NULL)]
+ [InlineData("cpu", ChipType.CPU)]
+ [InlineData("audio", ChipType.Audio)]
+ public void AsChipTypeTest(string? field, ChipType expected)
+ {
+ ChipType actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, ControlType.NULL)]
+ [InlineData("joy", ControlType.Joy)]
+ [InlineData("stick", ControlType.Stick)]
+ [InlineData("paddle", ControlType.Paddle)]
+ [InlineData("pedal", ControlType.Pedal)]
+ [InlineData("lightgun", ControlType.Lightgun)]
+ [InlineData("positional", ControlType.Positional)]
+ [InlineData("dial", ControlType.Dial)]
+ [InlineData("trackball", ControlType.Trackball)]
+ [InlineData("mouse", ControlType.Mouse)]
+ [InlineData("only_buttons", ControlType.OnlyButtons)]
+ [InlineData("keypad", ControlType.Keypad)]
+ [InlineData("keyboard", ControlType.Keyboard)]
+ [InlineData("mahjong", ControlType.Mahjong)]
+ [InlineData("hanafuda", ControlType.Hanafuda)]
+ [InlineData("gambling", ControlType.Gambling)]
+ public void AsControlTypeTest(string? field, ControlType expected)
+ {
+ ControlType actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, DeviceType.NULL)]
+ [InlineData("unknown", DeviceType.Unknown)]
+ [InlineData("cartridge", DeviceType.Cartridge)]
+ [InlineData("floppydisk", DeviceType.FloppyDisk)]
+ [InlineData("harddisk", DeviceType.HardDisk)]
+ [InlineData("cylinder", DeviceType.Cylinder)]
+ [InlineData("cassette", DeviceType.Cassette)]
+ [InlineData("punchcard", DeviceType.PunchCard)]
+ [InlineData("punchtape", DeviceType.PunchTape)]
+ [InlineData("printout", DeviceType.Printout)]
+ [InlineData("serial", DeviceType.Serial)]
+ [InlineData("parallel", DeviceType.Parallel)]
+ [InlineData("snapshot", DeviceType.Snapshot)]
+ [InlineData("quickload", DeviceType.QuickLoad)]
+ [InlineData("memcard", DeviceType.MemCard)]
+ [InlineData("cdrom", DeviceType.CDROM)]
+ [InlineData("magtape", DeviceType.MagTape)]
+ [InlineData("romimage", DeviceType.ROMImage)]
+ [InlineData("midiin", DeviceType.MIDIIn)]
+ [InlineData("midiout", DeviceType.MIDIOut)]
+ [InlineData("picture", DeviceType.Picture)]
+ [InlineData("vidfile", DeviceType.VidFile)]
+ public void AsDeviceTypeTest(string? field, DeviceType expected)
+ {
+ DeviceType actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, DisplayType.NULL)]
+ [InlineData("raster", DisplayType.Raster)]
+ [InlineData("vector", DisplayType.Vector)]
+ [InlineData("lcd", DisplayType.LCD)]
+ [InlineData("svg", DisplayType.SVG)]
+ [InlineData("unknown", DisplayType.Unknown)]
+ public void AsDisplayTypeTest(string? field, DisplayType expected)
+ {
+ DisplayType actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, Endianness.NULL)]
+ [InlineData("big", Endianness.Big)]
+ [InlineData("little", Endianness.Little)]
+ public void AsEndiannessTest(string? field, Endianness expected)
+ {
+ Endianness actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, FeatureStatus.NULL)]
+ [InlineData("unemulated", FeatureStatus.Unemulated)]
+ [InlineData("imperfect", FeatureStatus.Imperfect)]
+ public void AsFeatureStatusTest(string? field, FeatureStatus expected)
+ {
+ FeatureStatus actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, FeatureType.NULL)]
+ [InlineData("protection", FeatureType.Protection)]
+ [InlineData("palette", FeatureType.Palette)]
+ [InlineData("graphics", FeatureType.Graphics)]
+ [InlineData("sound", FeatureType.Sound)]
+ [InlineData("controls", FeatureType.Controls)]
+ [InlineData("keyboard", FeatureType.Keyboard)]
+ [InlineData("mouse", FeatureType.Mouse)]
+ [InlineData("microphone", FeatureType.Microphone)]
+ [InlineData("camera", FeatureType.Camera)]
+ [InlineData("disk", FeatureType.Disk)]
+ [InlineData("printer", FeatureType.Printer)]
+ [InlineData("lan", FeatureType.Lan)]
+ [InlineData("wan", FeatureType.Wan)]
+ [InlineData("timing", FeatureType.Timing)]
+ public void AsFeatureTypeTest(string? field, FeatureType expected)
+ {
+ FeatureType actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, ItemStatus.NULL)]
+ [InlineData("none", ItemStatus.None)]
+ [InlineData("no", ItemStatus.None)]
+ [InlineData("good", ItemStatus.Good)]
+ [InlineData("baddump", ItemStatus.BadDump)]
+ [InlineData("nodump", ItemStatus.Nodump)]
+ [InlineData("yes", ItemStatus.Nodump)]
+ [InlineData("verified", ItemStatus.Verified)]
+ public void AsItemStatusTest(string? field, ItemStatus expected)
+ {
+ ItemStatus actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, ItemType.NULL)]
+ [InlineData("adjuster", ItemType.Adjuster)]
+ [InlineData("analog", ItemType.Analog)]
+ [InlineData("archive", ItemType.Archive)]
+ [InlineData("biosset", ItemType.BiosSet)]
+ [InlineData("blank", ItemType.Blank)]
+ [InlineData("chip", ItemType.Chip)]
+ [InlineData("condition", ItemType.Condition)]
+ [InlineData("configuration", ItemType.Configuration)]
+ [InlineData("conflocation", ItemType.ConfLocation)]
+ [InlineData("confsetting", ItemType.ConfSetting)]
+ [InlineData("control", ItemType.Control)]
+ [InlineData("dataarea", ItemType.DataArea)]
+ [InlineData("device", ItemType.Device)]
+ [InlineData("deviceref", ItemType.DeviceRef)]
+ [InlineData("device_ref", ItemType.DeviceRef)]
+ [InlineData("diplocation", ItemType.DipLocation)]
+ [InlineData("dipswitch", ItemType.DipSwitch)]
+ [InlineData("dipvalue", ItemType.DipValue)]
+ [InlineData("disk", ItemType.Disk)]
+ [InlineData("diskarea", ItemType.DiskArea)]
+ [InlineData("display", ItemType.Display)]
+ [InlineData("driver", ItemType.Driver)]
+ [InlineData("extension", ItemType.Extension)]
+ [InlineData("feature", ItemType.Feature)]
+ [InlineData("file", ItemType.File)]
+ [InlineData("info", ItemType.Info)]
+ [InlineData("input", ItemType.Input)]
+ [InlineData("instance", ItemType.Instance)]
+ [InlineData("media", ItemType.Media)]
+ [InlineData("part", ItemType.Part)]
+ [InlineData("partfeature", ItemType.PartFeature)]
+ [InlineData("part_feature", ItemType.PartFeature)]
+ [InlineData("port", ItemType.Port)]
+ [InlineData("ramoption", ItemType.RamOption)]
+ [InlineData("ram_option", ItemType.RamOption)]
+ [InlineData("release", ItemType.Release)]
+ [InlineData("releasedetails", ItemType.ReleaseDetails)]
+ [InlineData("release_details", ItemType.ReleaseDetails)]
+ [InlineData("rom", ItemType.Rom)]
+ [InlineData("sample", ItemType.Sample)]
+ [InlineData("serials", ItemType.Serials)]
+ [InlineData("sharedfeat", ItemType.SharedFeat)]
+ [InlineData("shared_feat", ItemType.SharedFeat)]
+ [InlineData("sharedfeature", ItemType.SharedFeat)]
+ [InlineData("shared_feature", ItemType.SharedFeat)]
+ [InlineData("slot", ItemType.Slot)]
+ [InlineData("slotoption", ItemType.SlotOption)]
+ [InlineData("slot_option", ItemType.SlotOption)]
+ [InlineData("softwarelist", ItemType.SoftwareList)]
+ [InlineData("software_list", ItemType.SoftwareList)]
+ [InlineData("sound", ItemType.Sound)]
+ [InlineData("sourcedetails", ItemType.SourceDetails)]
+ [InlineData("source_details", ItemType.SourceDetails)]
+ public void AsItemTypeTest(string? field, ItemType expected)
+ {
+ ItemType actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, LoadFlag.NULL)]
+ [InlineData("load16_byte", LoadFlag.Load16Byte)]
+ [InlineData("load16_word", LoadFlag.Load16Word)]
+ [InlineData("load16_word_swap", LoadFlag.Load16WordSwap)]
+ [InlineData("load32_byte", LoadFlag.Load32Byte)]
+ [InlineData("load32_word", LoadFlag.Load32Word)]
+ [InlineData("load32_word_swap", LoadFlag.Load32WordSwap)]
+ [InlineData("load32_dword", LoadFlag.Load32DWord)]
+ [InlineData("load64_word", LoadFlag.Load64Word)]
+ [InlineData("load64_word_swap", LoadFlag.Load64WordSwap)]
+ [InlineData("reload", LoadFlag.Reload)]
+ [InlineData("fill", LoadFlag.Fill)]
+ [InlineData("continue", LoadFlag.Continue)]
+ [InlineData("reload_plain", LoadFlag.ReloadPlain)]
+ [InlineData("ignore", LoadFlag.Ignore)]
+ public void AsLoadFlagTest(string? field, LoadFlag expected)
+ {
+ LoadFlag actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, MachineType.None)]
+ [InlineData("none", MachineType.None)]
+ [InlineData("bios", MachineType.Bios)]
+ [InlineData("dev", MachineType.Device)]
+ [InlineData("device", MachineType.Device)]
+ [InlineData("mech", MachineType.Mechanical)]
+ [InlineData("mechanical", MachineType.Mechanical)]
+ public void AsMachineTypeTest(string? field, MachineType expected)
+ {
+ MachineType actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, OpenMSXSubType.NULL)]
+ [InlineData("rom", OpenMSXSubType.Rom)]
+ [InlineData("megarom", OpenMSXSubType.MegaRom)]
+ [InlineData("sccpluscart", OpenMSXSubType.SCCPlusCart)]
+ public void AsOpenMSXSubTypeTest(string? field, OpenMSXSubType expected)
+ {
+ OpenMSXSubType actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, Relation.NULL)]
+ [InlineData("eq", Relation.Equal)]
+ [InlineData("ne", Relation.NotEqual)]
+ [InlineData("gt", Relation.GreaterThan)]
+ [InlineData("le", Relation.LessThanOrEqual)]
+ [InlineData("lt", Relation.LessThan)]
+ [InlineData("ge", Relation.GreaterThanOrEqual)]
+ public void AsRelationTest(string? field, Relation expected)
+ {
+ Relation actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, Runnable.NULL)]
+ [InlineData("no", Runnable.No)]
+ [InlineData("partial", Runnable.Partial)]
+ [InlineData("yes", Runnable.Yes)]
+ public void AsRunnableTest(string? field, Runnable expected)
+ {
+ Runnable actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, SoftwareListStatus.None)]
+ [InlineData("none", SoftwareListStatus.None)]
+ [InlineData("original", SoftwareListStatus.Original)]
+ [InlineData("compatible", SoftwareListStatus.Compatible)]
+ public void AsSoftwareListStatusTest(string? field, SoftwareListStatus expected)
+ {
+ SoftwareListStatus actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, Supported.NULL)]
+ [InlineData("no", Supported.No)]
+ [InlineData("unsupported", Supported.No)]
+ [InlineData("partial", Supported.Partial)]
+ [InlineData("yes", Supported.Yes)]
+ [InlineData("supported", Supported.Yes)]
+ public void AsSupportedTest(string? field, Supported expected)
+ {
+ Supported actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(null, SupportStatus.NULL)]
+ [InlineData("good", SupportStatus.Good)]
+ [InlineData("imperfect", SupportStatus.Imperfect)]
+ [InlineData("preliminary", SupportStatus.Preliminary)]
+ public void AsSupportStatusTest(string? field, SupportStatus expected)
+ {
+ SupportStatus actual = field.AsEnumValue();
+ Assert.Equal(expected, actual);
+ }
+
+ #endregion
+
+ #region Enum to String
+
+ [Theory]
+ [InlineData(ChipType.NULL, null)]
+ [InlineData(ChipType.CPU, "cpu")]
+ [InlineData(ChipType.Audio, "audio")]
+ public void FromChipTypeTest(ChipType field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(ControlType.NULL, null)]
+ [InlineData(ControlType.Joy, "joy")]
+ [InlineData(ControlType.Stick, "stick")]
+ [InlineData(ControlType.Paddle, "paddle")]
+ [InlineData(ControlType.Pedal, "pedal")]
+ [InlineData(ControlType.Lightgun, "lightgun")]
+ [InlineData(ControlType.Positional, "positional")]
+ [InlineData(ControlType.Dial, "dial")]
+ [InlineData(ControlType.Trackball, "trackball")]
+ [InlineData(ControlType.Mouse, "mouse")]
+ [InlineData(ControlType.OnlyButtons, "only_buttons")]
+ [InlineData(ControlType.Keypad, "keypad")]
+ [InlineData(ControlType.Keyboard, "keyboard")]
+ [InlineData(ControlType.Mahjong, "mahjong")]
+ [InlineData(ControlType.Hanafuda, "hanafuda")]
+ [InlineData(ControlType.Gambling, "gambling")]
+ public void FromControlTypeTest(ControlType field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(DeviceType.NULL, null)]
+ [InlineData(DeviceType.Unknown, "unknown")]
+ [InlineData(DeviceType.Cartridge, "cartridge")]
+ [InlineData(DeviceType.FloppyDisk, "floppydisk")]
+ [InlineData(DeviceType.HardDisk, "harddisk")]
+ [InlineData(DeviceType.Cylinder, "cylinder")]
+ [InlineData(DeviceType.Cassette, "cassette")]
+ [InlineData(DeviceType.PunchCard, "punchcard")]
+ [InlineData(DeviceType.PunchTape, "punchtape")]
+ [InlineData(DeviceType.Printout, "printout")]
+ [InlineData(DeviceType.Serial, "serial")]
+ [InlineData(DeviceType.Parallel, "parallel")]
+ [InlineData(DeviceType.Snapshot, "snapshot")]
+ [InlineData(DeviceType.QuickLoad, "quickload")]
+ [InlineData(DeviceType.MemCard, "memcard")]
+ [InlineData(DeviceType.CDROM, "cdrom")]
+ [InlineData(DeviceType.MagTape, "magtape")]
+ [InlineData(DeviceType.ROMImage, "romimage")]
+ [InlineData(DeviceType.MIDIIn, "midiin")]
+ [InlineData(DeviceType.MIDIOut, "midiout")]
+ [InlineData(DeviceType.Picture, "picture")]
+ [InlineData(DeviceType.VidFile, "vidfile")]
+ public void FromDeviceTypeTest(DeviceType field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(DisplayType.NULL, null)]
+ [InlineData(DisplayType.Raster, "raster")]
+ [InlineData(DisplayType.Vector, "vector")]
+ [InlineData(DisplayType.LCD, "lcd")]
+ [InlineData(DisplayType.SVG, "svg")]
+ [InlineData(DisplayType.Unknown, "unknown")]
+ public void FromDisplayTypeTest(DisplayType field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(Endianness.NULL, null)]
+ [InlineData(Endianness.Big, "big")]
+ [InlineData(Endianness.Little, "little")]
+ public void FromEndiannessTest(Endianness field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(FeatureStatus.NULL, null)]
+ [InlineData(FeatureStatus.Unemulated, "unemulated")]
+ [InlineData(FeatureStatus.Imperfect, "imperfect")]
+ public void FromFeatureStatusTest(FeatureStatus field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(FeatureType.NULL, null)]
+ [InlineData(FeatureType.Protection, "protection")]
+ [InlineData(FeatureType.Palette, "palette")]
+ [InlineData(FeatureType.Graphics, "graphics")]
+ [InlineData(FeatureType.Sound, "sound")]
+ [InlineData(FeatureType.Controls, "controls")]
+ [InlineData(FeatureType.Keyboard, "keyboard")]
+ [InlineData(FeatureType.Mouse, "mouse")]
+ [InlineData(FeatureType.Microphone, "microphone")]
+ [InlineData(FeatureType.Camera, "camera")]
+ [InlineData(FeatureType.Disk, "disk")]
+ [InlineData(FeatureType.Printer, "printer")]
+ [InlineData(FeatureType.Lan, "lan")]
+ [InlineData(FeatureType.Wan, "wan")]
+ [InlineData(FeatureType.Timing, "timing")]
+ public void FromFeatureTypeTest(FeatureType field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(ItemStatus.NULL, true, null)]
+ [InlineData(ItemStatus.NULL, false, null)]
+ [InlineData(ItemStatus.None, true, "no")]
+ [InlineData(ItemStatus.None, false, "none")]
+ [InlineData(ItemStatus.Good, true, "good")]
+ [InlineData(ItemStatus.Good, false, "good")]
+ [InlineData(ItemStatus.BadDump, true, "baddump")]
+ [InlineData(ItemStatus.BadDump, false, "baddump")]
+ [InlineData(ItemStatus.Nodump, true, "yes")]
+ [InlineData(ItemStatus.Nodump, false, "nodump")]
+ [InlineData(ItemStatus.Verified, true, "verified")]
+ [InlineData(ItemStatus.Verified, false, "verified")]
+ public void FromItemStatusTest(ItemStatus field, bool useSecond, string? expected)
+ {
+ string? actual = field.AsStringValue(useSecond);
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(ItemType.NULL, null)]
+ [InlineData(ItemType.Adjuster, "adjuster")]
+ [InlineData(ItemType.Analog, "analog")]
+ [InlineData(ItemType.Archive, "archive")]
+ [InlineData(ItemType.BiosSet, "biosset")]
+ [InlineData(ItemType.Blank, "blank")]
+ [InlineData(ItemType.Chip, "chip")]
+ [InlineData(ItemType.Condition, "condition")]
+ [InlineData(ItemType.Configuration, "configuration")]
+ [InlineData(ItemType.ConfLocation, "conflocation")]
+ [InlineData(ItemType.ConfSetting, "confsetting")]
+ [InlineData(ItemType.Control, "control")]
+ [InlineData(ItemType.DataArea, "dataarea")]
+ [InlineData(ItemType.Device, "device")]
+ [InlineData(ItemType.DeviceRef, "device_ref")]
+ [InlineData(ItemType.DipLocation, "diplocation")]
+ [InlineData(ItemType.DipSwitch, "dipswitch")]
+ [InlineData(ItemType.DipValue, "dipvalue")]
+ [InlineData(ItemType.Disk, "disk")]
+ [InlineData(ItemType.DiskArea, "diskarea")]
+ [InlineData(ItemType.Display, "display")]
+ [InlineData(ItemType.Driver, "driver")]
+ [InlineData(ItemType.Extension, "extension")]
+ [InlineData(ItemType.Feature, "feature")]
+ [InlineData(ItemType.File, "file")]
+ [InlineData(ItemType.Info, "info")]
+ [InlineData(ItemType.Input, "input")]
+ [InlineData(ItemType.Instance, "instance")]
+ [InlineData(ItemType.Media, "media")]
+ [InlineData(ItemType.Part, "part")]
+ [InlineData(ItemType.PartFeature, "part_feature")]
+ [InlineData(ItemType.Port, "port")]
+ [InlineData(ItemType.RamOption, "ramoption")]
+ [InlineData(ItemType.Release, "release")]
+ [InlineData(ItemType.ReleaseDetails, "release_details")]
+ [InlineData(ItemType.Rom, "rom")]
+ [InlineData(ItemType.Sample, "sample")]
+ [InlineData(ItemType.Serials, "serials")]
+ [InlineData(ItemType.SharedFeat, "sharedfeat")]
+ [InlineData(ItemType.Slot, "slot")]
+ [InlineData(ItemType.SlotOption, "slotoption")]
+ [InlineData(ItemType.SoftwareList, "softwarelist")]
+ [InlineData(ItemType.Sound, "sound")]
+ [InlineData(ItemType.SourceDetails, "source_details")]
+ public void FromItemTypeTest(ItemType field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(LoadFlag.NULL, null)]
+ [InlineData(LoadFlag.Load16Byte, "load16_byte")]
+ [InlineData(LoadFlag.Load16Word, "load16_word")]
+ [InlineData(LoadFlag.Load16WordSwap, "load16_word_swap")]
+ [InlineData(LoadFlag.Load32Byte, "load32_byte")]
+ [InlineData(LoadFlag.Load32Word, "load32_word")]
+ [InlineData(LoadFlag.Load32WordSwap, "load32_word_swap")]
+ [InlineData(LoadFlag.Load32DWord, "load32_dword")]
+ [InlineData(LoadFlag.Load64Word, "load64_word")]
+ [InlineData(LoadFlag.Load64WordSwap, "load64_word_swap")]
+ [InlineData(LoadFlag.Reload, "reload")]
+ [InlineData(LoadFlag.Fill, "fill")]
+ [InlineData(LoadFlag.Continue, "continue")]
+ [InlineData(LoadFlag.ReloadPlain, "reload_plain")]
+ [InlineData(LoadFlag.Ignore, "ignore")]
+ public void FromLoadFlagTest(LoadFlag field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(MachineType.None, true, "none")]
+ [InlineData(MachineType.None, false, "none")]
+ [InlineData(MachineType.Bios, true, "bios")]
+ [InlineData(MachineType.Bios, false, "bios")]
+ [InlineData(MachineType.Device, true, "dev")]
+ [InlineData(MachineType.Device, false, "device")]
+ [InlineData(MachineType.Mechanical, true, "mech")]
+ [InlineData(MachineType.Mechanical, false, "mechanical")]
+ public void FromMachineTypeTest(MachineType field, bool old, string? expected)
+ {
+ string? actual = field.AsStringValue(old);
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(OpenMSXSubType.NULL, null)]
+ [InlineData(OpenMSXSubType.Rom, "rom")]
+ [InlineData(OpenMSXSubType.MegaRom, "megarom")]
+ [InlineData(OpenMSXSubType.SCCPlusCart, "sccpluscart")]
+ public void FromOpenMSXSubTypeTest(OpenMSXSubType field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(Relation.NULL, null)]
+ [InlineData(Relation.Equal, "eq")]
+ [InlineData(Relation.NotEqual, "ne")]
+ [InlineData(Relation.GreaterThan, "gt")]
+ [InlineData(Relation.LessThanOrEqual, "le")]
+ [InlineData(Relation.LessThan, "lt")]
+ [InlineData(Relation.GreaterThanOrEqual, "ge")]
+ public void FromRelationTest(Relation field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(Runnable.NULL, null)]
+ [InlineData(Runnable.No, "no")]
+ [InlineData(Runnable.Partial, "partial")]
+ [InlineData(Runnable.Yes, "yes")]
+ public void FromRunnableTest(Runnable field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(SoftwareListStatus.None, "none")]
+ [InlineData(SoftwareListStatus.Original, "original")]
+ [InlineData(SoftwareListStatus.Compatible, "compatible")]
+ public void FromSoftwareListStatusTest(SoftwareListStatus field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(Supported.NULL, true, null)]
+ [InlineData(Supported.NULL, false, null)]
+ [InlineData(Supported.No, true, "unsupported")]
+ [InlineData(Supported.No, false, "no")]
+ [InlineData(Supported.Partial, true, "partial")]
+ [InlineData(Supported.Partial, false, "partial")]
+ [InlineData(Supported.Yes, true, "supported")]
+ [InlineData(Supported.Yes, false, "yes")]
+ public void FromSupportedTest(Supported field, bool useSecond, string? expected)
+ {
+ string? actual = field.AsStringValue(useSecond);
+ Assert.Equal(expected, actual);
+ }
+
+ [Theory]
+ [InlineData(SupportStatus.NULL, null)]
+ [InlineData(SupportStatus.Good, "good")]
+ [InlineData(SupportStatus.Imperfect, "imperfect")]
+ [InlineData(SupportStatus.Preliminary, "preliminary")]
+ public void FromSupportStatusTest(SupportStatus field, string? expected)
+ {
+ string? actual = field.AsStringValue();
+ Assert.Equal(expected, actual);
+ }
+
+ #endregion
+
+ #region Generators
+
+ [Theory]
+ [InlineData(ChipType.NULL, 2)]
+ [InlineData(ControlType.NULL, 15)]
+ [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, 54)]
+ [InlineData(LoadFlag.NULL, 14)]
+ [InlineData(MachineType.None, 6)]
+ [InlineData(OpenMSXSubType.NULL, 3)]
+ [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
diff --git a/SabreTools.DatItems/DatItem.cs b/SabreTools.DatItems/DatItem.cs
index 47a2988d..0e46f325 100644
--- a/SabreTools.DatItems/DatItem.cs
+++ b/SabreTools.DatItems/DatItem.cs
@@ -297,33 +297,6 @@ namespace SabreTools.DatItems
return filterRunner.Run(_internal);
}
- ///
- /// Remove a field from the DatItem
- ///
- /// Field to remove
- /// True if the removal was successful, false otherwise
- public bool RemoveField(string? fieldName)
- => FieldManipulator.RemoveField(_internal, fieldName);
-
- ///
- /// Replace a field from another DatItem
- ///
- /// DatItem to replace field from
- /// Field to replace
- /// True if the replacement was successful, false otherwise
- public bool ReplaceField(DatItem? other, string? fieldName)
- => FieldManipulator.ReplaceField(other?._internal, _internal, fieldName);
-
- ///
- /// Set a field in the DatItem from a mapping string
- ///
- /// Field to set
- /// String representing the value to set
- /// True if the removal was successful, false otherwise
- /// This only performs minimal validation before setting
- public bool SetField(string? fieldName, string value)
- => FieldManipulator.SetField(_internal, fieldName, value);
-
#endregion
#region Sorting and Merging
diff --git a/SabreTools.DatItems/Machine.cs b/SabreTools.DatItems/Machine.cs
index 0a8411f8..c30cd6fd 100644
--- a/SabreTools.DatItems/Machine.cs
+++ b/SabreTools.DatItems/Machine.cs
@@ -91,33 +91,6 @@ namespace SabreTools.DatItems
/// True if the Machine passes the filter, false otherwise
public bool PassesFilter(FilterRunner filterRunner) => filterRunner.Run(_internal);
- ///
- /// Remove a field from the Machine
- ///
- /// Field to remove
- /// True if the removal was successful, false otherwise
- public bool RemoveField(string? fieldName)
- => FieldManipulator.RemoveField(_internal, fieldName);
-
- ///
- /// Replace a field from another Machine
- ///
- /// Machine to replace field from
- /// Field to replace
- /// True if the replacement was successful, false otherwise
- public bool ReplaceField(Machine? other, string? fieldName)
- => FieldManipulator.ReplaceField(other?._internal, _internal, fieldName);
-
- ///
- /// Set a field in the Machine from a mapping string
- ///
- /// Field to set
- /// String representing the value to set
- /// True if the setting was successful, false otherwise
- /// This only performs minimal validation before setting
- public bool SetField(string? fieldName, string value)
- => FieldManipulator.SetField(_internal, fieldName, value);
-
#endregion
}
}