2024-12-05 21:51:25 -05:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using SabreTools.RedumpLib.Data;
|
|
|
|
|
using Xunit;
|
2025-10-07 18:07:46 -04:00
|
|
|
using LogCompression = MPF.Processors.LogCompression;
|
2025-05-30 12:43:25 -04:00
|
|
|
using RedumperDriveType = MPF.ExecutionContexts.Redumper.DriveType;
|
2024-12-05 21:51:25 -05:00
|
|
|
using RedumperReadMethod = MPF.ExecutionContexts.Redumper.ReadMethod;
|
|
|
|
|
using RedumperSectorOrder = MPF.ExecutionContexts.Redumper.SectorOrder;
|
|
|
|
|
|
|
|
|
|
namespace MPF.Frontend.Test
|
|
|
|
|
{
|
|
|
|
|
public class EnumExtensionsTests
|
|
|
|
|
{
|
|
|
|
|
#region Long Name
|
|
|
|
|
|
2025-10-16 20:28:37 -04:00
|
|
|
[Theory]
|
|
|
|
|
[InlineData(null, "Unknown")]
|
|
|
|
|
[InlineData(InterfaceLanguage.AutoDetect, "Auto Detect")]
|
|
|
|
|
[InlineData(InterfaceLanguage.English, "English")]
|
2025-10-17 17:26:56 -04:00
|
|
|
[InlineData(InterfaceLanguage.French, "Français")]
|
|
|
|
|
[InlineData(InterfaceLanguage.German, "Deutsch")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Italian, "Italiano")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Japanese, "日本語")]
|
2025-10-16 20:28:37 -04:00
|
|
|
[InlineData(InterfaceLanguage.Korean, "한국어")]
|
2025-10-17 17:26:56 -04:00
|
|
|
[InlineData(InterfaceLanguage.Polish, "Polski")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Russian, "Русский")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Spanish, "Español")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Swedish, "Svenska")]
|
2025-10-18 18:10:45 -04:00
|
|
|
[InlineData(InterfaceLanguage.Ukrainian, "Українська")]
|
2025-10-27 23:04:00 +09:00
|
|
|
[InlineData(InterfaceLanguage.L337, "L337")]
|
2025-10-16 20:28:37 -04:00
|
|
|
public void LongName_InterfaceLanguage(InterfaceLanguage? lang, string? expected)
|
|
|
|
|
{
|
|
|
|
|
string? actual = lang.LongName();
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
|
2026-01-25 18:09:00 -05:00
|
|
|
if (lang is not null)
|
2025-10-16 20:28:37 -04:00
|
|
|
{
|
|
|
|
|
actual = EnumExtensions.GetLongName(lang);
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-05 21:51:25 -05:00
|
|
|
[Theory]
|
|
|
|
|
[InlineData(null, "Unknown")]
|
|
|
|
|
[InlineData(InternalProgram.NONE, "Unknown")]
|
|
|
|
|
[InlineData(InternalProgram.Aaru, "Aaru")]
|
|
|
|
|
[InlineData(InternalProgram.DiscImageCreator, "DiscImageCreator")]
|
2026-01-27 16:16:34 -05:00
|
|
|
// [InlineData(InternalProgram.Dreamdump, "Dreamdump")]
|
2024-12-05 21:51:25 -05:00
|
|
|
[InlineData(InternalProgram.Redumper, "Redumper")]
|
|
|
|
|
[InlineData(InternalProgram.CleanRip, "CleanRip")]
|
|
|
|
|
[InlineData(InternalProgram.PS3CFW, "PS3 CFW")]
|
|
|
|
|
[InlineData(InternalProgram.UmdImageCreator, "UmdImageCreator")]
|
|
|
|
|
[InlineData(InternalProgram.XboxBackupCreator, "XboxBackupCreator")]
|
|
|
|
|
public void LongName_InternalProgram(InternalProgram? prog, string? expected)
|
|
|
|
|
{
|
|
|
|
|
string? actual = prog.LongName();
|
|
|
|
|
Assert.Equal(expected, actual);
|
2025-10-07 19:43:34 -04:00
|
|
|
|
2026-01-25 18:09:00 -05:00
|
|
|
if (prog is not null)
|
2025-10-07 19:43:34 -04:00
|
|
|
{
|
|
|
|
|
actual = EnumExtensions.GetLongName(prog);
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
2024-12-05 21:51:25 -05:00
|
|
|
}
|
|
|
|
|
|
2025-10-07 18:07:46 -04:00
|
|
|
[Theory]
|
|
|
|
|
[InlineData(null, "Unknown")]
|
|
|
|
|
[InlineData(LogCompression.DeflateDefault, "ZIP using Deflate (Level 5)")]
|
|
|
|
|
[InlineData(LogCompression.DeflateMaximum, "ZIP using Deflate (Level 9)")]
|
2025-11-27 20:09:43 -05:00
|
|
|
[InlineData(LogCompression.Zstd19, "ZIP using Zstd (Level 19)")]
|
2025-10-07 18:07:46 -04:00
|
|
|
public void LongName_LogCompression(LogCompression? comp, string? expected)
|
|
|
|
|
{
|
|
|
|
|
string? actual = comp.LongName();
|
|
|
|
|
Assert.Equal(expected, actual);
|
2025-10-07 19:43:34 -04:00
|
|
|
|
2026-01-25 18:09:00 -05:00
|
|
|
if (comp is not null)
|
2025-10-07 19:43:34 -04:00
|
|
|
{
|
|
|
|
|
actual = EnumExtensions.GetLongName(comp);
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
2025-10-07 18:07:46 -04:00
|
|
|
}
|
|
|
|
|
|
2024-12-05 21:51:25 -05:00
|
|
|
[Theory]
|
|
|
|
|
[InlineData(null, "Unknown")]
|
|
|
|
|
[InlineData(RedumperReadMethod.NONE, "Default")]
|
|
|
|
|
[InlineData(RedumperReadMethod.D8, "D8")]
|
|
|
|
|
[InlineData(RedumperReadMethod.BE, "BE")]
|
|
|
|
|
public void LongName_RedumperReadMethod(RedumperReadMethod? method, string? expected)
|
|
|
|
|
{
|
|
|
|
|
string? actual = method.LongName();
|
|
|
|
|
Assert.Equal(expected, actual);
|
2025-10-07 19:43:34 -04:00
|
|
|
|
2026-01-25 18:09:00 -05:00
|
|
|
if (method is not null)
|
2025-10-07 19:43:34 -04:00
|
|
|
{
|
|
|
|
|
actual = EnumExtensions.GetLongName(method);
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
2024-12-05 21:51:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData(null, "Unknown")]
|
|
|
|
|
[InlineData(RedumperSectorOrder.NONE, "Default")]
|
|
|
|
|
[InlineData(RedumperSectorOrder.DATA_C2_SUB, "DATA_C2_SUB")]
|
|
|
|
|
[InlineData(RedumperSectorOrder.DATA_SUB_C2, "DATA_SUB_C2")]
|
|
|
|
|
[InlineData(RedumperSectorOrder.DATA_SUB, "DATA_SUB")]
|
|
|
|
|
[InlineData(RedumperSectorOrder.DATA_C2, "DATA_C2")]
|
|
|
|
|
public void LongName_RedumperSectorOrder(RedumperSectorOrder? order, string? expected)
|
|
|
|
|
{
|
|
|
|
|
string? actual = order.LongName();
|
|
|
|
|
Assert.Equal(expected, actual);
|
2025-10-07 19:43:34 -04:00
|
|
|
|
2026-01-25 18:09:00 -05:00
|
|
|
if (order is not null)
|
2025-10-07 19:43:34 -04:00
|
|
|
{
|
|
|
|
|
actual = EnumExtensions.GetLongName(order);
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
2024-12-05 21:51:25 -05:00
|
|
|
}
|
|
|
|
|
|
2025-05-31 01:40:22 +09:00
|
|
|
[Theory]
|
|
|
|
|
[InlineData(null, "Unknown")]
|
|
|
|
|
[InlineData(RedumperDriveType.NONE, "Default")]
|
|
|
|
|
[InlineData(RedumperDriveType.GENERIC, "GENERIC")]
|
|
|
|
|
[InlineData(RedumperDriveType.PLEXTOR, "PLEXTOR")]
|
2025-12-15 23:56:49 +09:00
|
|
|
[InlineData(RedumperDriveType.MTK8A, "MTK8A")]
|
|
|
|
|
[InlineData(RedumperDriveType.MTK8B, "MTK8B")]
|
|
|
|
|
[InlineData(RedumperDriveType.MTK8C, "MTK8C")]
|
|
|
|
|
[InlineData(RedumperDriveType.MTK3, "MTK3")]
|
|
|
|
|
[InlineData(RedumperDriveType.MTK2, "MTK2")]
|
2025-05-31 01:40:22 +09:00
|
|
|
public void LongName_RedumperDriveType(RedumperDriveType? type, string? expected)
|
|
|
|
|
{
|
|
|
|
|
string? actual = type.LongName();
|
|
|
|
|
Assert.Equal(expected, actual);
|
2025-10-07 19:43:34 -04:00
|
|
|
|
2026-01-25 18:09:00 -05:00
|
|
|
if (type is not null)
|
2025-10-07 19:43:34 -04:00
|
|
|
{
|
|
|
|
|
actual = EnumExtensions.GetLongName(type);
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
2025-05-31 01:40:22 +09:00
|
|
|
}
|
|
|
|
|
|
2024-12-05 21:51:25 -05:00
|
|
|
#endregion
|
|
|
|
|
|
2024-12-31 13:43:57 -05:00
|
|
|
#region Short Name
|
|
|
|
|
|
2025-10-16 20:28:37 -04:00
|
|
|
[Theory]
|
|
|
|
|
[InlineData(null, "Unknown")]
|
2025-10-16 22:35:31 -04:00
|
|
|
[InlineData(InterfaceLanguage.AutoDetect, "auto")]
|
2025-10-16 20:28:37 -04:00
|
|
|
[InlineData(InterfaceLanguage.English, "eng")]
|
2025-10-17 17:26:56 -04:00
|
|
|
[InlineData(InterfaceLanguage.French, "fra")]
|
|
|
|
|
[InlineData(InterfaceLanguage.German, "deu")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Italian, "ita")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Japanese, "jpn")]
|
2025-10-16 20:28:37 -04:00
|
|
|
[InlineData(InterfaceLanguage.Korean, "kor")]
|
2025-10-17 17:26:56 -04:00
|
|
|
[InlineData(InterfaceLanguage.Polish, "pol")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Russian, "rus")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Spanish, "spa")]
|
|
|
|
|
[InlineData(InterfaceLanguage.Swedish, "swe")]
|
2025-10-18 18:10:45 -04:00
|
|
|
[InlineData(InterfaceLanguage.Ukrainian, "ukr")]
|
2025-10-27 23:04:00 +09:00
|
|
|
[InlineData(InterfaceLanguage.L337, "l37")]
|
2025-10-16 20:28:37 -04:00
|
|
|
public void ShortName_InterfaceLanguage(InterfaceLanguage? lang, string? expected)
|
|
|
|
|
{
|
|
|
|
|
string? actual = lang.ShortName();
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-31 13:43:57 -05:00
|
|
|
[Theory]
|
|
|
|
|
[InlineData(null, "Unknown")]
|
|
|
|
|
[InlineData(InternalProgram.NONE, "Unknown")]
|
|
|
|
|
[InlineData(InternalProgram.Aaru, "aaru")]
|
|
|
|
|
[InlineData(InternalProgram.DiscImageCreator, "dic")]
|
2026-01-27 16:16:34 -05:00
|
|
|
// [InlineData(InternalProgram.Dreamdump, "dreamdump")]
|
2024-12-31 13:43:57 -05:00
|
|
|
[InlineData(InternalProgram.Redumper, "redumper")]
|
|
|
|
|
[InlineData(InternalProgram.CleanRip, "cleanrip")]
|
2024-12-31 15:10:43 -05:00
|
|
|
[InlineData(InternalProgram.PS3CFW, "ps3cfw")]
|
2024-12-31 13:43:57 -05:00
|
|
|
[InlineData(InternalProgram.UmdImageCreator, "uic")]
|
|
|
|
|
[InlineData(InternalProgram.XboxBackupCreator, "xbc")]
|
|
|
|
|
public void ShortName_InternalProgram(InternalProgram? prog, string? expected)
|
|
|
|
|
{
|
|
|
|
|
string? actual = prog.ShortName();
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2024-12-05 21:51:25 -05:00
|
|
|
#region From String
|
|
|
|
|
|
2024-12-31 13:43:57 -05:00
|
|
|
[Theory]
|
2025-10-16 20:28:37 -04:00
|
|
|
[InlineData(null, InterfaceLanguage.AutoDetect)]
|
|
|
|
|
[InlineData("", InterfaceLanguage.AutoDetect)]
|
2025-10-16 22:35:31 -04:00
|
|
|
[InlineData("auto", InterfaceLanguage.AutoDetect)]
|
2025-10-16 20:28:37 -04:00
|
|
|
[InlineData("eng", InterfaceLanguage.English)]
|
2025-10-17 17:26:56 -04:00
|
|
|
[InlineData("fra", InterfaceLanguage.French)]
|
|
|
|
|
[InlineData("deu", InterfaceLanguage.German)]
|
|
|
|
|
[InlineData("ita", InterfaceLanguage.Italian)]
|
|
|
|
|
[InlineData("jpn", InterfaceLanguage.Japanese)]
|
2025-10-16 20:28:37 -04:00
|
|
|
[InlineData("kor", InterfaceLanguage.Korean)]
|
2025-10-17 17:26:56 -04:00
|
|
|
[InlineData("pol", InterfaceLanguage.Polish)]
|
|
|
|
|
[InlineData("rus", InterfaceLanguage.Russian)]
|
|
|
|
|
[InlineData("spa", InterfaceLanguage.Spanish)]
|
|
|
|
|
[InlineData("swe", InterfaceLanguage.Swedish)]
|
2025-10-18 18:10:45 -04:00
|
|
|
[InlineData("ukr", InterfaceLanguage.Ukrainian)]
|
2025-10-27 23:04:00 +09:00
|
|
|
[InlineData("l37", InterfaceLanguage.L337)]
|
2025-10-16 20:28:37 -04:00
|
|
|
public void ToInterfaceLanguageTest(string? interfaceLanguage, InterfaceLanguage expected)
|
|
|
|
|
{
|
|
|
|
|
InterfaceLanguage actual = interfaceLanguage.ToInterfaceLanguage();
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
2024-12-31 13:43:57 -05:00
|
|
|
[InlineData(null, InternalProgram.NONE)]
|
|
|
|
|
[InlineData("", InternalProgram.NONE)]
|
|
|
|
|
[InlineData("aaru", InternalProgram.Aaru)]
|
|
|
|
|
[InlineData("dic", InternalProgram.DiscImageCreator)]
|
2026-01-27 16:16:34 -05:00
|
|
|
// [InlineData("dreamdump", InternalProgram.Dreamdump)]
|
2024-12-31 13:43:57 -05:00
|
|
|
[InlineData("redumper", InternalProgram.Redumper)]
|
|
|
|
|
[InlineData("cleanrip", InternalProgram.CleanRip)]
|
|
|
|
|
[InlineData("ps3cfw", InternalProgram.PS3CFW)]
|
|
|
|
|
[InlineData("uic", InternalProgram.UmdImageCreator)]
|
|
|
|
|
[InlineData("xbc", InternalProgram.XboxBackupCreator)]
|
|
|
|
|
public void ToInternalProgramTest(string? internalProgram, InternalProgram expected)
|
|
|
|
|
{
|
|
|
|
|
InternalProgram actual = internalProgram.ToInternalProgram();
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Write remaining from-string tests
|
2024-12-05 21:51:25 -05:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Functionality Support
|
|
|
|
|
|
|
|
|
|
private static readonly RedumpSystem?[] _antiModchipSystems =
|
|
|
|
|
[
|
|
|
|
|
RedumpSystem.SonyPlayStation,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
private static readonly RedumpSystem?[] _copyProtectionSystems =
|
|
|
|
|
[
|
|
|
|
|
RedumpSystem.AppleMacintosh,
|
2025-11-07 09:58:28 -05:00
|
|
|
RedumpSystem.DVDVideo,
|
2024-12-05 21:51:25 -05:00
|
|
|
RedumpSystem.EnhancedCD ,
|
|
|
|
|
RedumpSystem.IBMPCcompatible,
|
|
|
|
|
RedumpSystem.PalmOS,
|
|
|
|
|
RedumpSystem.PocketPC,
|
|
|
|
|
RedumpSystem.RainbowDisc,
|
|
|
|
|
RedumpSystem.SonyElectronicBook,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[MemberData(nameof(GenerateSupportsAntiModchipScansData))]
|
|
|
|
|
public void SupportsAntiModchipScansTest(RedumpSystem? redumpSystem, bool expected)
|
|
|
|
|
{
|
|
|
|
|
bool actual = redumpSystem.SupportsAntiModchipScans();
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[MemberData(nameof(GenerateSupportsCopyProtectionScansData))]
|
|
|
|
|
public void SupportsCopyProtectionScansTest(RedumpSystem? redumpSystem, bool expected)
|
|
|
|
|
{
|
|
|
|
|
bool actual = redumpSystem.SupportsCopyProtectionScans();
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<object?[]> GenerateSupportsAntiModchipScansData()
|
|
|
|
|
{
|
|
|
|
|
var testData = new List<object?[]>() { new object?[] { null, false } };
|
2025-11-11 15:52:26 -05:00
|
|
|
foreach (RedumpSystem redumpSystem in Enum.GetValues<RedumpSystem>())
|
2024-12-05 21:51:25 -05:00
|
|
|
{
|
|
|
|
|
if (_antiModchipSystems.Contains(redumpSystem))
|
|
|
|
|
testData.Add([redumpSystem, true]);
|
|
|
|
|
else
|
|
|
|
|
testData.Add([redumpSystem, false]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return testData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<object?[]> GenerateSupportsCopyProtectionScansData()
|
|
|
|
|
{
|
|
|
|
|
var testData = new List<object?[]>() { new object?[] { null, false } };
|
2025-11-11 15:52:26 -05:00
|
|
|
foreach (RedumpSystem redumpSystem in Enum.GetValues<RedumpSystem>())
|
2024-12-05 21:51:25 -05:00
|
|
|
{
|
|
|
|
|
if (_copyProtectionSystems.Contains(redumpSystem))
|
|
|
|
|
testData.Add([redumpSystem, true]);
|
|
|
|
|
else
|
|
|
|
|
testData.Add([redumpSystem, false]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return testData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
2025-05-31 01:40:22 +09:00
|
|
|
}
|