Clean up submission info tests

This commit is contained in:
Matt Nadareski
2026-07-04 23:02:09 -04:00
parent f495722075
commit 7448f768ea
2 changed files with 81 additions and 117 deletions

View File

@@ -2,96 +2,100 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using SabreTools.RedumpLib.Data;
using SabreTools.RedumpLib.Data.Sections;
using Xunit;
using CommonDiscInfoSection = SabreTools.RedumpLib.RedumpOrg.Sections.CommonDiscInfoSection;
using CopyProtectionSection = SabreTools.RedumpLib.RedumpOrg.Sections.CopyProtectionSection;
using DumpersAndStatusSection = SabreTools.RedumpLib.RedumpOrg.Sections.DumpersAndStatusSection;
using DumpingInfoSection = SabreTools.RedumpLib.RedumpOrg.Sections.DumpingInfoSection;
using EDCSection = SabreTools.RedumpLib.RedumpOrg.Sections.EDCSection;
using ExtrasSection = SabreTools.RedumpLib.RedumpOrg.Sections.ExtrasSection;
using ParentCloneRelationshipSection = SabreTools.RedumpLib.RedumpOrg.Sections.ParentCloneRelationshipSection;
using SizeAndChecksumsSection = SabreTools.RedumpLib.RedumpOrg.Sections.SizeAndChecksumsSection;
using SubmissionInfo = SabreTools.RedumpLib.RedumpOrg.SubmissionInfo;
using TracksAndWriteOffsetsSection = SabreTools.RedumpLib.RedumpOrg.Sections.TracksAndWriteOffsetsSection;
using VersionAndEditionsSection = SabreTools.RedumpLib.RedumpOrg.Sections.VersionAndEditionsSection;
namespace SabreTools.RedumpLib.Test
{
// TODO: Remove all references to redump.org submission information
public class SubmissionInfoTests
{
[Fact]
public void EmptySerializationTest()
public void DefaultSerializationTest()
{
var submissionInfo = new SubmissionInfo();
string json = JsonConvert.SerializeObject(submissionInfo, Formatting.Indented);
Assert.NotNull(json);
}
[Fact]
public void PartialSerializationTest()
{
var submissionInfo = new SubmissionInfo()
{
CommonDiscInfo = new CommonDiscInfoSection(),
VersionAndEditions = new VersionAndEditionsSection(),
EDC = new EDCSection(),
ParentCloneRelationship = new ParentCloneRelationshipSection(),
Extras = new ExtrasSection(),
CopyProtection = new CopyProtectionSection(),
DumpersAndStatus = new DumpersAndStatusSection(),
TracksAndWriteOffsets = new TracksAndWriteOffsetsSection(),
SizeAndChecksums = new SizeAndChecksumsSection(),
};
string json = JsonConvert.SerializeObject(submissionInfo, Formatting.Indented);
Assert.NotNull(json);
}
[Fact]
public void FullSerializationTest()
{
var submissionInfo = new SubmissionInfo()
{
SchemaVersion = 1,
FullyMatchedID = 3,
FullyMatchedIDs = [3],
PartiallyMatchedIDs = [0, 1, 2, 3],
Added = DateTime.UtcNow,
LastModified = DateTime.UtcNow,
CommonDiscInfo = new CommonDiscInfoSection()
DiscIdentity = new DiscIdentitySection()
{
System = PhysicalSystem.IBMPCcompatible,
Media = MediaType.CD,
Title = "Game Title",
ForeignTitleNonLatin = "Foreign Game Title",
DiscNumberLetter = "1",
DiscTitle = "Install Disc",
Category = DiscCategory.Games,
Region = Region.World,
Title = "Game Title",
ForeignTitle = "Foreign Game Title",
DiscNumber = "1",
DiscTitle = "Install Disc",
FilenameSuffix = "(Alt)",
},
RegionsAndLanguages = new RegionsAndLanguagesSection()
{
Regions = [Region.World],
Languages = [Language.English, Language.Spanish, Language.French],
LanguageSelection = [LanguageSelection.BiosSettings],
Serial = "Disc Serial",
Layer0MasteringRing = "L0 Mastering Ring",
},
DiscIdentifiers = new DiscIdentifiersSection()
{
DiscSerials = "Disc Serial",
Editions = "Rerelease",
Barcodes = "UPC Barcode",
Version = "Original",
ErrorCount = "0",
EXEDate = "19xx-xx-xx",
EDC = YesNo.Yes,
Layerbreak = 0,
Layerbreak2 = 1,
Layerbreak3 = 2,
DiscID = "Disc ID",
DiscKey = "Disc key",
UniversalHash = "SHA-1 hash",
},
RingCodes = new RingCodesSection()
{
Layer0MasteringCode = "L0 Mastering Ring",
Layer0MasteringSID = "L0 Mastering SID",
Layer0ToolstampMasteringCode = "L0 Toolstamp",
Layer0MouldSID = "L0 Mould SID",
Layer0AdditionalMould = "L0 Additional Mould",
Layer1MasteringRing = "L1 Mastering Ring",
Layer0Toolstamps = "L0 Toolstamp",
Layer0MouldSIDs = "L0 Mould SID",
Layer0AdditionalMoulds = "L0 Additional Mould",
Layer1MasteringCode = "L1 Mastering Ring",
Layer1MasteringSID = "L1 Mastering SID",
Layer1ToolstampMasteringCode = "L1 Toolstamp",
Layer1MouldSID = "L1 Mould SID",
Layer1AdditionalMould = "L1 Additional Mould",
Layer2MasteringRing = "L2 Mastering Ring",
Layer1Toolstamps = "L1 Toolstamp",
Layer1MouldSIDs = "L1 Mould SID",
Layer1AdditionalMoulds = "L1 Additional Mould",
Layer2MasteringCode = "L2 Mastering Ring",
Layer2MasteringSID = "L2 Mastering SID",
Layer2ToolstampMasteringCode = "L2 Toolstamp",
Layer3MasteringRing = "L3 Mastering Ring",
Layer2Toolstamps = "L2 Toolstamp",
Layer2MouldSIDs = "L2 Mould SID",
Layer2AdditionalMoulds = "L2 Additional Mould",
Layer3MasteringCode = "L3 Mastering Ring",
Layer3MasteringSID = "L3 Mastering SID",
Layer3ToolstampMasteringCode = "L3 Toolstamp",
RingWriteOffset = "+12",
Barcode = "UPC Barcode",
EXEDateBuildDate = "19xx-xx-xx",
ErrorsCount = "0",
Layer3Toolstamps = "L3 Toolstamp",
Layer3MouldSIDs = "L3 Mould SID",
Layer3AdditionalMoulds = "L3 Additional Mould",
LabelSideMasteringCode = "LS Mastering Ring",
LabelSideMasteringSID = "LS Mastering SID",
LabelSideToolstamps = "LS Toolstamp",
LabelSideMouldSIDs = "LS Mould SID",
LabelSideAdditionalMoulds = "LS Additional Mould",
WriteOffset = "+12",
SampleStart = "+357",
},
DumpMetadata = new DumpMetadataSection()
{
Comments = "Comment data line 1\r\nComment data line 2",
CommentsSpecialFields = new Dictionary<SiteCode, string>()
{
@@ -102,79 +106,38 @@ namespace SabreTools.RedumpLib.Test
{
[SiteCode.PlayableDemos] = "Game Demo 1",
},
},
VersionAndEditions = new VersionAndEditionsSection()
{
Version = "Original",
VersionDatfile = "Alt",
CommonEditions = ["Taikenban"],
OtherEditions = "Rerelease",
},
EDC = new EDCSection()
{
EDC = YesNo.Yes,
},
ParentCloneRelationship = new ParentCloneRelationshipSection()
{
ParentID = "12345",
RegionalParent = false,
},
Extras = new ExtrasSection()
{
Protection = "List of protections",
SectorRanges = "SSv1 Ranges",
SBI = "SecuROM data",
PVD = "PVD",
DiscKey = "Disc key",
DiscID = "Disc ID",
PIC = "PIC",
Header = "Header",
BCA = "BCA",
SecuritySectorRanges = "SSv1 Ranges",
},
CopyProtection = new CopyProtectionSection()
{
AntiModchip = YesNo.Yes,
LibCrypt = YesNo.No,
LibCryptData = "LibCrypt data",
Protection = "List of protections",
SecuROMData = "SecuROM data",
},
DumpersAndStatus = new DumpersAndStatusSection()
{
Status = DumpStatus.VerifiedGreen,
Dumpers = ["Dumper1", "Dumper2"],
OtherDumpers = "Dumper3",
},
TracksAndWriteOffsets = new TracksAndWriteOffsetsSection()
{
ClrMameProData = "Datfile",
PIC = "PIC",
PICIdentifier = "XB4",
Cuesheet = "Cuesheet",
CuesheetRaw = [0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39],
CommonWriteOffsets = [0, 12, -12],
OtherWriteOffsets = "-2",
Dat = "Datfile",
},
SizeAndChecksums = new SizeAndChecksumsSection()
SubmissionControls = new SubmissionControlsSection()
{
Layerbreak = 0,
Layerbreak2 = 1,
Layerbreak3 = 2,
DumpLog = "Redumper log",
LogsArchiveURL = "Logs URL",
ReviewComment = "Fine, I guess",
SubmissionComment = "Ignore the 3500 errors please",
SubmitAs = "SelfAutomaton",
},
DumpingInfo = new DumpingInfoSection()
{
DumpingProgram = "DiscImageCreator 20500101",
FrontendVersion = "10.0.0",
DumpingProgram = "Redumper b000",
DumpingDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"),
DumpingParameters = "cd dvd bd sacd fd hdd",
DumpingParameters = "disc --drive=C:\\",
Manufacturer = "ATAPI",
Model = "Optical Drive",
Model = "Optical Disc Drive",
Firmware = "1.23",
ReportedDiscType = "CD-R",
C2ErrorsCount = "0",
},
Artifacts = new Dictionary<string, string>()

View File

@@ -9,6 +9,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Newtonsoft.Json;
using SabreTools.RedumpLib.Data;
using SabreTools.RedumpLib.Web;
namespace SabreTools.RedumpLib.Tools
{
@@ -52,7 +53,7 @@ namespace SabreTools.RedumpLib.Tools
/// <param name="info">Existing SubmissionInfo object to fill</param>
/// <param name="id">Redump disc ID to retrieve</param>
/// <param name="includeAllData">True to include all pullable information, false to do bare minimum</param>
public static async Task<bool> FillFromId(Web.Client client, SubmissionInfo info, int id, bool includeAllData)
public static async Task<bool> FillFromId(Client client, SubmissionInfo info, int id, bool includeAllData)
{
var discData = await client.DownloadSingleDiscPage(id);
if (string.IsNullOrEmpty(discData))