Files

873 lines
29 KiB
C#
Raw Permalink Normal View History

2025-07-24 09:36:37 -04:00
using Xunit;
namespace SabreTools.Serialization.CrossModel.Test
2025-07-24 09:36:37 -04:00
{
public class MessTests
{
[Fact]
public void RoundTripGameTest()
{
// Get the cross-model serializer
2025-09-26 10:20:48 -04:00
var serializer = new Mess();
2025-07-24 09:36:37 -04:00
// Build the data
2025-09-26 13:06:18 -04:00
Data.Models.Listxml.Mess m1 = Build(game: true);
2025-07-24 09:36:37 -04:00
// Serialize to generic model
2025-09-26 13:06:18 -04:00
Data.Models.Metadata.MetadataFile? metadata = serializer.Serialize(m1);
2025-07-24 09:36:37 -04:00
Assert.NotNull(metadata);
// Serialize back to original model
2025-09-26 13:06:18 -04:00
Data.Models.Listxml.Mess? newMess = serializer.Deserialize(metadata);
2025-07-24 09:36:37 -04:00
// Validate the data
Assert.NotNull(newMess);
Assert.Equal("version", newMess.Version);
2025-07-24 09:36:37 -04:00
Assert.NotNull(newMess.Game);
var newGame = Assert.Single(newMess.Game);
Validate(newGame);
}
[Fact]
public void RoundTripMachineTest()
{
// Get the cross-model serializer
2025-09-26 10:20:48 -04:00
var serializer = new Mess();
2025-07-24 09:36:37 -04:00
// Build the data
2025-09-26 13:06:18 -04:00
Data.Models.Listxml.Mess m1 = Build(game: false);
2025-07-24 09:36:37 -04:00
// Serialize to generic model
2025-09-26 13:06:18 -04:00
Data.Models.Metadata.MetadataFile? metadata = serializer.Serialize(m1);
2025-07-24 09:36:37 -04:00
Assert.NotNull(metadata);
// Serialize back to original model
2025-09-26 13:06:18 -04:00
Data.Models.Listxml.Mess? newMess = serializer.Deserialize(metadata);
2025-07-24 09:36:37 -04:00
// Validate the data
Assert.NotNull(newMess);
Assert.Equal("version", newMess.Version);
2025-07-24 09:36:37 -04:00
Assert.NotNull(newMess.Game);
var newGame = Assert.Single(newMess.Game);
Validate(newGame);
}
/// <summary>
/// Build model for serialization and deserialization
/// </summary>
2025-09-26 13:06:18 -04:00
private static Data.Models.Listxml.Mess Build(bool game)
2025-07-24 09:36:37 -04:00
{
2025-09-26 13:06:18 -04:00
var biosset = new Data.Models.Listxml.BiosSet
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-02 11:18:49 -04:00
Description = "description",
2026-04-01 16:52:55 -04:00
Default = true,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var rom = new Data.Models.Listxml.Rom
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
Bios = "bios",
Size = 12345,
CRC = "crc32",
SHA1 = "sha1",
Merge = "merge",
Region = "region",
Offset = "offset",
2026-04-02 02:18:08 -04:00
Status = Data.Models.Metadata.ItemStatus.Good,
2026-04-01 21:59:16 -04:00
Optional = true,
Dispose = true,
SoundOnly = true,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var disk = new Data.Models.Listxml.Disk
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-04 01:15:40 -04:00
MD5 = "md5",
SHA1 = "sha1",
Merge = "merge",
Region = "region",
Index = 12345,
2026-04-01 21:59:16 -04:00
Writable = true,
2026-04-02 02:18:08 -04:00
Status = Data.Models.Metadata.ItemStatus.Good,
2026-04-01 21:59:16 -04:00
Optional = true,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var deviceref = new Data.Models.Listxml.DeviceRef
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var sample = new Data.Models.Listxml.Sample
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var chip = new Data.Models.Listxml.Chip
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-02 11:18:49 -04:00
Tag = "tag",
2026-04-02 02:18:08 -04:00
Type = Data.Models.Metadata.ChipType.CPU,
2026-04-01 21:59:16 -04:00
SoundOnly = true,
2026-04-03 10:26:20 -04:00
Clock = 12345,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var display = new Data.Models.Listxml.Display
2025-07-24 09:36:37 -04:00
{
2026-04-02 11:18:49 -04:00
Tag = "tag",
2026-04-02 02:18:08 -04:00
Type = Data.Models.Metadata.DisplayType.Vector,
Rotate = Data.Models.Metadata.Rotation.East,
2026-04-01 21:59:16 -04:00
FlipX = true,
Width = 12345,
Height = 12345,
Refresh = 123.45,
PixClock = 12345,
HTotal = 12345,
HBEnd = 12345,
HBStart = 12345,
VTotal = 12345,
VBEnd = 12345,
VBStart = 12345,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var video = new Data.Models.Listxml.Video
2025-07-24 09:36:37 -04:00
{
2026-04-02 02:18:08 -04:00
Screen = Data.Models.Metadata.DisplayType.Vector,
Orientation = Data.Models.Metadata.Rotation.East,
Width = 12345,
Height = 12345,
AspectX = 12345,
AspectY = 12345,
Refresh = 123.45,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var sound = new Data.Models.Listxml.Sound
2025-07-24 09:36:37 -04:00
{
Channels = 12345,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var control = new Data.Models.Listxml.Control
2025-07-24 09:36:37 -04:00
{
2026-04-02 02:18:08 -04:00
Type = Data.Models.Metadata.ControlType.Lightgun,
Player = 12345,
Buttons = 12345,
ReqButtons = 12345,
Minimum = 12345,
Maximum = 12345,
Sensitivity = 12345,
KeyDelta = 12345,
2026-04-01 21:59:16 -04:00
Reverse = true,
Ways = "ways",
Ways2 = "ways2",
Ways3 = "ways3",
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var input = new Data.Models.Listxml.Input
2025-07-24 09:36:37 -04:00
{
2026-04-01 21:59:16 -04:00
Service = true,
Tilt = true,
Players = 12345,
ControlAttr = "controlattr",
Buttons = 12345,
Coins = 12345,
2025-07-24 09:36:37 -04:00
Control = [control],
};
2025-09-26 13:06:18 -04:00
var condition = new Data.Models.Listxml.Condition
2025-07-24 09:36:37 -04:00
{
2026-04-02 11:18:49 -04:00
Tag = "tag",
Mask = "mask",
2026-04-02 02:18:08 -04:00
Relation = Data.Models.Metadata.Relation.Equal,
2026-04-02 11:18:49 -04:00
Value = "value",
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var diplocation = new Data.Models.Listxml.DipLocation
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
Number = 12345,
2026-04-01 21:59:16 -04:00
Inverted = true,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var dipvalue = new Data.Models.Listxml.DipValue
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-02 11:18:49 -04:00
Value = "value",
2026-04-01 16:52:55 -04:00
Default = true,
2025-07-24 09:36:37 -04:00
Condition = condition,
};
2025-09-26 13:06:18 -04:00
var dipswitch = new Data.Models.Listxml.DipSwitch
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-02 11:18:49 -04:00
Tag = "tag",
Mask = "mask",
2025-07-24 09:36:37 -04:00
Condition = condition,
DipLocation = [diplocation],
DipValue = [dipvalue],
};
2025-09-26 13:06:18 -04:00
var conflocation = new Data.Models.Listxml.ConfLocation
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
Number = 12345,
2026-04-01 21:59:16 -04:00
Inverted = true,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var confsetting = new Data.Models.Listxml.ConfSetting
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-02 11:18:49 -04:00
Value = "value",
2026-04-01 16:52:55 -04:00
Default = true,
2025-07-24 09:36:37 -04:00
Condition = condition,
};
2025-09-26 13:06:18 -04:00
var configuration = new Data.Models.Listxml.Configuration
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-02 11:18:49 -04:00
Tag = "tag",
Mask = "mask",
2025-07-24 09:36:37 -04:00
Condition = condition,
ConfLocation = [conflocation],
ConfSetting = [confsetting],
};
2025-09-26 13:06:18 -04:00
var analog = new Data.Models.Listxml.Analog
2025-07-24 09:36:37 -04:00
{
2026-04-02 11:18:49 -04:00
Mask = "mask",
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var port = new Data.Models.Listxml.Port
2025-07-24 09:36:37 -04:00
{
2026-04-02 11:18:49 -04:00
Tag = "tag",
2025-07-24 09:36:37 -04:00
Analog = [analog],
};
2025-09-26 13:06:18 -04:00
var adjuster = new Data.Models.Listxml.Adjuster
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-01 16:52:55 -04:00
Default = true,
2025-07-24 09:36:37 -04:00
Condition = condition,
};
2025-09-26 13:06:18 -04:00
var driver = new Data.Models.Listxml.Driver
2025-07-24 09:36:37 -04:00
{
2026-04-02 02:18:08 -04:00
Status = Data.Models.Metadata.SupportStatus.Good,
Color = Data.Models.Metadata.SupportStatus.Good,
Sound = Data.Models.Metadata.SupportStatus.Good,
PaletteSize = "palettesize",
2026-04-02 02:18:08 -04:00
Emulation = Data.Models.Metadata.SupportStatus.Good,
Cocktail = Data.Models.Metadata.SupportStatus.Good,
SaveState = Data.Models.Metadata.Supported.Yes,
2026-04-01 21:59:16 -04:00
RequiresArtwork = true,
Unofficial = true,
NoSoundHardware = true,
Incomplete = true,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var feature = new Data.Models.Listxml.Feature
2025-07-24 09:36:37 -04:00
{
2026-04-02 02:18:08 -04:00
Type = Data.Models.Metadata.FeatureType.Protection,
Status = Data.Models.Metadata.FeatureStatus.Imperfect,
Overall = Data.Models.Metadata.FeatureStatus.Imperfect,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var instance = new Data.Models.Listxml.Instance
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-02 14:28:46 -04:00
BriefName = "briefname",
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var extension = new Data.Models.Listxml.Extension
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var device = new Data.Models.Listxml.Device
2025-07-24 09:36:37 -04:00
{
2026-04-02 02:18:08 -04:00
Type = Data.Models.Metadata.DeviceType.PunchTape,
2026-04-02 11:18:49 -04:00
Tag = "tag",
2026-04-02 14:28:46 -04:00
FixedImage = "fixedimage",
Mandatory = true,
2026-04-02 14:28:46 -04:00
Interface = "interface",
2025-07-24 09:36:37 -04:00
Instance = instance,
Extension = [extension],
};
2025-09-26 13:06:18 -04:00
var slotOption = new Data.Models.Listxml.SlotOption
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-02 14:28:46 -04:00
DevName = "devname",
2026-04-01 16:52:55 -04:00
Default = true,
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var slot = new Data.Models.Listxml.Slot
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2025-07-24 09:36:37 -04:00
SlotOption = [slotOption],
};
2025-09-26 13:06:18 -04:00
var softwarelist = new Data.Models.Listxml.SoftwareList
2025-07-24 09:36:37 -04:00
{
2026-04-02 11:18:49 -04:00
Tag = "tag",
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-02 02:18:08 -04:00
Status = Data.Models.Metadata.SoftwareListStatus.Original,
Filter = "filter",
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
var ramoption = new Data.Models.Listxml.RamOption
2025-07-24 09:36:37 -04:00
{
2026-04-02 13:21:37 -04:00
Name = "name",
2026-04-01 16:52:55 -04:00
Default = true,
2026-04-02 14:28:46 -04:00
Content = "content",
2025-07-24 09:36:37 -04:00
};
2025-09-26 13:06:18 -04:00
Data.Models.Listxml.GameBase gameBase = game
? new Data.Models.Listxml.Game()
: new Data.Models.Listxml.Machine();
2026-04-02 13:21:37 -04:00
gameBase.Name = "name";
gameBase.SourceFile = "sourcefile";
2026-04-01 21:59:16 -04:00
gameBase.IsBios = true;
gameBase.IsDevice = true;
gameBase.IsMechanical = true;
2026-04-01 22:06:24 -04:00
gameBase.Runnable = Data.Models.Metadata.Runnable.Yes;
gameBase.CloneOf = "cloneof";
gameBase.RomOf = "romof";
gameBase.SampleOf = "sampleof";
2026-04-02 11:18:49 -04:00
gameBase.Description = "description";
gameBase.Year = "year";
gameBase.Manufacturer = "manufacturer";
gameBase.History = "history";
2025-07-24 09:36:37 -04:00
gameBase.BiosSet = [biosset];
gameBase.Rom = [rom];
gameBase.Disk = [disk];
gameBase.DeviceRef = [deviceref];
gameBase.Sample = [sample];
gameBase.Chip = [chip];
gameBase.Display = [display];
gameBase.Video = [video];
gameBase.Sound = sound;
gameBase.Input = input;
gameBase.DipSwitch = [dipswitch];
gameBase.Configuration = [configuration];
gameBase.Port = [port];
gameBase.Adjuster = [adjuster];
gameBase.Driver = driver;
gameBase.Feature = [feature];
gameBase.Device = [device];
gameBase.Slot = [slot];
gameBase.SoftwareList = [softwarelist];
gameBase.RamOption = [ramoption];
2025-09-26 13:06:18 -04:00
return new Data.Models.Listxml.Mess
2025-07-24 09:36:37 -04:00
{
Version = "version",
2025-07-24 09:36:37 -04:00
Game = [gameBase],
};
}
/// <summary>
/// Validate a GameBase
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.GameBase? gb)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(gb);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", gb.Name);
Assert.Equal("sourcefile", gb.SourceFile);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, gb.IsBios);
Assert.Equal(true, gb.IsDevice);
Assert.Equal(true, gb.IsMechanical);
2026-04-01 22:06:24 -04:00
Assert.Equal(Data.Models.Metadata.Runnable.Yes, gb.Runnable);
Assert.Equal("cloneof", gb.CloneOf);
Assert.Equal("romof", gb.RomOf);
Assert.Equal("sampleof", gb.SampleOf);
2026-04-02 11:18:49 -04:00
Assert.Equal("description", gb.Description);
Assert.Equal("year", gb.Year);
Assert.Equal("manufacturer", gb.Manufacturer);
Assert.Equal("history", gb.History);
2025-07-24 09:36:37 -04:00
Assert.NotNull(gb.BiosSet);
var biosset = Assert.Single(gb.BiosSet);
Validate(biosset);
Assert.NotNull(gb.Rom);
var rom = Assert.Single(gb.Rom);
Validate(rom);
Assert.NotNull(gb.Disk);
var disk = Assert.Single(gb.Disk);
Validate(disk);
Assert.NotNull(gb.DeviceRef);
var deviceref = Assert.Single(gb.DeviceRef);
Validate(deviceref);
Assert.NotNull(gb.Sample);
var sample = Assert.Single(gb.Sample);
Validate(sample);
Assert.NotNull(gb.Chip);
var chip = Assert.Single(gb.Chip);
Validate(chip);
Assert.NotNull(gb.Display);
var display = Assert.Single(gb.Display);
Validate(display);
Assert.NotNull(gb.Video);
var video = Assert.Single(gb.Video);
Validate(video);
Validate(gb.Sound);
Validate(gb.Input);
Assert.NotNull(gb.DipSwitch);
var dipswitch = Assert.Single(gb.DipSwitch);
Validate(dipswitch);
Assert.NotNull(gb.Configuration);
var configuration = Assert.Single(gb.Configuration);
Validate(configuration);
Assert.NotNull(gb.Port);
var port = Assert.Single(gb.Port);
Validate(port);
Assert.NotNull(gb.Adjuster);
var adjuster = Assert.Single(gb.Adjuster);
Validate(adjuster);
Validate(gb.Driver);
Assert.NotNull(gb.Feature);
var feature = Assert.Single(gb.Feature);
Validate(feature);
Assert.NotNull(gb.Device);
var device = Assert.Single(gb.Device);
Validate(device);
Assert.NotNull(gb.Slot);
var slot = Assert.Single(gb.Slot);
Validate(slot);
Assert.NotNull(gb.SoftwareList);
var softwarelist = Assert.Single(gb.SoftwareList);
Validate(softwarelist);
Assert.NotNull(gb.RamOption);
var ramoption = Assert.Single(gb.RamOption);
Validate(ramoption);
}
/// <summary>
/// Validate a BiosSet
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.BiosSet? biosset)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(biosset);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", biosset.Name);
2026-04-02 11:18:49 -04:00
Assert.Equal("description", biosset.Description);
2026-04-01 16:52:55 -04:00
Assert.Equal(true, biosset.Default);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Rom
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Rom? rom)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(rom);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", rom.Name);
Assert.Equal("bios", rom.Bios);
Assert.Equal(12345, rom.Size);
Assert.Equal("crc32", rom.CRC);
Assert.Equal("sha1", rom.SHA1);
Assert.Equal("merge", rom.Merge);
Assert.Equal("region", rom.Region);
Assert.Equal("offset", rom.Offset);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.ItemStatus.Good, rom.Status);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, rom.Optional);
Assert.Equal(true, rom.Dispose);
Assert.Equal(true, rom.SoundOnly);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Disk
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Disk? disk)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(disk);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", disk.Name);
2026-04-04 01:15:40 -04:00
Assert.Equal("md5", disk.MD5);
Assert.Equal("sha1", disk.SHA1);
Assert.Equal("merge", disk.Merge);
Assert.Equal("region", disk.Region);
Assert.Equal(12345, disk.Index);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, disk.Writable);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.ItemStatus.Good, disk.Status);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, disk.Optional);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a DeviceRef
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.DeviceRef? deviceref)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(deviceref);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", deviceref.Name);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Sample
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Sample? sample)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(sample);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", sample.Name);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Chip
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Chip? chip)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(chip);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", chip.Name);
2026-04-02 11:18:49 -04:00
Assert.Equal("tag", chip.Tag);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.ChipType.CPU, chip.Type);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, chip.SoundOnly);
2026-04-03 10:26:20 -04:00
Assert.Equal(12345, chip.Clock);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Display
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Display? display)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(display);
2026-04-02 11:18:49 -04:00
Assert.Equal("tag", display.Tag);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.DisplayType.Vector, display.Type);
Assert.Equal(Data.Models.Metadata.Rotation.East, display.Rotate);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, display.FlipX);
Assert.Equal(12345, display.Width);
Assert.Equal(12345, display.Height);
Assert.Equal(123.45, display.Refresh);
Assert.Equal(12345, display.PixClock);
Assert.Equal(12345, display.HTotal);
Assert.Equal(12345, display.HBEnd);
Assert.Equal(12345, display.HBStart);
Assert.Equal(12345, display.VTotal);
Assert.Equal(12345, display.VBEnd);
Assert.Equal(12345, display.VBStart);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Video
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Video? video)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(video);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.DisplayType.Vector, video.Screen);
Assert.Equal(Data.Models.Metadata.Rotation.East, video.Orientation);
Assert.Equal(12345, video.Width);
Assert.Equal(12345, video.Height);
Assert.Equal(12345, video.AspectX);
Assert.Equal(12345, video.AspectY);
Assert.Equal(123.45, video.Refresh);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Sound
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Sound? sound)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(sound);
Assert.Equal(12345, sound.Channels);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Input
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Input? input)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(input);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, input.Service);
Assert.Equal(true, input.Tilt);
Assert.Equal(12345, input.Players);
Assert.Equal("controlattr", input.ControlAttr);
Assert.Equal(12345, input.Buttons);
Assert.Equal(12345, input.Coins);
2025-07-24 09:36:37 -04:00
Assert.NotNull(input.Control);
var control = Assert.Single(input.Control);
Validate(control);
}
/// <summary>
/// Validate a Control
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Control? control)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(control);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.ControlType.Lightgun, control.Type);
Assert.Equal(12345, control.Player);
Assert.Equal(12345, control.Buttons);
Assert.Equal(12345, control.ReqButtons);
Assert.Equal(12345, control.Minimum);
Assert.Equal(12345, control.Maximum);
Assert.Equal(12345, control.Sensitivity);
Assert.Equal(12345, control.KeyDelta);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, control.Reverse);
Assert.Equal("ways", control.Ways);
Assert.Equal("ways2", control.Ways2);
Assert.Equal("ways3", control.Ways3);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a DipSwitch
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.DipSwitch? dipswitch)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(dipswitch);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", dipswitch.Name);
2026-04-02 11:18:49 -04:00
Assert.Equal("tag", dipswitch.Tag);
Assert.Equal("mask", dipswitch.Mask);
2025-07-24 09:36:37 -04:00
Validate(dipswitch.Condition);
Assert.NotNull(dipswitch.DipLocation);
var diplocation = Assert.Single(dipswitch.DipLocation);
Validate(diplocation);
Assert.NotNull(dipswitch.DipValue);
var dipvalue = Assert.Single(dipswitch.DipValue);
Validate(dipvalue);
}
/// <summary>
/// Validate a Condition
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Condition? condition)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(condition);
2026-04-02 11:18:49 -04:00
Assert.Equal("tag", condition.Tag);
Assert.Equal("mask", condition.Mask);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.Relation.Equal, condition.Relation);
2026-04-02 11:18:49 -04:00
Assert.Equal("value", condition.Value);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a DipLocation
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.DipLocation? diplocation)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(diplocation);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", diplocation.Name);
Assert.Equal(12345, diplocation.Number);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, diplocation.Inverted);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a DipValue
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.DipValue? dipvalue)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(dipvalue);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", dipvalue.Name);
2026-04-02 11:18:49 -04:00
Assert.Equal("value", dipvalue.Value);
2026-04-01 16:52:55 -04:00
Assert.Equal(true, dipvalue.Default);
2025-07-24 09:36:37 -04:00
Validate(dipvalue.Condition);
}
/// <summary>
/// Validate a Configuration
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Configuration? configuration)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(configuration);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", configuration.Name);
2026-04-02 11:18:49 -04:00
Assert.Equal("tag", configuration.Tag);
Assert.Equal("mask", configuration.Mask);
2025-07-24 09:36:37 -04:00
Validate(configuration.Condition);
Assert.NotNull(configuration.ConfLocation);
var conflocation = Assert.Single(configuration.ConfLocation);
Validate(conflocation);
Assert.NotNull(configuration.ConfSetting);
var confsetting = Assert.Single(configuration.ConfSetting);
Validate(confsetting);
}
/// <summary>
/// Validate a ConfLocation
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.ConfLocation? conflocation)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(conflocation);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", conflocation.Name);
Assert.Equal(12345, conflocation.Number);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, conflocation.Inverted);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a ConfSetting
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.ConfSetting? confsetting)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(confsetting);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", confsetting.Name);
2026-04-02 11:18:49 -04:00
Assert.Equal("value", confsetting.Value);
2026-04-01 16:52:55 -04:00
Assert.Equal(true, confsetting.Default);
2025-07-24 09:36:37 -04:00
Validate(confsetting.Condition);
}
/// <summary>
/// Validate a Port
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Port? port)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(port);
2026-04-02 11:18:49 -04:00
Assert.Equal("tag", port.Tag);
2025-07-24 09:36:37 -04:00
Assert.NotNull(port.Analog);
var analog = Assert.Single(port.Analog);
Validate(analog);
}
/// <summary>
/// Validate a Analog
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Analog? analog)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(analog);
2026-04-02 11:18:49 -04:00
Assert.Equal("mask", analog.Mask);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Adjuster
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Adjuster? adjuster)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(adjuster);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", adjuster.Name);
2026-04-01 16:52:55 -04:00
Assert.Equal(true, adjuster.Default);
2025-07-24 09:36:37 -04:00
Validate(adjuster.Condition);
}
/// <summary>
/// Validate a Driver
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Driver? driver)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(driver);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.SupportStatus.Good, driver.Status);
Assert.Equal(Data.Models.Metadata.SupportStatus.Good, driver.Color);
Assert.Equal(Data.Models.Metadata.SupportStatus.Good, driver.Sound);
Assert.Equal("palettesize", driver.PaletteSize);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.SupportStatus.Good, driver.Emulation);
Assert.Equal(Data.Models.Metadata.SupportStatus.Good, driver.Cocktail);
Assert.Equal(Data.Models.Metadata.Supported.Yes, driver.SaveState);
2026-04-01 21:59:16 -04:00
Assert.Equal(true, driver.RequiresArtwork);
Assert.Equal(true, driver.Unofficial);
Assert.Equal(true, driver.NoSoundHardware);
Assert.Equal(true, driver.Incomplete);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Feature
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Feature? feature)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(feature);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.FeatureType.Protection, feature.Type);
Assert.Equal(Data.Models.Metadata.FeatureStatus.Imperfect, feature.Status);
Assert.Equal(Data.Models.Metadata.FeatureStatus.Imperfect, feature.Overall);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Device
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Device? device)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(device);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.DeviceType.PunchTape, device.Type);
2026-04-02 11:18:49 -04:00
Assert.Equal("tag", device.Tag);
2026-04-02 14:28:46 -04:00
Assert.Equal("fixedimage", device.FixedImage);
Assert.Equal(true, device.Mandatory);
2026-04-02 14:28:46 -04:00
Assert.Equal("interface", device.Interface);
2025-07-24 09:36:37 -04:00
Validate(device.Instance);
Assert.NotNull(device.Extension);
var extension = Assert.Single(device.Extension);
Validate(extension);
}
/// <summary>
/// Validate a Instance
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Instance? instance)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(instance);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", instance.Name);
2026-04-02 14:28:46 -04:00
Assert.Equal("briefname", instance.BriefName);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Extension
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Extension? extension)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(extension);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", extension.Name);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a Slot
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.Slot? slot)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(slot);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", slot.Name);
2025-07-24 09:36:37 -04:00
Assert.NotNull(slot.SlotOption);
var slotoption = Assert.Single(slot.SlotOption);
Validate(slotoption);
}
/// <summary>
/// Validate a SlotOption
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.SlotOption? slotoption)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(slotoption);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", slotoption.Name);
2026-04-02 14:28:46 -04:00
Assert.Equal("devname", slotoption.DevName);
2026-04-01 16:52:55 -04:00
Assert.Equal(true, slotoption.Default);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a SoftwareList
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.SoftwareList? softwarelist)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(softwarelist);
2026-04-02 11:18:49 -04:00
Assert.Equal("tag", softwarelist.Tag);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", softwarelist.Name);
2026-04-02 02:18:08 -04:00
Assert.Equal(Data.Models.Metadata.SoftwareListStatus.Original, softwarelist.Status);
Assert.Equal("filter", softwarelist.Filter);
2025-07-24 09:36:37 -04:00
}
/// <summary>
/// Validate a RamOption
/// </summary>
2025-09-26 13:06:18 -04:00
private static void Validate(Data.Models.Listxml.RamOption? ramoption)
2025-07-24 09:36:37 -04:00
{
Assert.NotNull(ramoption);
2026-04-02 13:21:37 -04:00
Assert.Equal("name", ramoption.Name);
2026-04-01 16:52:55 -04:00
Assert.Equal(true, ramoption.Default);
2026-04-02 14:28:46 -04:00
Assert.Equal("content", ramoption.Content);
2025-07-24 09:36:37 -04:00
}
}
2025-11-14 09:06:59 -05:00
}