using System; using SabreTools.Core; using Xunit; namespace SabreTools.Test.Parser { /// /// Filenames that end in `-files` are real examples. /// All other files are artificial and may not fully represent real examples. /// public class DeserializationTests { [Theory] [InlineData("test-archivedotorg-files1.xml", 22)] [InlineData("test-archivedotorg-files2.xml", 13)] [InlineData("test-archivedotorg-files3.xml", 21)] [InlineData("test-archivedotorg-files4.xml", 19)] [InlineData("test-archivedotorg-files5.xml", 1390)] public void ArchiveDotOrgDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.ArchiveDotOrg.Deserialize(filename); // Validate the values Assert.NotNull(dat?.File); Assert.Equal(count, dat.File.Length); // Validate we're not missing any attributes or elements Assert.Null(dat.ADDITIONAL_ATTRIBUTES); Assert.Null(dat.ADDITIONAL_ELEMENTS); foreach (var file in dat.File) { Assert.Null(file.ADDITIONAL_ATTRIBUTES); Assert.Null(file.ADDITIONAL_ELEMENTS); } } [Theory] [InlineData("test-attractmode-files.txt", 11)] public void AttractModeDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.AttractMode.Deserialize(filename); // Validate texpected: he values Assert.NotNull(dat?.Row); Assert.Equal(count, dat.Row.Length); // Validate we're not missing any attributes or elements foreach (var file in dat.Row) { Assert.Null(file.ADDITIONAL_ELEMENTS); } } [Theory] [InlineData("test-cmp-files.dat", 59)] public void ClrMameProDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.ClrMamePro.Deserialize(filename); // Validate the values Assert.NotNull(dat?.ClrMamePro); Assert.Equal(count, dat.Game.Length); // Validate we're not missing any attributes or elements Assert.Empty(dat.ADDITIONAL_ELEMENTS); Assert.Null(dat.ClrMamePro.ADDITIONAL_ELEMENTS); foreach (var game in dat.Game) { Assert.Empty(game.ADDITIONAL_ELEMENTS); foreach (var item in game.Item) { switch (item) { case Models.ClrMamePro.Release release: Assert.Empty(release.ADDITIONAL_ELEMENTS); break; case Models.ClrMamePro.BiosSet biosset: Assert.Empty(biosset.ADDITIONAL_ELEMENTS); break; case Models.ClrMamePro.Rom rom: Assert.Empty(rom.ADDITIONAL_ELEMENTS); break; case Models.ClrMamePro.Disk disk: Assert.Empty(disk.ADDITIONAL_ELEMENTS); break; case Models.ClrMamePro.Media media: Assert.Empty(media.ADDITIONAL_ELEMENTS); break; case Models.ClrMamePro.Sample sample: Assert.Empty(sample.ADDITIONAL_ELEMENTS); break; case Models.ClrMamePro.Archive archive: Assert.Empty(archive.ADDITIONAL_ELEMENTS); break; } } } } [Theory] [InlineData("test-doscenter-files.dat.gz", 34965)] public void DosCenterDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.DosCenter.Deserialize(filename); // Validate the values Assert.NotNull(dat?.DosCenter); Assert.Equal(count, dat.Game.Length); // Validate we're not missing any attributes or elements Assert.Empty(dat.ADDITIONAL_ELEMENTS); Assert.Empty(dat.DosCenter.ADDITIONAL_ELEMENTS); foreach (var game in dat.Game) { Assert.Empty(game.ADDITIONAL_ELEMENTS); foreach (var file in game.File) { Assert.Empty(file.ADDITIONAL_ELEMENTS); } } } [Theory] [InlineData("test-smdb-files.txt", 6113)] public void EverdriveSMDBDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.EverdriveSMDB.Deserialize(filename); // Validate the values Assert.NotNull(dat?.Row); Assert.Equal(count, dat.Row.Length); // Validate we're not missing any attributes or elements foreach (var file in dat.Row) { Assert.Null(file.ADDITIONAL_ELEMENTS); } } [Theory] [InlineData("test-sfv-files.sfv", Hash.CRC, 100)] [InlineData("test-md5-files.md5", Hash.MD5, 100)] [InlineData("test-sha1-files.sha1", Hash.SHA1, 100)] [InlineData("test-sha256.sha256", Hash.SHA256, 1)] [InlineData("test-sha384.sha384", Hash.SHA384, 1)] [InlineData("test-sha512.sha512", Hash.SHA512, 1)] [InlineData("test-spamsum.spamsum", Hash.SpamSum, 1)] public void HashfileDeserializeTest(string path, Hash hash, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.Hashfile.Deserialize(filename, hash); // Validate the values Assert.NotNull(dat); switch (hash) { case Hash.CRC: Assert.Equal(count, dat.SFV.Length); break; case Hash.MD5: Assert.Equal(count, dat.MD5.Length); break; case Hash.SHA1: Assert.Equal(count, dat.SHA1.Length); break; case Hash.SHA256: Assert.Equal(count, dat.SHA256.Length); break; case Hash.SHA384: Assert.Equal(count, dat.SHA384.Length); break; case Hash.SHA512: Assert.Equal(count, dat.SHA512.Length); break; case Hash.SpamSum: Assert.Equal(count, dat.SpamSum.Length); break; default: throw new ArgumentOutOfRangeException(nameof(hash)); } } [Theory] [InlineData("test-listrom-files.txt.gz", 45861)] public void ListromDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.Listrom.Deserialize(filename); // Validate the values Assert.NotNull(dat?.Set); Assert.Equal(count, dat.Set.Length); // Validate we're not missing any attributes or elements Assert.Empty(dat.ADDITIONAL_ELEMENTS); } [Theory] [InlineData("test-listxml-files.xml.gz", 45861)] public void ListxmlDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.Listxml.Deserialize(filename); // Validate the values Assert.NotNull(dat?.Machine); Assert.Equal(count, dat.Machine.Length); // Validate we're not missing any attributes or elements Assert.Null(dat.ADDITIONAL_ATTRIBUTES); Assert.Null(dat.ADDITIONAL_ELEMENTS); foreach (var machine in dat.Machine) { Assert.Null(machine.ADDITIONAL_ATTRIBUTES); Assert.Null(machine.ADDITIONAL_ELEMENTS); foreach (var biosset in machine.BiosSet ?? Array.Empty()) { Assert.Null(biosset.ADDITIONAL_ATTRIBUTES); Assert.Null(biosset.ADDITIONAL_ELEMENTS); } foreach (var rom in machine.Rom ?? Array.Empty()) { Assert.Null(rom.ADDITIONAL_ATTRIBUTES); Assert.Null(rom.ADDITIONAL_ELEMENTS); } foreach (var disk in machine.Disk ?? Array.Empty()) { Assert.Null(disk.ADDITIONAL_ATTRIBUTES); Assert.Null(disk.ADDITIONAL_ELEMENTS); } foreach (var deviceRef in machine.DeviceRef ?? Array.Empty()) { Assert.Null(deviceRef.ADDITIONAL_ATTRIBUTES); Assert.Null(deviceRef.ADDITIONAL_ELEMENTS); } foreach (var sample in machine.Sample ?? Array.Empty()) { Assert.Null(sample.ADDITIONAL_ATTRIBUTES); Assert.Null(sample.ADDITIONAL_ELEMENTS); } foreach (var chip in machine.Chip ?? Array.Empty()) { Assert.Null(chip.ADDITIONAL_ATTRIBUTES); Assert.Null(chip.ADDITIONAL_ELEMENTS); } foreach (var display in machine.Display ?? Array.Empty()) { Assert.Null(display.ADDITIONAL_ATTRIBUTES); Assert.Null(display.ADDITIONAL_ELEMENTS); } if (machine.Sound != null) { Assert.Null(machine.Sound.ADDITIONAL_ATTRIBUTES); Assert.Null(machine.Sound.ADDITIONAL_ELEMENTS); } if (machine.Input != null) { Assert.Null(machine.Input.ADDITIONAL_ATTRIBUTES); Assert.Null(machine.Input.ADDITIONAL_ELEMENTS); foreach (var control in machine.Input.Control ?? Array.Empty()) { Assert.Null(control.ADDITIONAL_ATTRIBUTES); Assert.Null(control.ADDITIONAL_ELEMENTS); } } foreach (var dipswitch in machine.DipSwitch ?? Array.Empty()) { Assert.Null(dipswitch.ADDITIONAL_ATTRIBUTES); Assert.Null(dipswitch.ADDITIONAL_ELEMENTS); if (dipswitch.Condition != null) { Assert.Null(dipswitch.Condition.ADDITIONAL_ATTRIBUTES); Assert.Null(dipswitch.Condition.ADDITIONAL_ELEMENTS); } foreach (var diplocation in dipswitch.DipLocation ?? Array.Empty()) { Assert.Null(diplocation.ADDITIONAL_ATTRIBUTES); Assert.Null(diplocation.ADDITIONAL_ELEMENTS); } foreach (var dipvalue in dipswitch.DipValue ?? Array.Empty()) { Assert.Null(dipvalue.ADDITIONAL_ATTRIBUTES); Assert.Null(dipvalue.ADDITIONAL_ELEMENTS); if (dipvalue.Condition != null) { Assert.Null(dipvalue.Condition.ADDITIONAL_ATTRIBUTES); Assert.Null(dipvalue.Condition.ADDITIONAL_ELEMENTS); } } } foreach (var configuration in machine.Configuration ?? Array.Empty()) { Assert.Null(configuration.ADDITIONAL_ATTRIBUTES); Assert.Null(configuration.ADDITIONAL_ELEMENTS); if (configuration.Condition != null) { Assert.Null(configuration.Condition.ADDITIONAL_ATTRIBUTES); Assert.Null(configuration.Condition.ADDITIONAL_ELEMENTS); } foreach (var conflocation in configuration.ConfLocation ?? Array.Empty()) { Assert.Null(conflocation.ADDITIONAL_ATTRIBUTES); Assert.Null(conflocation.ADDITIONAL_ELEMENTS); } foreach (var confsetting in configuration.ConfSetting ?? Array.Empty()) { Assert.Null(confsetting.ADDITIONAL_ATTRIBUTES); Assert.Null(confsetting.ADDITIONAL_ELEMENTS); if (confsetting.Condition != null) { Assert.Null(confsetting.Condition.ADDITIONAL_ATTRIBUTES); Assert.Null(confsetting.Condition.ADDITIONAL_ELEMENTS); } } } foreach (var port in machine.Port ?? Array.Empty()) { Assert.Null(port.ADDITIONAL_ATTRIBUTES); Assert.Null(port.ADDITIONAL_ELEMENTS); foreach (var analog in port.Analog ?? Array.Empty()) { Assert.Null(analog.ADDITIONAL_ATTRIBUTES); Assert.Null(analog.ADDITIONAL_ELEMENTS); } } foreach (var adjuster in machine.Adjuster ?? Array.Empty()) { Assert.Null(adjuster.ADDITIONAL_ATTRIBUTES); Assert.Null(adjuster.ADDITIONAL_ELEMENTS); if (adjuster.Condition != null) { Assert.Null(adjuster.Condition.ADDITIONAL_ATTRIBUTES); Assert.Null(adjuster.Condition.ADDITIONAL_ELEMENTS); } } if (machine.Driver != null) { Assert.Null(machine.Driver.ADDITIONAL_ATTRIBUTES); Assert.Null(machine.Driver.ADDITIONAL_ELEMENTS); } foreach (var feature in machine.Feature ?? Array.Empty()) { Assert.Null(feature.ADDITIONAL_ATTRIBUTES); Assert.Null(feature.ADDITIONAL_ELEMENTS); } foreach (var device in machine.Device ?? Array.Empty()) { Assert.Null(device.ADDITIONAL_ATTRIBUTES); Assert.Null(device.ADDITIONAL_ELEMENTS); if (device.Instance != null) { Assert.Null(device.Instance.ADDITIONAL_ATTRIBUTES); Assert.Null(device.Instance.ADDITIONAL_ELEMENTS); } foreach (var extension in device.Extension ?? Array.Empty()) { Assert.Null(extension.ADDITIONAL_ATTRIBUTES); Assert.Null(extension.ADDITIONAL_ELEMENTS); } } foreach (var slot in machine.Slot ?? Array.Empty()) { Assert.Null(slot.ADDITIONAL_ATTRIBUTES); Assert.Null(slot.ADDITIONAL_ELEMENTS); foreach (var slotoption in slot.SlotOption ?? Array.Empty()) { Assert.Null(slotoption.ADDITIONAL_ATTRIBUTES); Assert.Null(slotoption.ADDITIONAL_ELEMENTS); } } foreach (var softwarelist in machine.SoftwareList ?? Array.Empty()) { Assert.Null(softwarelist.ADDITIONAL_ATTRIBUTES); Assert.Null(softwarelist.ADDITIONAL_ELEMENTS); } foreach (var ramoption in machine.RamOption ?? Array.Empty()) { Assert.Null(ramoption.ADDITIONAL_ATTRIBUTES); Assert.Null(ramoption.ADDITIONAL_ELEMENTS); } } } [Theory] [InlineData("test-logiqx-files1.xml.gz", 45875)] [InlineData("test-logiqx-files2.xml", 761)] public void LogiqxDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.Logiqx.Deserialize(filename); // Validate the values Assert.NotNull(dat?.Game); Assert.Equal(count, dat.Game.Length); // Validate we're not missing any attributes or elements Assert.Null(dat.ADDITIONAL_ATTRIBUTES); Assert.Null(dat.ADDITIONAL_ELEMENTS); if (dat.Header != null) { var header = dat.Header; Assert.Null(header.ADDITIONAL_ATTRIBUTES); Assert.Null(header.ADDITIONAL_ELEMENTS); if (header.ClrMamePro != null) { var cmp = header.ClrMamePro; Assert.Null(cmp.ADDITIONAL_ATTRIBUTES); Assert.Null(cmp.ADDITIONAL_ELEMENTS); } if (header.RomCenter != null) { var rc = header.RomCenter; Assert.Null(rc.ADDITIONAL_ATTRIBUTES); Assert.Null(rc.ADDITIONAL_ELEMENTS); } } foreach (var game in dat.Game) { Assert.Null(game.ADDITIONAL_ATTRIBUTES); Assert.Null(game.ADDITIONAL_ELEMENTS); foreach (var item in game.Item ?? Array.Empty()) { Assert.Null(item.ADDITIONAL_ATTRIBUTES); Assert.Null(item.ADDITIONAL_ELEMENTS); } if (game.Trurip != null) { var trurip = game.Trurip; Assert.Null(trurip.ADDITIONAL_ATTRIBUTES); Assert.Null(trurip.ADDITIONAL_ELEMENTS); } } foreach (var dir in dat.Dir ?? Array.Empty()) { foreach (var game in dir.Game) { Assert.Null(game.ADDITIONAL_ATTRIBUTES); Assert.Null(game.ADDITIONAL_ELEMENTS); foreach (var item in game.Item ?? Array.Empty()) { Assert.Null(item.ADDITIONAL_ATTRIBUTES); Assert.Null(item.ADDITIONAL_ELEMENTS); } if (game.Trurip != null) { var trurip = game.Trurip; Assert.Null(trurip.ADDITIONAL_ATTRIBUTES); Assert.Null(trurip.ADDITIONAL_ELEMENTS); } } } } [Theory] [InlineData("test-offlinelist-files.xml", 6750)] public void OfflineListDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.OfflineList.Deserialize(filename); // Validate the values Assert.NotNull(dat?.Games?.Game); Assert.Equal(count, dat.Games.Game.Length); // Validate we're not missing any attributes or elements Assert.Null(dat.ADDITIONAL_ATTRIBUTES); Assert.Null(dat.ADDITIONAL_ELEMENTS); if (dat.Configuration != null) { var configuration = dat.Configuration; Assert.Null(configuration.ADDITIONAL_ATTRIBUTES); Assert.Null(configuration.ADDITIONAL_ELEMENTS); if (configuration.Infos != null) { var infos = configuration.Infos; Assert.Null(infos.ADDITIONAL_ATTRIBUTES); Assert.Null(infos.ADDITIONAL_ELEMENTS); if (infos.Title != null) { var title = infos.Title; Assert.Null(title.ADDITIONAL_ATTRIBUTES); Assert.Null(title.ADDITIONAL_ELEMENTS); } if (infos.Location != null) { var location = infos.Location; Assert.Null(location.ADDITIONAL_ATTRIBUTES); Assert.Null(location.ADDITIONAL_ELEMENTS); } if (infos.Publisher != null) { var publisher = infos.Publisher; Assert.Null(publisher.ADDITIONAL_ATTRIBUTES); Assert.Null(publisher.ADDITIONAL_ELEMENTS); } if (infos.SourceRom != null) { var sourceRom = infos.SourceRom; Assert.Null(sourceRom.ADDITIONAL_ATTRIBUTES); Assert.Null(sourceRom.ADDITIONAL_ELEMENTS); } if (infos.SaveType != null) { var saveType = infos.SaveType; Assert.Null(saveType.ADDITIONAL_ATTRIBUTES); Assert.Null(saveType.ADDITIONAL_ELEMENTS); } if (infos.RomSize != null) { var romSize = infos.RomSize; Assert.Null(romSize.ADDITIONAL_ATTRIBUTES); Assert.Null(romSize.ADDITIONAL_ELEMENTS); } if (infos.ReleaseNumber != null) { var releaseNumber = infos.ReleaseNumber; Assert.Null(releaseNumber.ADDITIONAL_ATTRIBUTES); Assert.Null(releaseNumber.ADDITIONAL_ELEMENTS); } if (infos.LanguageNumber != null) { var languageNumber = infos.LanguageNumber; Assert.Null(languageNumber.ADDITIONAL_ATTRIBUTES); Assert.Null(languageNumber.ADDITIONAL_ELEMENTS); } if (infos.Comment != null) { var comment = infos.Comment; Assert.Null(comment.ADDITIONAL_ATTRIBUTES); Assert.Null(comment.ADDITIONAL_ELEMENTS); } if (infos.RomCRC != null) { var romCRC = infos.RomCRC; Assert.Null(romCRC.ADDITIONAL_ATTRIBUTES); Assert.Null(romCRC.ADDITIONAL_ELEMENTS); } if (infos.Im1CRC != null) { var im1CRC = infos.Im1CRC; Assert.Null(im1CRC.ADDITIONAL_ATTRIBUTES); Assert.Null(im1CRC.ADDITIONAL_ELEMENTS); } if (infos.Im2CRC != null) { var im2CRC = infos.Im2CRC; Assert.Null(im2CRC.ADDITIONAL_ATTRIBUTES); Assert.Null(im2CRC.ADDITIONAL_ELEMENTS); } if (infos.Languages != null) { var languages = infos.Languages; Assert.Null(languages.ADDITIONAL_ATTRIBUTES); Assert.Null(languages.ADDITIONAL_ELEMENTS); } } if (configuration.CanOpen != null) { var canOpen = configuration.CanOpen; Assert.Null(canOpen.ADDITIONAL_ATTRIBUTES); Assert.Null(canOpen.ADDITIONAL_ELEMENTS); } if (configuration.NewDat != null) { var newDat = configuration.NewDat; Assert.Null(newDat.ADDITIONAL_ATTRIBUTES); Assert.Null(newDat.ADDITIONAL_ELEMENTS); if (newDat.DatUrl != null) { var datURL = newDat.DatUrl; Assert.Null(datURL.ADDITIONAL_ATTRIBUTES); Assert.Null(datURL.ADDITIONAL_ELEMENTS); } } if (configuration.Search != null) { var search = configuration.Search; Assert.Null(search.ADDITIONAL_ATTRIBUTES); Assert.Null(search.ADDITIONAL_ELEMENTS); foreach (var to in search.To ?? Array.Empty()) { Assert.Null(to.ADDITIONAL_ATTRIBUTES); Assert.Null(to.ADDITIONAL_ELEMENTS); foreach (var find in to.Find ?? Array.Empty()) { Assert.Null(find.ADDITIONAL_ATTRIBUTES); Assert.Null(find.ADDITIONAL_ELEMENTS); } } } } Assert.Null(dat.Games.ADDITIONAL_ATTRIBUTES); Assert.Null(dat.Games.ADDITIONAL_ELEMENTS); foreach (var game in dat.Games.Game) { Assert.Null(game.ADDITIONAL_ATTRIBUTES); Assert.Null(game.ADDITIONAL_ELEMENTS); if (game.Files != null) { var files = game.Files; Assert.Null(files.ADDITIONAL_ATTRIBUTES); Assert.Null(files.ADDITIONAL_ELEMENTS); foreach (var romCRC in files.RomCRC ?? Array.Empty()) { Assert.Null(romCRC.ADDITIONAL_ATTRIBUTES); Assert.Null(romCRC.ADDITIONAL_ELEMENTS); } } } if (dat.GUI != null) { var gui = dat.GUI; Assert.Null(gui.ADDITIONAL_ATTRIBUTES); Assert.Null(gui.ADDITIONAL_ELEMENTS); if (gui.Images != null) { var images = gui.Images; Assert.Null(images.ADDITIONAL_ATTRIBUTES); Assert.Null(images.ADDITIONAL_ELEMENTS); foreach (var image in images.Image ?? Array.Empty()) { Assert.Null(image.ADDITIONAL_ATTRIBUTES); Assert.Null(image.ADDITIONAL_ELEMENTS); } } } } [Theory] [InlineData("test-openmsx-files.xml", 2550)] public void OpenMSXDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.OpenMSX.Deserialize(filename); // Validate the values Assert.NotNull(dat); Assert.NotNull(dat.Software); Assert.Equal(count, dat.Software.Length); // Validate we're not missing any attributes or elements Assert.Null(dat.ADDITIONAL_ATTRIBUTES); Assert.Null(dat.ADDITIONAL_ELEMENTS); foreach (var software in dat.Software) { Assert.Null(software.ADDITIONAL_ATTRIBUTES); Assert.Null(software.ADDITIONAL_ELEMENTS); foreach (var dump in software.Dump ?? Array.Empty()) { Assert.Null(dump.ADDITIONAL_ATTRIBUTES); Assert.Null(dump.ADDITIONAL_ELEMENTS); if (dump.Original != null) { Assert.Null(dump.Original.ADDITIONAL_ATTRIBUTES); Assert.Null(dump.Original.ADDITIONAL_ELEMENTS); } if (dump.Rom != null) { Assert.Null(dump.Rom.ADDITIONAL_ATTRIBUTES); Assert.Null(dump.Rom.ADDITIONAL_ELEMENTS); } } } } [Theory] [InlineData("test-romcenter-files.dat", 901)] public void RomCenterDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.RomCenter.Deserialize(filename); // Validate the values Assert.NotNull(dat?.Games?.Rom); Assert.Equal(count, dat.Games.Rom.Length); // Validate we're not missing any attributes or elements Assert.Empty(dat.ADDITIONAL_ELEMENTS); if (dat.Credits != null) Assert.Empty(dat.Credits.ADDITIONAL_ELEMENTS); if (dat.Dat != null) Assert.Empty(dat.Dat.ADDITIONAL_ELEMENTS); if (dat.Emulator != null) Assert.Empty(dat.Emulator.ADDITIONAL_ELEMENTS); if (dat.Games != null) { Assert.Empty(dat.Games.ADDITIONAL_ELEMENTS); foreach (var rom in dat.Games.Rom ?? Array.Empty()) { Assert.Null(rom.ADDITIONAL_ELEMENTS); } } } [Theory] [InlineData("test-softwarelist-files1.xml", 4531)] [InlineData("test-softwarelist-files2.xml", 2797)] [InlineData("test-softwarelist-files3.xml", 274)] public void SoftwareListDeserializeTest(string path, long count) { // Open the file for reading string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path); // Deserialize the file var dat = Serialization.SoftawreList.Deserialize(filename); // Validate the values Assert.NotNull(dat); Assert.NotNull(dat.Software); Assert.Equal(count, dat.Software.Length); // Validate we're not missing any attributes or elements Assert.Null(dat.ADDITIONAL_ATTRIBUTES); Assert.Null(dat.ADDITIONAL_ELEMENTS); foreach (var software in dat.Software) { Assert.Null(software.ADDITIONAL_ATTRIBUTES); Assert.Null(software.ADDITIONAL_ELEMENTS); foreach (var info in software.Info ?? Array.Empty()) { Assert.Null(info.ADDITIONAL_ATTRIBUTES); Assert.Null(info.ADDITIONAL_ELEMENTS); } foreach (var sharedfeat in software.SharedFeat ?? Array.Empty()) { Assert.Null(sharedfeat.ADDITIONAL_ATTRIBUTES); Assert.Null(sharedfeat.ADDITIONAL_ELEMENTS); } foreach (var part in software.Part ?? Array.Empty()) { Assert.Null(part.ADDITIONAL_ATTRIBUTES); Assert.Null(part.ADDITIONAL_ELEMENTS); foreach (var feature in part.Feature ?? Array.Empty()) { Assert.Null(feature.ADDITIONAL_ATTRIBUTES); Assert.Null(feature.ADDITIONAL_ELEMENTS); } foreach (var dataarea in part.DataArea ?? Array.Empty()) { Assert.Null(dataarea.ADDITIONAL_ATTRIBUTES); Assert.Null(dataarea.ADDITIONAL_ELEMENTS); foreach (var rom in dataarea.Rom ?? Array.Empty()) { Assert.Null(rom.ADDITIONAL_ATTRIBUTES); Assert.Null(rom.ADDITIONAL_ELEMENTS); } } foreach (var diskarea in part.DiskArea ?? Array.Empty()) { Assert.Null(diskarea.ADDITIONAL_ATTRIBUTES); Assert.Null(diskarea.ADDITIONAL_ELEMENTS); foreach (var disk in diskarea.Disk ?? Array.Empty()) { Assert.Null(disk.ADDITIONAL_ATTRIBUTES); Assert.Null(disk.ADDITIONAL_ELEMENTS); } } foreach (var dipswitch in part.DipSwitch ?? Array.Empty()) { Assert.Null(dipswitch.ADDITIONAL_ATTRIBUTES); Assert.Null(dipswitch.ADDITIONAL_ELEMENTS); foreach (var dipvalue in dipswitch.DipValue ?? Array.Empty()) { Assert.Null(dipvalue.ADDITIONAL_ATTRIBUTES); Assert.Null(dipvalue.ADDITIONAL_ELEMENTS); } } } } } } }