mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix default format setting, add tests
This commit is contained in:
@@ -19,6 +19,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public ArchiveDotOrg(DatFile? datFile) : base(datFile)
|
public ArchiveDotOrg(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.ArchiveDotOrg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public AttractMode(DatFile? datFile) : base(datFile)
|
public AttractMode(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.AttractMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public ClrMamePro(DatFile? datFile) : base(datFile)
|
public ClrMamePro(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.ClrMamePro);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public DosCenter(DatFile? datFile) : base(datFile)
|
public DosCenter(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.DOSCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public EverdriveSMDB(DatFile? datFile) : base(datFile)
|
public EverdriveSMDB(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.EverdriveSMDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public SfvFile(DatFile? datFile) : base(datFile)
|
public SfvFile(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_hash = HashType.CRC32;
|
_hash = HashType.CRC32;
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RedumpSFV);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -131,6 +132,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Md2File(DatFile? datFile) : base(datFile)
|
public Md2File(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_hash = HashType.MD2;
|
_hash = HashType.MD2;
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RedumpMD2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -172,6 +174,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Md4File(DatFile? datFile) : base(datFile)
|
public Md4File(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_hash = HashType.MD4;
|
_hash = HashType.MD4;
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RedumpMD4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -215,6 +218,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Md5File(DatFile? datFile) : base(datFile)
|
public Md5File(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_hash = HashType.MD5;
|
_hash = HashType.MD5;
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RedumpMD5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -268,6 +272,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Sha1File(DatFile? datFile) : base(datFile)
|
public Sha1File(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_hash = HashType.SHA1;
|
_hash = HashType.SHA1;
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RedumpSHA1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -320,6 +325,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Sha256File(DatFile? datFile) : base(datFile)
|
public Sha256File(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_hash = HashType.SHA256;
|
_hash = HashType.SHA256;
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RedumpSHA256);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -366,6 +372,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Sha384File(DatFile? datFile) : base(datFile)
|
public Sha384File(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_hash = HashType.SHA384;
|
_hash = HashType.SHA384;
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RedumpSHA384);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -407,6 +414,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Sha512File(DatFile? datFile) : base(datFile)
|
public Sha512File(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_hash = HashType.SHA512;
|
_hash = HashType.SHA512;
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RedumpSHA512);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -449,6 +457,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public SpamSumFile(DatFile? datFile) : base(datFile)
|
public SpamSumFile(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_hash = HashType.SpamSum;
|
_hash = HashType.SpamSum;
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RedumpSpamSum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public Listrom(DatFile? datFile) : base(datFile)
|
public Listrom(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.Listrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public Listxml(DatFile? datFile) : base(datFile)
|
public Listxml(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.Listxml);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -253,6 +253,10 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public Logiqx(DatFile? datFile, bool useGame) : base(datFile)
|
public Logiqx(DatFile? datFile, bool useGame) : base(datFile)
|
||||||
{
|
{
|
||||||
_useGame = useGame;
|
_useGame = useGame;
|
||||||
|
if (useGame)
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.LogiqxDeprecated);
|
||||||
|
else
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.Logiqx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public Missfile(DatFile? datFile) : base(datFile)
|
public Missfile(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.MissFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public OfflineList(DatFile? datFile) : base(datFile)
|
public OfflineList(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.OfflineList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ The softwaredb.xml file contains information about rom mapper types
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public OpenMSX(DatFile? datFile) : base(datFile)
|
public OpenMSX(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.OpenMSX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public RomCenter(DatFile? datFile) : base(datFile)
|
public RomCenter(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.RomCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public SabreJSON(DatFile? datFile) : base(datFile)
|
public SabreJSON(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.SabreJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public SabreXML(DatFile? datFile) : base(datFile)
|
public SabreXML(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.SabreXML);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public CommaSeparatedValue(DatFile? datFile) : base(datFile)
|
public CommaSeparatedValue(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_delim = ',';
|
_delim = ',';
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.CSV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +157,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public SemicolonSeparatedValue(DatFile? datFile) : base(datFile)
|
public SemicolonSeparatedValue(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_delim = ';';
|
_delim = ';';
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.SSV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +173,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
public TabSeparatedValue(DatFile? datFile) : base(datFile)
|
public TabSeparatedValue(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
_delim = '\t';
|
_delim = '\t';
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.TSV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||||
public SoftwareList(DatFile? datFile) : base(datFile)
|
public SoftwareList(DatFile? datFile) : base(datFile)
|
||||||
{
|
{
|
||||||
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.SoftwareList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -155,13 +155,23 @@ namespace SabreTools.DatTools
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to be parsed</param>
|
/// <param name="filename">Name of the file to be parsed</param>
|
||||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// Code must remove the existing format in order to ensure the format is derived
|
||||||
|
/// from the input file instead. This should be addressed later by either always
|
||||||
|
/// deriving the format, or by setting a flag for this to be done automatically.
|
||||||
|
// </remarks>
|
||||||
public static DatFile ParseStatistics(string? filename, bool throwOnError = false)
|
public static DatFile ParseStatistics(string? filename, bool throwOnError = false)
|
||||||
{
|
{
|
||||||
// Null filenames are invalid
|
// Null filenames are invalid
|
||||||
if (filename == null)
|
if (filename == null)
|
||||||
return CreateDatFile();
|
{
|
||||||
|
DatFile empty = CreateDatFile();
|
||||||
|
empty.Header.RemoveField(DatHeader.DatFormatKey);
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
DatFile datFile = CreateDatFile();
|
DatFile datFile = CreateDatFile();
|
||||||
|
datFile.Header.RemoveField(DatHeader.DatFormatKey);
|
||||||
ParseInto(datFile, filename, statsOnly: true, throwOnError: throwOnError);
|
ParseInto(datFile, filename, statsOnly: true, throwOnError: throwOnError);
|
||||||
return datFile;
|
return datFile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,142 @@ namespace SabreTools.Test
|
|||||||
{
|
{
|
||||||
public class ParserTests
|
public class ParserTests
|
||||||
{
|
{
|
||||||
|
[Fact]
|
||||||
|
public void CreateDatFile_Default_Logiqx()
|
||||||
|
{
|
||||||
|
var datFile = Parser.CreateDatFile();
|
||||||
|
Assert.Equal(DatFormat.Logiqx, datFile.Header.GetFieldValue<DatFormat>(DatHeader.DatFormatKey));
|
||||||
|
Assert.Equal(0, datFile.Items.DatStatistics.TotalCount);
|
||||||
|
Assert.Equal(0, datFile.ItemsDB.DatStatistics.TotalCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData((DatFormat)0x00, DatFormat.Logiqx)]
|
||||||
|
[InlineData(DatFormat.Logiqx, DatFormat.Logiqx)]
|
||||||
|
[InlineData(DatFormat.LogiqxDeprecated, DatFormat.LogiqxDeprecated)]
|
||||||
|
[InlineData(DatFormat.SoftwareList, DatFormat.SoftwareList)]
|
||||||
|
[InlineData(DatFormat.Listxml, DatFormat.Listxml)]
|
||||||
|
[InlineData(DatFormat.OfflineList, DatFormat.OfflineList)]
|
||||||
|
[InlineData(DatFormat.SabreXML, DatFormat.SabreXML)]
|
||||||
|
[InlineData(DatFormat.OpenMSX, DatFormat.OpenMSX)]
|
||||||
|
[InlineData(DatFormat.ArchiveDotOrg, DatFormat.ArchiveDotOrg)]
|
||||||
|
[InlineData(DatFormat.ClrMamePro, DatFormat.ClrMamePro)]
|
||||||
|
[InlineData(DatFormat.RomCenter, DatFormat.RomCenter)]
|
||||||
|
[InlineData(DatFormat.DOSCenter, DatFormat.DOSCenter)]
|
||||||
|
[InlineData(DatFormat.AttractMode, DatFormat.AttractMode)]
|
||||||
|
[InlineData(DatFormat.MissFile, DatFormat.MissFile)]
|
||||||
|
[InlineData(DatFormat.CSV, DatFormat.CSV)]
|
||||||
|
[InlineData(DatFormat.SSV, DatFormat.SSV)]
|
||||||
|
[InlineData(DatFormat.TSV, DatFormat.TSV)]
|
||||||
|
[InlineData(DatFormat.Listrom, DatFormat.Listrom)]
|
||||||
|
[InlineData(DatFormat.EverdriveSMDB, DatFormat.EverdriveSMDB)]
|
||||||
|
[InlineData(DatFormat.SabreJSON, DatFormat.SabreJSON)]
|
||||||
|
[InlineData(DatFormat.RedumpSFV, DatFormat.RedumpSFV)]
|
||||||
|
[InlineData(DatFormat.RedumpMD2, DatFormat.RedumpMD2)]
|
||||||
|
[InlineData(DatFormat.RedumpMD4, DatFormat.RedumpMD4)]
|
||||||
|
[InlineData(DatFormat.RedumpMD5, DatFormat.RedumpMD5)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA1, DatFormat.RedumpSHA1)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA256, DatFormat.RedumpSHA256)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA384, DatFormat.RedumpSHA384)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA512, DatFormat.RedumpSHA512)]
|
||||||
|
[InlineData(DatFormat.RedumpSpamSum, DatFormat.RedumpSpamSum)]
|
||||||
|
public void CreateDatFile_Format_NoBaseDat(DatFormat datFormat, DatFormat expected)
|
||||||
|
{
|
||||||
|
var datFile = Parser.CreateDatFile(datFormat, baseDat: null);
|
||||||
|
Assert.Equal(expected, datFile.Header.GetFieldValue<DatFormat>(DatHeader.DatFormatKey));
|
||||||
|
Assert.Equal(0, datFile.Items.DatStatistics.TotalCount);
|
||||||
|
Assert.Equal(0, datFile.ItemsDB.DatStatistics.TotalCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData((DatFormat)0x00, DatFormat.Logiqx)]
|
||||||
|
[InlineData(DatFormat.Logiqx, DatFormat.Logiqx)]
|
||||||
|
[InlineData(DatFormat.LogiqxDeprecated, DatFormat.LogiqxDeprecated)]
|
||||||
|
[InlineData(DatFormat.SoftwareList, DatFormat.SoftwareList)]
|
||||||
|
[InlineData(DatFormat.Listxml, DatFormat.Listxml)]
|
||||||
|
[InlineData(DatFormat.OfflineList, DatFormat.OfflineList)]
|
||||||
|
[InlineData(DatFormat.SabreXML, DatFormat.SabreXML)]
|
||||||
|
[InlineData(DatFormat.OpenMSX, DatFormat.OpenMSX)]
|
||||||
|
[InlineData(DatFormat.ArchiveDotOrg, DatFormat.ArchiveDotOrg)]
|
||||||
|
[InlineData(DatFormat.ClrMamePro, DatFormat.ClrMamePro)]
|
||||||
|
[InlineData(DatFormat.RomCenter, DatFormat.RomCenter)]
|
||||||
|
[InlineData(DatFormat.DOSCenter, DatFormat.DOSCenter)]
|
||||||
|
[InlineData(DatFormat.AttractMode, DatFormat.AttractMode)]
|
||||||
|
[InlineData(DatFormat.MissFile, DatFormat.MissFile)]
|
||||||
|
[InlineData(DatFormat.CSV, DatFormat.CSV)]
|
||||||
|
[InlineData(DatFormat.SSV, DatFormat.SSV)]
|
||||||
|
[InlineData(DatFormat.TSV, DatFormat.TSV)]
|
||||||
|
[InlineData(DatFormat.Listrom, DatFormat.Listrom)]
|
||||||
|
[InlineData(DatFormat.EverdriveSMDB, DatFormat.EverdriveSMDB)]
|
||||||
|
[InlineData(DatFormat.SabreJSON, DatFormat.SabreJSON)]
|
||||||
|
[InlineData(DatFormat.RedumpSFV, DatFormat.RedumpSFV)]
|
||||||
|
[InlineData(DatFormat.RedumpMD2, DatFormat.RedumpMD2)]
|
||||||
|
[InlineData(DatFormat.RedumpMD4, DatFormat.RedumpMD4)]
|
||||||
|
[InlineData(DatFormat.RedumpMD5, DatFormat.RedumpMD5)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA1, DatFormat.RedumpSHA1)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA256, DatFormat.RedumpSHA256)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA384, DatFormat.RedumpSHA384)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA512, DatFormat.RedumpSHA512)]
|
||||||
|
[InlineData(DatFormat.RedumpSpamSum, DatFormat.RedumpSpamSum)]
|
||||||
|
public void CreateDatFile_Format_BaseDat(DatFormat datFormat, DatFormat expected)
|
||||||
|
{
|
||||||
|
var baseDat = Parser.CreateDatFile();
|
||||||
|
baseDat.Header.SetFieldValue<string?>(DatHeader.FileNameKey, "filename");
|
||||||
|
|
||||||
|
var datFile = Parser.CreateDatFile(datFormat, baseDat);
|
||||||
|
Assert.Equal(expected, datFile.Header.GetFieldValue<DatFormat>(DatHeader.DatFormatKey));
|
||||||
|
Assert.Equal("filename", datFile.Header.GetFieldValue<string?>(DatHeader.FileNameKey));
|
||||||
|
Assert.Equal(0, datFile.Items.DatStatistics.TotalCount);
|
||||||
|
Assert.Equal(0, datFile.ItemsDB.DatStatistics.TotalCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData((DatFormat)0x00, (DatFormat)0x00)] // I think this is a bug
|
||||||
|
[InlineData(DatFormat.Logiqx, DatFormat.Logiqx)]
|
||||||
|
[InlineData(DatFormat.LogiqxDeprecated, DatFormat.LogiqxDeprecated)]
|
||||||
|
[InlineData(DatFormat.SoftwareList, DatFormat.SoftwareList)]
|
||||||
|
[InlineData(DatFormat.Listxml, DatFormat.Listxml)]
|
||||||
|
[InlineData(DatFormat.OfflineList, DatFormat.OfflineList)]
|
||||||
|
[InlineData(DatFormat.SabreXML, DatFormat.SabreXML)]
|
||||||
|
[InlineData(DatFormat.OpenMSX, DatFormat.OpenMSX)]
|
||||||
|
[InlineData(DatFormat.ArchiveDotOrg, DatFormat.ArchiveDotOrg)]
|
||||||
|
[InlineData(DatFormat.ClrMamePro, DatFormat.ClrMamePro)]
|
||||||
|
[InlineData(DatFormat.RomCenter, DatFormat.RomCenter)]
|
||||||
|
[InlineData(DatFormat.DOSCenter, DatFormat.DOSCenter)]
|
||||||
|
[InlineData(DatFormat.AttractMode, DatFormat.AttractMode)]
|
||||||
|
[InlineData(DatFormat.MissFile, DatFormat.MissFile)]
|
||||||
|
[InlineData(DatFormat.CSV, DatFormat.CSV)]
|
||||||
|
[InlineData(DatFormat.SSV, DatFormat.SSV)]
|
||||||
|
[InlineData(DatFormat.TSV, DatFormat.TSV)]
|
||||||
|
[InlineData(DatFormat.Listrom, DatFormat.Listrom)]
|
||||||
|
[InlineData(DatFormat.EverdriveSMDB, DatFormat.EverdriveSMDB)]
|
||||||
|
[InlineData(DatFormat.SabreJSON, DatFormat.SabreJSON)]
|
||||||
|
[InlineData(DatFormat.RedumpSFV, DatFormat.RedumpSFV)]
|
||||||
|
[InlineData(DatFormat.RedumpMD2, DatFormat.RedumpMD2)]
|
||||||
|
[InlineData(DatFormat.RedumpMD4, DatFormat.RedumpMD4)]
|
||||||
|
[InlineData(DatFormat.RedumpMD5, DatFormat.RedumpMD5)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA1, DatFormat.RedumpSHA1)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA256, DatFormat.RedumpSHA256)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA384, DatFormat.RedumpSHA384)]
|
||||||
|
[InlineData(DatFormat.RedumpSHA512, DatFormat.RedumpSHA512)]
|
||||||
|
[InlineData(DatFormat.RedumpSpamSum, DatFormat.RedumpSpamSum)]
|
||||||
|
public void CreateDatFile_Format_FromHeader(DatFormat datFormat, DatFormat expected)
|
||||||
|
{
|
||||||
|
DatHeader datHeader = new DatHeader();
|
||||||
|
datHeader.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, datFormat);
|
||||||
|
datHeader.SetFieldValue<string?>(DatHeader.FileNameKey, "filename");
|
||||||
|
|
||||||
|
DatModifiers datModifiers = new DatModifiers();
|
||||||
|
datModifiers.Quotes = true;
|
||||||
|
|
||||||
|
var datFile = Parser.CreateDatFile(datHeader, datModifiers);
|
||||||
|
Assert.Equal(expected, datFile.Header.GetFieldValue<DatFormat>(DatHeader.DatFormatKey));
|
||||||
|
Assert.Equal("filename", datFile.Header.GetFieldValue<string?>(DatHeader.FileNameKey));
|
||||||
|
Assert.True(datFile.Modifiers.Quotes);
|
||||||
|
Assert.Equal(0, datFile.Items.DatStatistics.TotalCount);
|
||||||
|
Assert.Equal(0, datFile.ItemsDB.DatStatistics.TotalCount);
|
||||||
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData(null, (DatFormat)0x00, 0)]
|
[InlineData(null, (DatFormat)0x00, 0)]
|
||||||
[InlineData("test-logiqx.xml", DatFormat.Logiqx, 6)]
|
[InlineData("test-logiqx.xml", DatFormat.Logiqx, 6)]
|
||||||
@@ -43,7 +179,7 @@ namespace SabreTools.Test
|
|||||||
// For all filenames, add the local path for test data
|
// For all filenames, add the local path for test data
|
||||||
if (filename != null)
|
if (filename != null)
|
||||||
filename = Path.Combine(Environment.CurrentDirectory, "TestData", filename);
|
filename = Path.Combine(Environment.CurrentDirectory, "TestData", filename);
|
||||||
|
|
||||||
var datFile = Parser.ParseStatistics(filename, throwOnError: true);
|
var datFile = Parser.ParseStatistics(filename, throwOnError: true);
|
||||||
Assert.Equal(datFormat, datFile.Header.GetFieldValue<DatFormat>(DatHeader.DatFormatKey));
|
Assert.Equal(datFormat, datFile.Header.GetFieldValue<DatFormat>(DatHeader.DatFormatKey));
|
||||||
Assert.Equal(totalCount, datFile.Items.DatStatistics.TotalCount);
|
Assert.Equal(totalCount, datFile.Items.DatStatistics.TotalCount);
|
||||||
|
|||||||
Reference in New Issue
Block a user