mirror of
https://github.com/SabreTools/MPF.git
synced 2026-02-04 05:35:52 +00:00
Add DetermineMediaType scaffolding and tests
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
- Further clarify configuration requirements for CLI
|
||||
- Ignore volume labels with path separators
|
||||
- Reduce media-specific checks where unnecessary
|
||||
- Add DetermineMediaType scaffolding and tests
|
||||
|
||||
### 3.3.2 (2025-06-12)
|
||||
|
||||
|
||||
@@ -11,6 +11,34 @@ namespace MPF.Processors.Test
|
||||
// TODO: Add tests around remaining helper methods
|
||||
public class AaruTests
|
||||
{
|
||||
#region DetermineMediaType
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Null_Throws()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Invalid_Throws()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Valid_Throws()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Aaru", "CDROM", "test");
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -7,6 +7,91 @@ namespace MPF.Processors.Test
|
||||
{
|
||||
public class CleanRipTests
|
||||
{
|
||||
#region DetermineMediaType
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_GC_Null_GC()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.NintendoGameCubeGameDisc, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Wii_Null_Wii()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new CleanRip(RedumpSystem.NintendoWii, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.NintendoWiiOpticalDisc, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Other_Null_Null()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new CleanRip(RedumpSystem.IBMPCcompatible, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_GC_Invalid_GC()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.NintendoGameCubeGameDisc, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Wii_Invalid_Wii()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new CleanRip(RedumpSystem.NintendoWii, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.NintendoWiiOpticalDisc, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Other_Invalid_Invalid()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new CleanRip(RedumpSystem.IBMPCcompatible, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_GC_Valid_GC()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "CleanRip", "DVD", "test");
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.NintendoGameCubeGameDisc, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Wii_Valid_Wii()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "CleanRip", "DVD", "test");
|
||||
var processor = new CleanRip(RedumpSystem.NintendoWii, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.NintendoWiiOpticalDisc, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Other_Valid_Valid()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "CleanRip", "DVD", "test");
|
||||
var processor = new CleanRip(RedumpSystem.IBMPCcompatible, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -10,6 +10,34 @@ namespace MPF.Processors.Test
|
||||
// TODO: Add tests around remaining helper methods
|
||||
public class DiscImageCreatorTests
|
||||
{
|
||||
#region DetermineMediaType
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Null_Throws()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Invalid_Throws()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Valid_Throws()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "CDROM", "test");
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using SabreTools.Models.Logiqx;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
@@ -8,6 +7,37 @@ namespace MPF.Processors.Test
|
||||
{
|
||||
public class PS3CFWTests
|
||||
{
|
||||
#region DetermineMediaType
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Null_BluRay()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.BluRay, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Invalid_BluRay()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.BluRay, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Valid_BluRay()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "PS3CFW", "BluRay", "test");
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.BluRay, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -8,6 +8,34 @@ namespace MPF.Processors.Test
|
||||
{
|
||||
public class RedumperTests
|
||||
{
|
||||
#region DetermineMediaType
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Null_Throws()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Invalid_Throws()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Valid_Throws()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Redumper", "CDROM", "test");
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -8,6 +8,37 @@ namespace MPF.Processors.Test
|
||||
{
|
||||
public class UmdImageCreatorTests
|
||||
{
|
||||
#region DetermineMediaType
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Null_DVD()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.UMD, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Invalid_DVD()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.UMD, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Valid_DVD()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD", "test");
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.UMD, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
@@ -289,7 +320,7 @@ namespace MPF.Processors.Test
|
||||
{
|
||||
string volDesc = string.Empty;
|
||||
bool actual = UmdImageCreator.GetVolumeLabels(volDesc, out Dictionary<string, List<string>> volLabels);
|
||||
|
||||
|
||||
Assert.False(actual);
|
||||
Assert.Empty(volLabels);
|
||||
}
|
||||
@@ -299,7 +330,7 @@ namespace MPF.Processors.Test
|
||||
{
|
||||
string volDesc = "INVALID";
|
||||
bool actual = UmdImageCreator.GetVolumeLabels(volDesc, out Dictionary<string, List<string>> volLabels);
|
||||
|
||||
|
||||
Assert.False(actual);
|
||||
Assert.Empty(volLabels);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,37 @@ namespace MPF.Processors.Test
|
||||
// TODO: Add tests for RecreateSS
|
||||
public class XboxBackupCreatorTests
|
||||
{
|
||||
#region DetermineMediaType
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Null_DVD()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.DVD, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Invalid_DVD()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.DVD, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Valid_DVD()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "XboxBackupCreator", "DVD", "test");
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(MediaType.DVD, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -26,6 +26,12 @@ namespace MPF.Processors
|
||||
|
||||
#region BaseProcessor Implementations
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? basePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -45,6 +45,13 @@ namespace MPF.Processors
|
||||
|
||||
#region Abstract Methods
|
||||
|
||||
/// <summary>
|
||||
/// Determine the media type based on the provided files
|
||||
/// </summary>
|
||||
/// <param name="basePath">Base filename and path to use for checking</param>
|
||||
/// <returns>MediaType that was determined, if possible</returns>
|
||||
public abstract MediaType? DetermineMediaType(string? basePath);
|
||||
|
||||
/// <summary>
|
||||
/// Generate a SubmissionInfo for the output files
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SabreTools.Hashing;
|
||||
@@ -18,6 +19,17 @@ namespace MPF.Processors
|
||||
|
||||
#region BaseProcessor Implementations
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? basePath)
|
||||
{
|
||||
return System switch
|
||||
{
|
||||
RedumpSystem.NintendoGameCube => MediaType.NintendoGameCubeGameDisc,
|
||||
RedumpSystem.NintendoWii => MediaType.NintendoWiiOpticalDisc,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -67,6 +67,12 @@ namespace MPF.Processors
|
||||
|
||||
#region BaseProcessor Implementations
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? basePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,12 @@ namespace MPF.Processors
|
||||
|
||||
#region BaseProcessor Implementations
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? basePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,10 @@ namespace MPF.Processors
|
||||
|
||||
#region BaseProcessor Implementations
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? basePath)
|
||||
=> MediaType.BluRay;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,12 @@ namespace MPF.Processors
|
||||
|
||||
#region BaseProcessor Implementations
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? basePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,10 @@ namespace MPF.Processors
|
||||
|
||||
#region BaseProcessor Implementations
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? basePath)
|
||||
=> MediaType.UMD;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,10 @@ namespace MPF.Processors
|
||||
|
||||
#region BaseProcessor Implementations
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? basePath)
|
||||
=> MediaType.DVD;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user