mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix tests, migrate Adjuster
This commit is contained in:
@@ -169,11 +169,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(name);
|
||||
|
||||
|
||||
@@ -95,11 +95,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
AltTitle = row.AltTitle,
|
||||
// TODO: Add extended fields
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName("-");
|
||||
|
||||
|
||||
@@ -140,11 +140,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var blank = new Blank
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
@@ -177,11 +173,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Date = release.Date,
|
||||
Default = release.Default?.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(release.Name);
|
||||
|
||||
@@ -213,11 +205,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Description = biosset.Description,
|
||||
Default = biosset.Default?.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(biosset.Name);
|
||||
|
||||
@@ -267,11 +255,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Inverted = rom.Inverted?.AsYesNo(),
|
||||
MIA = rom.MIA?.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(rom.Name);
|
||||
|
||||
@@ -306,11 +290,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
ItemStatus = disk.Status?.AsEnumValue<ItemStatus>() ?? ItemStatus.NULL,
|
||||
//Flags = disk.Flags, // TODO: Add to internal model
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(disk.Name);
|
||||
|
||||
@@ -344,11 +324,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA256 = medium.SHA256,
|
||||
SpamSum = medium.SpamSum,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(medium.Name);
|
||||
|
||||
@@ -377,11 +353,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var item = new Archive
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(archive.Name);
|
||||
|
||||
@@ -414,11 +386,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
//Flags = chip.Flags, // TODO: Add to internal model
|
||||
Clock = NumberHelper.ConvertToInt64(chip.Clock),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(chip.Name);
|
||||
|
||||
@@ -454,11 +422,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
//AspectY = video.AspectY, // TODO: Add to internal model or find mapping
|
||||
Refresh = NumberHelper.ConvertToDouble(video.Freq),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
switch (video.Orientation)
|
||||
@@ -496,11 +460,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
Channels = NumberHelper.ConvertToInt64(sound.Channels),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
@@ -538,11 +498,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Tilt = input.Tilt?.AsYesNo(),
|
||||
Service = input.Service?.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
@@ -571,11 +527,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
Values = [],
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(dipswitch.Name);
|
||||
|
||||
@@ -620,11 +572,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
//PaletteSize = driver.PaletteSize, // TODO: Add to internal model or find mapping
|
||||
//Blit = driver.Blit, // TODO: Add to internal model or find mapping
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
|
||||
@@ -109,11 +109,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var blank = new Blank
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
@@ -145,11 +141,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
CRC = rom.CRC,
|
||||
Date = rom.Date,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(rom.Name);
|
||||
|
||||
|
||||
@@ -107,11 +107,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA256 = row.SHA256,
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(name);
|
||||
|
||||
|
||||
@@ -149,11 +149,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Size = null,
|
||||
CRC = sfv.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(itemName);
|
||||
|
||||
@@ -200,11 +196,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
MD5 = md5.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
disk.SetName(itemName);
|
||||
|
||||
@@ -217,11 +209,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
MD5 = md5.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
media.SetName(itemName);
|
||||
|
||||
@@ -235,11 +223,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Size = null,
|
||||
MD5 = md5.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(itemName);
|
||||
|
||||
@@ -286,11 +270,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
SHA1 = sha1.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
disk.SetName(itemName);
|
||||
|
||||
@@ -303,11 +283,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
SHA1 = sha1.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
media.SetName(itemName);
|
||||
|
||||
@@ -321,11 +297,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Size = null,
|
||||
SHA1 = sha1.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(itemName);
|
||||
|
||||
@@ -372,11 +344,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
SHA256 = sha256.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
media.SetName(itemName);
|
||||
|
||||
@@ -391,11 +359,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Size = null,
|
||||
SHA256 = sha256.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(itemName);
|
||||
|
||||
@@ -445,11 +409,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Size = null,
|
||||
SHA384 = sha384.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(itemName);
|
||||
|
||||
@@ -499,11 +459,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Size = null,
|
||||
SHA512 = sha512.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(itemName);
|
||||
|
||||
@@ -550,11 +506,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
SpamSum = spamsum.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
media.SetName(itemName);
|
||||
|
||||
@@ -569,11 +521,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Size = null,
|
||||
SpamSum = spamsum.Hash,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(itemName);
|
||||
|
||||
|
||||
@@ -118,11 +118,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
disk.SetName(row.Name);
|
||||
|
||||
@@ -148,11 +144,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA1 = row.SHA1,
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(row.Name);
|
||||
|
||||
@@ -172,11 +164,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
ItemStatus = ItemStatus.BadDump,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
disk.SetName(row.Name);
|
||||
|
||||
@@ -200,11 +188,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA1 = null,
|
||||
ItemStatus = ItemStatus.Nodump,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
disk.SetName(row.Name);
|
||||
|
||||
@@ -225,11 +209,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA1 = row.SHA1,
|
||||
ItemStatus = ItemStatus.BadDump,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(row.Name);
|
||||
|
||||
@@ -249,11 +229,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA1 = null,
|
||||
ItemStatus = ItemStatus.Nodump,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
rom.SetName(row.Name);
|
||||
|
||||
|
||||
@@ -144,11 +144,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var blank = new Blank
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
@@ -179,11 +175,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Description = biosset.Description,
|
||||
Default = biosset.Default?.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(biosset.Name);
|
||||
|
||||
@@ -224,11 +216,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
//Dispose = rom.Dispose.AsYesNo(), // TODO: Add to internal model
|
||||
//SoundOnly = rom.SoundOnly.AsYesNo(), // TODO: Add to internal model
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(rom.Name);
|
||||
|
||||
@@ -266,11 +254,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
ItemStatus = disk.Status.AsEnumValue<ItemStatus>(),
|
||||
Optional = disk.Optional.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(disk.Name);
|
||||
|
||||
@@ -299,11 +283,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var item = new DeviceReference
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(deviceref.Name);
|
||||
|
||||
@@ -332,11 +312,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var item = new Sample
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(sample.Name);
|
||||
|
||||
@@ -370,11 +346,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
//SoundOnly = chip.SoundOnly, // TODO: Add to internal model
|
||||
Clock = NumberHelper.ConvertToInt64(chip.Clock),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(chip.Name);
|
||||
|
||||
@@ -418,11 +390,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
VBEnd = NumberHelper.ConvertToInt64(display.VBEnd),
|
||||
VBStart = NumberHelper.ConvertToInt64(display.VBStart),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
@@ -457,11 +425,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
//AspectY = video.AspectY, // TODO: Add to internal model or find mapping
|
||||
Refresh = NumberHelper.ConvertToDouble(video.Refresh),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
switch (video.Orientation)
|
||||
@@ -499,11 +463,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
Channels = NumberHelper.ConvertToInt64(sound.Channels),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
@@ -535,11 +495,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
//Buttons = input.Buttons, // TODO: Add to internal model
|
||||
Coins = NumberHelper.ConvertToInt64(input.Coins),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
var controls = new List<Control>();
|
||||
@@ -593,11 +549,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Tag = dipswitch.Tag,
|
||||
Mask = dipswitch.Mask,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(dipswitch.Name);
|
||||
|
||||
@@ -685,11 +637,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Tag = configuration.Tag,
|
||||
Mask = configuration.Mask,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(configuration.Name);
|
||||
|
||||
@@ -775,11 +723,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
Tag = port.Tag,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
var analogs = new List<Analog>();
|
||||
@@ -818,17 +762,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
containsItems = true;
|
||||
foreach (var adjuster in adjusters)
|
||||
{
|
||||
var item = new Adjuster
|
||||
{
|
||||
Default = adjuster.Default.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
var item = new Adjuster { Source = new Source { Index = indexId, Name = filename } };
|
||||
item.SetName(adjuster.Name);
|
||||
item.SetFieldValue<bool?>(Models.Metadata.Adjuster.DefaultKey, adjuster.Default.AsYesNo());
|
||||
|
||||
if (adjuster.Condition != null)
|
||||
{
|
||||
@@ -839,7 +775,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Relation = adjuster.Condition.Relation.AsEnumValue<Relation>(),
|
||||
Value = adjuster.Condition.Value,
|
||||
};
|
||||
item.Conditions = [condition];
|
||||
item.SetFieldValue<Condition[]?>(Models.Metadata.Adjuster.ConditionKey, [condition]);
|
||||
}
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
@@ -877,11 +813,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
NoSoundHardware = driver.NoSoundHardware.AsYesNo(),
|
||||
Incomplete = driver.Incomplete.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
@@ -912,11 +844,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Status = feature.Status.AsEnumValue<FeatureStatus>(),
|
||||
Overall = feature.Overall.AsEnumValue<FeatureStatus>(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
@@ -950,11 +878,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Mandatory = NumberHelper.ConvertToInt64(device.Mandatory),
|
||||
Interface = device.Interface,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
if (device.Instance != null)
|
||||
@@ -1003,11 +927,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var item = new Slot
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(slot.Name);
|
||||
|
||||
@@ -1055,11 +975,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Status = softwarelist.Status.AsEnumValue<SoftwareListStatus>(),
|
||||
Filter = softwarelist.Filter,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(softwarelist.Name);
|
||||
|
||||
@@ -1091,11 +1007,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Default = ramoption.Default.AsYesNo(),
|
||||
Content = ramoption.Content,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(ramoption.Name);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using SabreTools.Core;
|
||||
using SabreTools.Core.Tools;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.DatItems.Formats;
|
||||
using SabreTools.Serialization.CrossModel;
|
||||
|
||||
namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
@@ -802,12 +803,12 @@ namespace SabreTools.DatFiles.Formats
|
||||
var adjuster = new Models.Listxml.Adjuster
|
||||
{
|
||||
Name = item.GetName(),
|
||||
Default = item.Default.FromYesNo(),
|
||||
Default = item.GetFieldValue<bool?>(Models.Metadata.Adjuster.DefaultKey).FromYesNo(),
|
||||
};
|
||||
|
||||
if (item.ConditionsSpecified)
|
||||
{
|
||||
var conditionItem = item.Conditions?.FirstOrDefault();
|
||||
var conditionItem = item.GetFieldValue<Condition[]?>(Models.Metadata.Adjuster.ConditionKey)?.FirstOrDefault();
|
||||
var condition = new Models.Listxml.Condition
|
||||
{
|
||||
Tag = conditionItem?.Tag,
|
||||
|
||||
@@ -288,11 +288,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var blank = new Blank
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
@@ -325,11 +321,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Date = release.Date,
|
||||
Default = release.Default?.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(release.Name);
|
||||
|
||||
@@ -361,11 +353,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Description = biosset.Description,
|
||||
Default = biosset.Default?.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(biosset.Name);
|
||||
|
||||
@@ -412,11 +400,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Inverted = rom.Inverted?.AsYesNo(),
|
||||
MIA = rom.MIA?.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(rom.Name);
|
||||
|
||||
@@ -450,11 +434,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
MergeTag = disk.Merge,
|
||||
ItemStatus = disk.Status?.AsEnumValue<ItemStatus>() ?? ItemStatus.NULL,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(disk.Name);
|
||||
|
||||
@@ -488,11 +468,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA256 = medium.SHA256,
|
||||
SpamSum = medium.SpamSum,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(medium.Name);
|
||||
|
||||
@@ -521,11 +497,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var item = new DeviceReference
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(deviceref.Name);
|
||||
|
||||
@@ -554,11 +526,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var item = new Sample
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(sample.Name);
|
||||
|
||||
@@ -587,11 +555,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var item = new Archive
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(archive.Name);
|
||||
|
||||
@@ -627,11 +591,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
NoSoundHardware = driver.NoSoundHardware?.AsYesNo(),
|
||||
Incomplete = driver.Incomplete?.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
item.CopyMachineInformation(machine);
|
||||
@@ -662,11 +622,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Status = softwarelist.Status?.AsEnumValue<SoftwareListStatus>() ?? SoftwareListStatus.None,
|
||||
Filter = softwarelist.Filter,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(softwarelist.Name);
|
||||
|
||||
|
||||
@@ -331,11 +331,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var blank = new Blank
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
@@ -374,11 +370,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
CRC = crc.Content,
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(name);
|
||||
|
||||
|
||||
@@ -103,11 +103,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var blank = new Blank
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
@@ -148,11 +144,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA1 = rom.Hash,
|
||||
Remark = rom.Remark,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(name);
|
||||
|
||||
|
||||
@@ -123,11 +123,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
RomOf = rom.RomOf,
|
||||
},
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(rom.RomName);
|
||||
|
||||
|
||||
@@ -88,11 +88,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA1 = row.SHA1,
|
||||
ItemStatus = row.Status.AsEnumValue<ItemStatus>(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(row.DiskName);
|
||||
break;
|
||||
@@ -105,11 +101,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SHA256 = row.SHA256,
|
||||
SpamSum = row.SpamSum,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(row.DiskName);
|
||||
break;
|
||||
@@ -126,11 +118,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
SpamSum = row.SpamSum,
|
||||
ItemStatus = row.Status.AsEnumValue<ItemStatus>(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(row.RomName);
|
||||
break;
|
||||
|
||||
@@ -108,11 +108,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
Value = info.Value,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
infoItem.SetName(info.Name);
|
||||
|
||||
@@ -127,11 +123,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
Value = sharedfeat.Value,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
sharedfeatItem.SetName(sharedfeat.Name);
|
||||
|
||||
@@ -150,11 +142,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var blank = new Blank
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
|
||||
blank.CopyMachineInformation(machine);
|
||||
@@ -184,11 +172,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Interface = part.Interface,
|
||||
Features = CreateFeatures(part.Feature, machine, filename, indexId, statsOnly),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(part.Name);
|
||||
|
||||
@@ -221,11 +205,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
Value = feature.Value,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(feature.Name);
|
||||
|
||||
@@ -260,11 +240,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Width = NumberHelper.ConvertToInt64(dataarea.Width),
|
||||
Endianness = dataarea.Endianness.AsEnumValue<Endianness>(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(dataarea.Name);
|
||||
|
||||
@@ -306,11 +282,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Part = part,
|
||||
DataArea = dataarea,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(rom.Name);
|
||||
|
||||
@@ -339,11 +311,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var item = new DiskArea
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(diskarea.Name);
|
||||
|
||||
@@ -382,11 +350,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Part = part,
|
||||
DiskArea = diskarea,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(disk.Name);
|
||||
|
||||
@@ -421,11 +385,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
Part = part,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(dipswitch.Name);
|
||||
|
||||
@@ -455,11 +415,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Value = dipvalue.Value,
|
||||
Default = dipvalue.Default.AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
Source = new Source { Index = indexId, Name = filename },
|
||||
};
|
||||
item.SetName(dipvalue.Name);
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace SabreTools.DatFiles
|
||||
// Field.DatItem_Conditions does not apply here
|
||||
if (adjuster.ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition subCondition in adjuster.Conditions!)
|
||||
foreach (Condition subCondition in adjuster.GetFieldValue<Condition[]?>(Models.Metadata.Adjuster.ConditionKey)!)
|
||||
{
|
||||
SetFields(subCondition);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Core;
|
||||
|
||||
@@ -14,32 +12,16 @@ namespace SabreTools.DatItems.Formats
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Determine whether the value is default
|
||||
/// </summary>
|
||||
[JsonProperty("default", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("default")]
|
||||
public bool? Default
|
||||
{
|
||||
get => _internal.ReadBool(Models.Metadata.Adjuster.DefaultKey);
|
||||
set => _internal[Models.Metadata.Adjuster.DefaultKey] = value;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool DefaultSpecified { get { return Default != null; } }
|
||||
|
||||
/// <summary>
|
||||
/// Conditions associated with the adjustment
|
||||
/// </summary>
|
||||
[JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("conditions")]
|
||||
public List<Condition>? Conditions
|
||||
public bool ConditionsSpecified
|
||||
{
|
||||
get => _internal.Read<Condition[]>(Models.Metadata.Adjuster.ConditionKey)?.ToList();
|
||||
set => _internal[Models.Metadata.Adjuster.ConditionKey] = value?.ToArray();
|
||||
get
|
||||
{
|
||||
var conditions = GetFieldValue<Condition[]?>(Models.Metadata.Adjuster.ConditionKey);
|
||||
return conditions != null && conditions.Length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ConditionsSpecified { get { return Conditions != null && Conditions.Count > 0; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace SabreTools.Filtering
|
||||
if (!adjuster.ConditionsSpecified)
|
||||
return;
|
||||
|
||||
foreach (Condition subCondition in adjuster.Conditions!)
|
||||
foreach (Condition subCondition in adjuster.GetFieldValue<Condition[]?>(Models.Metadata.Adjuster.ConditionKey)!)
|
||||
{
|
||||
RemoveFields(subCondition);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using SabreTools.Core;
|
||||
using SabreTools.DatFiles;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.DatItems.Formats;
|
||||
@@ -24,7 +21,6 @@ namespace SabreTools.Test.DatFiles
|
||||
[
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-1",
|
||||
Size = 1024,
|
||||
CRC = "DEADBEEF",
|
||||
SHA1 = "0000000fbbb37f8488100b1b4697012de631a5e6",
|
||||
@@ -32,18 +28,16 @@ namespace SabreTools.Test.DatFiles
|
||||
},
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-2",
|
||||
Size = 1024,
|
||||
CRC = "DEADBEEF",
|
||||
SHA1 = "000000e948edcb4f7704b8af85a77a3339ecce44",
|
||||
Machine = new Machine { Name = "game-1" },
|
||||
},
|
||||
],
|
||||
["game-2"] = new ConcurrentList<DatItem>
|
||||
{
|
||||
["game-2"] =
|
||||
[
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-3",
|
||||
Size = 1024,
|
||||
CRC = "DEADBEEF",
|
||||
SHA1 = "00000ea4014ce66679e7e17d56ac510f67e39e26",
|
||||
@@ -51,14 +45,17 @@ namespace SabreTools.Test.DatFiles
|
||||
},
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-4",
|
||||
Size = 1024,
|
||||
CRC = "DEADBEEF",
|
||||
SHA1 = "00000151d437442e74e5134023fab8bf694a2487",
|
||||
Machine = new Machine { Name = "game-2" },
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
dict["game-1"]![0].SetName("rom-1");
|
||||
dict["game-1"]![1].SetName("rom-2");
|
||||
dict["game-2"]![0].SetName("rom-3");
|
||||
dict["game-2"]![1].SetName("rom-4");
|
||||
|
||||
dict.BucketBy(itemKey, DedupeType.None);
|
||||
Assert.Equal(expected, dict.Keys.Count);
|
||||
@@ -70,8 +67,8 @@ namespace SabreTools.Test.DatFiles
|
||||
// Setup the dictionary
|
||||
var dict = new ItemDictionary
|
||||
{
|
||||
["game-1"] = new ConcurrentList<DatItem> { new Rom(), },
|
||||
["game-2"] = new ConcurrentList<DatItem>(),
|
||||
["game-1"] = [new Rom(),],
|
||||
["game-2"] = [],
|
||||
["game-3"] = null,
|
||||
};
|
||||
|
||||
@@ -85,11 +82,10 @@ namespace SabreTools.Test.DatFiles
|
||||
// Setup the dictionary
|
||||
var dict = new ItemDictionary
|
||||
{
|
||||
["game-1"] = new ConcurrentList<DatItem>
|
||||
{
|
||||
["game-1"] =
|
||||
[
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-1",
|
||||
Size = 1024,
|
||||
CRC = "DEADBEEF",
|
||||
SHA1 = "0000000fbbb37f8488100b1b4697012de631a5e6",
|
||||
@@ -97,15 +93,16 @@ namespace SabreTools.Test.DatFiles
|
||||
},
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-2",
|
||||
Size = 1024,
|
||||
CRC = "DEADBEEF",
|
||||
SHA1 = "000000e948edcb4f7704b8af85a77a3339ecce44",
|
||||
Machine = new Machine { Name = "game-1" },
|
||||
Remove = true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
dict["game-1"]![0].SetName("rom-1");
|
||||
dict["game-1"]![1].SetName("rom-2");
|
||||
|
||||
dict.ClearMarked();
|
||||
string key = Assert.Single(dict.Keys);
|
||||
@@ -122,32 +119,32 @@ namespace SabreTools.Test.DatFiles
|
||||
// Setup the dictionary
|
||||
var dict = new ItemDictionary
|
||||
{
|
||||
["game-1"] = new ConcurrentList<DatItem>
|
||||
{
|
||||
["game-1"] =
|
||||
[
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-1",
|
||||
Size = 1024,
|
||||
SHA1 = "0000000fbbb37f8488100b1b4697012de631a5e6",
|
||||
Machine = new Machine { Name = "game-1" },
|
||||
},
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-2",
|
||||
Size = 1024,
|
||||
SHA1 = "000000e948edcb4f7704b8af85a77a3339ecce44",
|
||||
Machine = new Machine { Name = "game-1" },
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
dict["game-1"]![0].SetName("rom-1");
|
||||
dict["game-1"]![1].SetName("rom-2");
|
||||
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = "rom-1",
|
||||
Size = hasDuplicate ? 1024 : 2048,
|
||||
SHA1 = "0000000fbbb37f8488100b1b4697012de631a5e6",
|
||||
Machine = new Machine { Name = "game-1" },
|
||||
};
|
||||
rom.SetName("rom-1");
|
||||
|
||||
var actual = dict.GetDuplicates(rom);
|
||||
Assert.Equal(expected, actual.Count);
|
||||
@@ -161,32 +158,32 @@ namespace SabreTools.Test.DatFiles
|
||||
// Setup the dictionary
|
||||
var dict = new ItemDictionary
|
||||
{
|
||||
["game-1"] = new ConcurrentList<DatItem>
|
||||
{
|
||||
["game-1"] =
|
||||
[
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-1",
|
||||
Size = 1024,
|
||||
SHA1 = "0000000fbbb37f8488100b1b4697012de631a5e6",
|
||||
Machine = new Machine { Name = "game-1" },
|
||||
},
|
||||
new Rom
|
||||
{
|
||||
Name = "rom-2",
|
||||
Size = 1024,
|
||||
SHA1 = "000000e948edcb4f7704b8af85a77a3339ecce44",
|
||||
Machine = new Machine { Name = "game-1" },
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
dict["game-1"]![0].SetName("rom-1");
|
||||
dict["game-1"]![1].SetName("rom-2");
|
||||
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = "rom-1",
|
||||
Size = expected ? 1024 : 2048,
|
||||
SHA1 = "0000000fbbb37f8488100b1b4697012de631a5e6",
|
||||
Machine = new Machine { Name = "game-1" },
|
||||
};
|
||||
rom.SetName("rom-1");
|
||||
|
||||
bool actual = dict.HasDuplicates(rom);
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
@@ -32,15 +32,16 @@ namespace SabreTools.Test.DatFiles
|
||||
/// </summary>
|
||||
private static DatItem CreateDatItem()
|
||||
{
|
||||
return new Rom
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = "foo",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "bar",
|
||||
Description = "bar",
|
||||
}
|
||||
};
|
||||
rom.SetName("foo");
|
||||
return rom;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,30 +49,24 @@ namespace SabreTools.Test.DatItems
|
||||
{
|
||||
var romA = new Rom
|
||||
{
|
||||
Name = "same-name",
|
||||
CRC = "DEADBEEF",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "name-same",
|
||||
},
|
||||
Source = new Source
|
||||
{
|
||||
Index = 0,
|
||||
},
|
||||
Source = new Source { Index = 0 },
|
||||
};
|
||||
romA.SetName("same-name");
|
||||
var romB = new Rom
|
||||
{
|
||||
Name = "same-name",
|
||||
CRC = "DEADBEEF",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "name-same",
|
||||
},
|
||||
Source = new Source
|
||||
{
|
||||
Index = 1,
|
||||
},
|
||||
Source = new Source { Index = 1 },
|
||||
};
|
||||
romB.SetName("same-name");
|
||||
|
||||
var actual = romA.GetDuplicateStatus(romB);
|
||||
Assert.Equal(DupeType.External | DupeType.All, actual);
|
||||
@@ -83,30 +77,24 @@ namespace SabreTools.Test.DatItems
|
||||
{
|
||||
var romA = new Rom
|
||||
{
|
||||
Name = "same-name",
|
||||
CRC = "DEADBEEF",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "name-same",
|
||||
},
|
||||
Source = new Source
|
||||
{
|
||||
Index = 0,
|
||||
},
|
||||
Source = new Source { Index = 0 },
|
||||
};
|
||||
romA.SetName("same-name");
|
||||
var romB = new Rom
|
||||
{
|
||||
Name = "same-name",
|
||||
CRC = "DEADBEEF",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "not-name-same",
|
||||
},
|
||||
Source = new Source
|
||||
{
|
||||
Index = 1,
|
||||
},
|
||||
Source = new Source { Index = 1 },
|
||||
};
|
||||
romB.SetName("same-name");
|
||||
|
||||
var actual = romA.GetDuplicateStatus(romB);
|
||||
Assert.Equal(DupeType.External | DupeType.Hash, actual);
|
||||
@@ -117,30 +105,24 @@ namespace SabreTools.Test.DatItems
|
||||
{
|
||||
var romA = new Rom
|
||||
{
|
||||
Name = "same-name",
|
||||
CRC = "DEADBEEF",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "name-same",
|
||||
},
|
||||
Source = new Source
|
||||
{
|
||||
Index = 0,
|
||||
},
|
||||
Source = new Source { Index = 0 },
|
||||
};
|
||||
romA.SetName("same-name");
|
||||
var romB = new Rom
|
||||
{
|
||||
Name = "same-name",
|
||||
CRC = "DEADBEEF",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "name-same",
|
||||
},
|
||||
Source = new Source
|
||||
{
|
||||
Index = 0,
|
||||
},
|
||||
Source = new Source { Index = 0 },
|
||||
};
|
||||
romB.SetName("same-name");
|
||||
|
||||
var actual = romA.GetDuplicateStatus(romB);
|
||||
Assert.Equal(DupeType.Internal | DupeType.All, actual);
|
||||
@@ -151,30 +133,24 @@ namespace SabreTools.Test.DatItems
|
||||
{
|
||||
var romA = new Rom
|
||||
{
|
||||
Name = "same-name",
|
||||
CRC = "DEADBEEF",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "name-same",
|
||||
},
|
||||
Source = new Source
|
||||
{
|
||||
Index = 0,
|
||||
},
|
||||
Source = new Source { Index = 0 },
|
||||
};
|
||||
romA.SetName("same-name");
|
||||
var romB = new Rom
|
||||
{
|
||||
Name = "same-name",
|
||||
CRC = "DEADBEEF",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "not-name-same",
|
||||
},
|
||||
Source = new Source
|
||||
{
|
||||
Index = 0,
|
||||
},
|
||||
Source = new Source { Index = 0 },
|
||||
};
|
||||
romB.SetName("same-name");
|
||||
|
||||
var actual = romA.GetDuplicateStatus(romB);
|
||||
Assert.Equal(DupeType.Internal | DupeType.Hash, actual);
|
||||
|
||||
@@ -68,15 +68,16 @@ namespace SabreTools.Test.Filter
|
||||
/// </summary>
|
||||
private static DatItem CreateDatItem()
|
||||
{
|
||||
return new Rom
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = "foo",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "bar",
|
||||
Description = "bar",
|
||||
}
|
||||
};
|
||||
rom.SetName("foo");
|
||||
return rom;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,15 +115,16 @@ namespace SabreTools.Test.Filtering
|
||||
/// </summary>
|
||||
private static DatItem CreateDatItem(string name, string machine, string desc)
|
||||
{
|
||||
return new Rom
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = name,
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = machine,
|
||||
Description = desc,
|
||||
}
|
||||
};
|
||||
rom.SetName(name);
|
||||
return rom;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,15 +32,16 @@ namespace SabreTools.Test.Filtering
|
||||
/// </summary>
|
||||
private static DatItem CreateDatItem()
|
||||
{
|
||||
return new Rom
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = "foo",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "bar",
|
||||
Description = "bar",
|
||||
}
|
||||
};
|
||||
rom.SetName("foo");
|
||||
return rom;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,15 +40,16 @@ namespace SabreTools.Test.Filtering
|
||||
/// </summary>
|
||||
private static DatItem CreateDatItem()
|
||||
{
|
||||
return new Rom
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = "foo",
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = "bar",
|
||||
Description = "bar",
|
||||
}
|
||||
};
|
||||
rom.SetName("foo");
|
||||
return rom;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user