mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Add processor base implementation tests
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
- Add skeleton test projects for individual libraries
|
||||
- Move existing tests to new projects
|
||||
- Add BaseProcessor tests
|
||||
- Add processor base implementation tests
|
||||
|
||||
### 3.2.4 (2024-11-24)
|
||||
|
||||
|
||||
168
MPF.Processors.Test/AaruTests.cs
Normal file
168
MPF.Processors.Test/AaruTests.cs
Normal file
@@ -0,0 +1,168 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
namespace MPF.Processors.Test
|
||||
{
|
||||
public class AaruTests
|
||||
{
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Null_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, null);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_CDROM_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(8, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_DVD_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.DVD);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(7, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_HDDVD_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.HDDVD);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(7, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_BluRay_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.BluRay);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(7, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Other_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.ApertureCard);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Aaru", "CDROM", "test");
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Equal(7, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckRequiredFiles
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Invalid_Filled()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Equal(7, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Aaru", "CDROM", "test");
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDeleteableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Aaru", "CDROM", "test");
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetZippableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Aaru", "CDROM", "test");
|
||||
var processor = new Aaru(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Equal(7, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
157
MPF.Processors.Test/CleanRipTests.cs
Normal file
157
MPF.Processors.Test/CleanRipTests.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
namespace MPF.Processors.Test
|
||||
{
|
||||
public class CleanRipTests
|
||||
{
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Null_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, null);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_DVD_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(3, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_NintendoGameCubeGameDisc_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.NintendoGameCubeGameDisc);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(3, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_NintendoWiiOpticalDisc_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.NintendoWiiOpticalDisc);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(3, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Other_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.ApertureCard);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "CleanRip", "DVD", "test");
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Equal(2, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckRequiredFiles
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Invalid_Filled()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Equal(3, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "CleanRip", "DVD", "test");
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDeleteableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "CleanRip", "DVD", "test");
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetZippableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "CleanRip", "DVD", "test");
|
||||
var processor = new CleanRip(RedumpSystem.NintendoGameCube, MediaType.DVD);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Equal(2, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
223
MPF.Processors.Test/DiscImageCreatorTests.cs
Normal file
223
MPF.Processors.Test/DiscImageCreatorTests.cs
Normal file
@@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
namespace MPF.Processors.Test
|
||||
{
|
||||
public class DiscImageCreatorTests
|
||||
{
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Null_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, null);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_CDROM_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(26, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_GDROM_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.GDROM);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(10, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_DVD_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.DVD);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(16, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_HDDVD_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.HDDVD);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(16, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_BluRay_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.BluRay);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(16, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_NintendoGameCubeGameDisc_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.NintendoGameCubeGameDisc);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(16, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_NintendoWiiOpticalDisc_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.NintendoWiiOpticalDisc);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(16, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_FloppyDisk_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.FloppyDisk);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(4, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_HardDisk_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.HardDisk);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(4, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Other_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.ApertureCard);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "CDROM", "test");
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Equal(21, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckRequiredFiles
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Invalid_Filled()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Equal(17, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "CDROM", "test");
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDeleteableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "CDROM", "test");
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Equal(2, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetZippableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "CDROM", "test");
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Equal(23, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
135
MPF.Processors.Test/PS3CFWTests.cs
Normal file
135
MPF.Processors.Test/PS3CFWTests.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
namespace MPF.Processors.Test
|
||||
{
|
||||
public class PS3CFWTests
|
||||
{
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Null_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, null);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_BluRay_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(3, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Other_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.ApertureCard);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "PS3CFW", "BluRay", "test");
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Equal(2, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckRequiredFiles
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Invalid_Filled()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Equal(3, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "PS3CFW", "BluRay", "test");
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDeleteableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "PS3CFW", "BluRay", "test");
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetZippableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "PS3CFW", "BluRay", "test");
|
||||
var processor = new PS3CFW(RedumpSystem.SonyPlayStation3, MediaType.BluRay);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Equal(2, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
168
MPF.Processors.Test/RedumperTests.cs
Normal file
168
MPF.Processors.Test/RedumperTests.cs
Normal file
@@ -0,0 +1,168 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
namespace MPF.Processors.Test
|
||||
{
|
||||
public class RedumperTests
|
||||
{
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Null_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, null);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_CDROM_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(14, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_DVD_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.DVD);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(16, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_HDDVD_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.HDDVD);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(10, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_BluRay_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.BluRay);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(10, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Other_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.ApertureCard);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Redumper", "CDROM", "test");
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Equal(11, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckRequiredFiles
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Invalid_Filled()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Equal(8, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Redumper", "CDROM", "test");
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDeleteableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Valid_Single()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Redumper", "CDROM", "test");
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Single(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetZippableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "Redumper", "CDROM", "test");
|
||||
var processor = new Redumper(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Equal(11, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.aaruf
Normal file
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.aaruf
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.cicm.xml
Normal file
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.cicm.xml
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.ibg
Normal file
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.ibg
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.mhddlog.bin
Normal file
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.mhddlog.bin
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.resume.xml
Normal file
1
MPF.Processors.Test/TestData/Aaru/CDROM/test.resume.xml
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/CleanRip/DVD/test.bca
Normal file
1
MPF.Processors.Test/TestData/CleanRip/DVD/test.bca
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/CleanRip/DVD/test.iso
Normal file
1
MPF.Processors.Test/TestData/CleanRip/DVD/test.iso
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/PS3CFW/BluRay/test.disc.pic
Normal file
1
MPF.Processors.Test/TestData/PS3CFW/BluRay/test.disc.pic
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/PS3CFW/BluRay/test.iso
Normal file
1
MPF.Processors.Test/TestData/PS3CFW/BluRay/test.iso
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.asus
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.asus
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.atip
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.atip
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.cdtext
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.cdtext
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.cue
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.cue
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.fulltoc
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.fulltoc
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.hash
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.hash
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.pma
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.pma
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.scram
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.scram
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.state
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.state
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.subcode
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.subcode
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.toc
Normal file
1
MPF.Processors.Test/TestData/Redumper/CDROM/test.toc
Normal file
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
@@ -0,0 +1 @@
|
||||
TEST DATA
|
||||
135
MPF.Processors.Test/UmdImageCreatorTests.cs
Normal file
135
MPF.Processors.Test/UmdImageCreatorTests.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
namespace MPF.Processors.Test
|
||||
{
|
||||
public class UmdImageCreatorTests
|
||||
{
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Null_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, null);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_UMD_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(7, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Other_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.ApertureCard);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD", "test");
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Equal(6, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckRequiredFiles
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Invalid_Filled()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Equal(5, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD", "test");
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDeleteableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD", "test");
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetZippableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD", "test");
|
||||
var processor = new UmdImageCreator(RedumpSystem.SonyPlayStationPortable, MediaType.UMD);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Equal(6, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
135
MPF.Processors.Test/XboxBackupCreatorTests.cs
Normal file
135
MPF.Processors.Test/XboxBackupCreatorTests.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
namespace MPF.Processors.Test
|
||||
{
|
||||
public class XboxBackupCreatorTests
|
||||
{
|
||||
#region GetOutputFiles
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Null_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, null);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_DVD_Populated()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Equal(7, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOutputFiles_Other_Empty()
|
||||
{
|
||||
string? baseDirectory = null;
|
||||
string baseFilename = "test";
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.ApertureCard);
|
||||
|
||||
var actual = processor.GetOutputFiles(baseDirectory, baseFilename);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateArtifacts
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateArtifacts_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "XboxBackupCreator", "DVD", "test");
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.GenerateArtifacts(basePath);
|
||||
Assert.Equal(6, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckRequiredFiles
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Invalid_Filled()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Equal(5, actual.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CheckRequiredFiles_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "XboxBackupCreator", "DVD", "test");
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.CheckRequiredFiles(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDeleteableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDeleteableFilePaths_Valid_Empty()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "XboxBackupCreator", "DVD", "test");
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.GetDeleteableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetZippableFilePaths
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Invalid_Empty()
|
||||
{
|
||||
string basePath = string.Empty;
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Empty(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetZippableFilePaths_Valid_Filled()
|
||||
{
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "XboxBackupCreator", "DVD", "test");
|
||||
var processor = new XboxBackupCreator(RedumpSystem.MicrosoftXbox, MediaType.DVD);
|
||||
var actual = processor.GetZippableFilePaths(basePath);
|
||||
Assert.Equal(6, actual.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -191,10 +191,8 @@ namespace MPF.Processors
|
||||
outputFilename = Path.GetFileNameWithoutExtension(outputFilename);
|
||||
|
||||
// Then get the base path for all checking
|
||||
string basePath;
|
||||
if (string.IsNullOrEmpty(outputDirectory))
|
||||
basePath = outputFilename;
|
||||
else
|
||||
string basePath = outputFilename;
|
||||
if (!string.IsNullOrEmpty(outputDirectory))
|
||||
basePath = Path.Combine(outputDirectory, outputFilename);
|
||||
|
||||
// Finally, let the parameters say if all files exist
|
||||
@@ -208,6 +206,10 @@ namespace MPF.Processors
|
||||
/// <returns>Dictiionary of artifact keys to Base64-encoded values, if possible</param>
|
||||
public Dictionary<string, string> GenerateArtifacts(string basePath)
|
||||
{
|
||||
// Handle invalid inputs
|
||||
if (basePath.Length == 0)
|
||||
return [];
|
||||
|
||||
// Split the base path for matching
|
||||
string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty;
|
||||
string baseFilename = Path.GetFileNameWithoutExtension(basePath);
|
||||
@@ -228,24 +230,24 @@ namespace MPF.Processors
|
||||
continue;
|
||||
|
||||
// Skip non-existent files
|
||||
foreach (string filename in outputFile.Filenames)
|
||||
{
|
||||
string possibleFile = Path.Combine(baseDirectory, filename);
|
||||
if (!File.Exists(possibleFile))
|
||||
continue;
|
||||
if (!outputFile.Exists(baseDirectory))
|
||||
continue;
|
||||
|
||||
// Skip non-existent files
|
||||
foreach (var filePath in outputFile.GetPaths(baseDirectory))
|
||||
{
|
||||
// Get binary artifacts as a byte array
|
||||
if (outputFile.IsBinaryArtifact)
|
||||
{
|
||||
byte[] data = File.ReadAllBytes(possibleFile);
|
||||
byte[] data = File.ReadAllBytes(filePath);
|
||||
string str = Convert.ToBase64String(data);
|
||||
artifacts.Add(outputFile.ArtifactKey, str);
|
||||
artifacts[outputFile.ArtifactKey] = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
string? data = ProcessingTool.GetFullFile(possibleFile);
|
||||
string? data = ProcessingTool.GetFullFile(filePath);
|
||||
string str = ProcessingTool.GetBase64(data) ?? string.Empty;
|
||||
artifacts.Add(outputFile.ArtifactKey, str);
|
||||
artifacts[outputFile.ArtifactKey] = str;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -331,7 +333,7 @@ namespace MPF.Processors
|
||||
/// </summary>
|
||||
/// <param name="basePath">Base filename and path to use for checking</param>
|
||||
/// <returns>A list representing missing files, empty if none</returns>
|
||||
private List<string> CheckRequiredFiles(string basePath)
|
||||
internal List<string> CheckRequiredFiles(string basePath)
|
||||
{
|
||||
// Split the base path for matching
|
||||
string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty;
|
||||
@@ -399,11 +401,11 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a list of all deleteable filenames
|
||||
/// Generate a list of all deleteable file paths
|
||||
/// </summary>
|
||||
/// <param name="basePath">Base filename and path to use for checking</param>
|
||||
/// <returns>List of all deleteable filenames, empty otherwise</returns>
|
||||
private List<string> GetDeleteableFilenames(string basePath)
|
||||
/// <returns>List of all deleteable file paths, empty otherwise</returns>
|
||||
internal List<string> GetDeleteableFilePaths(string basePath)
|
||||
{
|
||||
// Split the base path for matching
|
||||
string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty;
|
||||
@@ -415,48 +417,18 @@ namespace MPF.Processors
|
||||
return [];
|
||||
|
||||
// Filter down to deleteable files
|
||||
var deleteableFiles = outputFiles.FindAll(of => of.IsDeleteable);
|
||||
#if NET20
|
||||
var deleteableFilenames = new List<string>();
|
||||
foreach (var deleteableFile in deleteableFiles)
|
||||
var deleteable = outputFiles.FindAll(of => of.IsDeleteable);
|
||||
|
||||
// Get all paths that exist
|
||||
var deleteablePaths = new List<string>();
|
||||
foreach (var file in deleteable)
|
||||
{
|
||||
deleteableFilenames.AddRange(deleteableFile.Filenames);
|
||||
var paths = file.GetPaths(baseDirectory);
|
||||
paths = paths.FindAll(File.Exists);
|
||||
deleteablePaths.AddRange(paths);
|
||||
}
|
||||
|
||||
return deleteableFilenames;
|
||||
#else
|
||||
return deleteableFiles.SelectMany(of => of.Filenames).ToList();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a list of all deleteable file paths
|
||||
/// </summary>
|
||||
/// <param name="basePath">Base filename and path to use for checking</param>
|
||||
/// <returns>List of all deleteable file paths, empty otherwise</returns>
|
||||
private List<string> GetDeleteableFilePaths(string basePath)
|
||||
{
|
||||
// Split the base path for matching
|
||||
string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty;
|
||||
|
||||
// Get the list of deleteable files
|
||||
var deleteableFilenames = GetDeleteableFilenames(basePath);
|
||||
if (deleteableFilenames.Count == 0)
|
||||
return [];
|
||||
|
||||
// Return only files that exist
|
||||
var deleteableFiles = new List<string>();
|
||||
foreach (var filename in deleteableFilenames)
|
||||
{
|
||||
// Skip non-existent files
|
||||
string possiblePath = Path.Combine(baseDirectory, filename);
|
||||
if (!File.Exists(possiblePath))
|
||||
continue;
|
||||
|
||||
deleteableFiles.Add(possiblePath);
|
||||
}
|
||||
|
||||
return deleteableFiles;
|
||||
return deleteablePaths;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -514,11 +486,11 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a list of all zippable filenames
|
||||
/// Generate a list of all zippable file paths
|
||||
/// </summary>
|
||||
/// <param name="basePath">Base filename and path to use for checking</param>
|
||||
/// <returns>List of all zippable filenames, empty otherwise</returns>
|
||||
private List<string> GetZippableFilenames(string basePath)
|
||||
/// <returns>List of all zippable file paths, empty otherwise</returns>
|
||||
internal List<string> GetZippableFilePaths(string basePath)
|
||||
{
|
||||
// Split the base path for matching
|
||||
string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty;
|
||||
@@ -530,48 +502,18 @@ namespace MPF.Processors
|
||||
return [];
|
||||
|
||||
// Filter down to zippable files
|
||||
var zippableFiles = outputFiles.FindAll(of => of.IsZippable);
|
||||
#if NET20
|
||||
var zippableFilenames = new List<string>();
|
||||
foreach (var zippableFile in zippableFiles)
|
||||
var zippable = outputFiles.FindAll(of => of.IsZippable);
|
||||
|
||||
// Get all paths that exist
|
||||
var zippablePaths = new List<string>();
|
||||
foreach (var file in zippable)
|
||||
{
|
||||
zippableFilenames.AddRange(zippableFile.Filenames);
|
||||
var paths = file.GetPaths(baseDirectory);
|
||||
paths = paths.FindAll(File.Exists);
|
||||
zippablePaths.AddRange(paths);
|
||||
}
|
||||
|
||||
return zippableFilenames;
|
||||
#else
|
||||
return zippableFiles.SelectMany(of => of.Filenames).ToList();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a list of all zippable file paths
|
||||
/// </summary>
|
||||
/// <param name="basePath">Base filename and path to use for checking</param>
|
||||
/// <returns>List of all zippable file paths, empty otherwise</returns>
|
||||
private List<string> GetZippableFilePaths(string basePath)
|
||||
{
|
||||
// Split the base path for matching
|
||||
string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty;
|
||||
|
||||
// Get the list of zippable files
|
||||
var zippableFilenames = GetZippableFilenames(basePath);
|
||||
if (zippableFilenames.Count == 0)
|
||||
return [];
|
||||
|
||||
// Return only files that exist
|
||||
var zippableFiles = new List<string>();
|
||||
foreach (var filename in zippableFilenames)
|
||||
{
|
||||
// Skip non-existent files
|
||||
string possiblePath = Path.Combine(baseDirectory, filename);
|
||||
if (!File.Exists(possiblePath))
|
||||
continue;
|
||||
|
||||
zippableFiles.Add(possiblePath);
|
||||
}
|
||||
|
||||
return zippableFiles;
|
||||
return zippablePaths;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
using System.IO.Compression;
|
||||
@@ -78,15 +79,29 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
/// <summary>
|
||||
/// Indicates if an output file exists in an archive
|
||||
/// </summary>
|
||||
/// <param name="archive">Zip archive to check in</param>
|
||||
/// <inheritdoc/>
|
||||
public override bool Exists(ZipArchive? archive)
|
||||
{
|
||||
// Files aren't extracted so this check can't be done
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetPaths(string baseDirectory)
|
||||
{
|
||||
List<string> paths = [];
|
||||
|
||||
foreach (string filename in Filenames)
|
||||
{
|
||||
string possibleFile = Path.Combine(baseDirectory, filename);
|
||||
if (!_existsFunc(possibleFile))
|
||||
continue;
|
||||
|
||||
paths.Add(possibleFile);
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
using System.IO.Compression;
|
||||
@@ -198,7 +199,7 @@ namespace MPF.Processors
|
||||
// Ensure the directory exists
|
||||
if (!Directory.Exists(baseDirectory))
|
||||
return false;
|
||||
|
||||
|
||||
foreach (string filename in Filenames)
|
||||
{
|
||||
// Check for invalid filenames
|
||||
@@ -246,5 +247,25 @@ namespace MPF.Processors
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get all matching paths for the file
|
||||
/// </summary>
|
||||
/// <param name="baseDirectory">Base directory to check in</param>
|
||||
public virtual List<string> GetPaths(string baseDirectory)
|
||||
{
|
||||
List<string> paths = [];
|
||||
|
||||
foreach (string filename in Filenames)
|
||||
{
|
||||
string possibleFile = Path.Combine(baseDirectory, filename);
|
||||
if (!File.Exists(possibleFile))
|
||||
continue;
|
||||
|
||||
paths.Add(possibleFile);
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
using System.IO.Compression;
|
||||
@@ -64,10 +65,7 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
/// <summary>
|
||||
/// Indicates if an output file exists in an archive
|
||||
/// </summary>
|
||||
/// <param name="archive">Zip archive to check in</param>
|
||||
/// <inheritdoc/>
|
||||
public override bool Exists(ZipArchive? archive)
|
||||
{
|
||||
// If the archive is invalid
|
||||
@@ -85,5 +83,26 @@ namespace MPF.Processors
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetPaths(string baseDirectory)
|
||||
{
|
||||
// Ensure the directory exists
|
||||
if (!Directory.Exists(baseDirectory))
|
||||
return [];
|
||||
|
||||
List<string> paths = [];
|
||||
|
||||
// Get list of all files in directory
|
||||
var directoryFiles = Directory.GetFiles(baseDirectory);
|
||||
foreach (string file in directoryFiles)
|
||||
{
|
||||
var matches = Array.FindAll(Filenames, pattern => Regex.IsMatch(file, pattern));
|
||||
if (matches != null && matches.Length > 0)
|
||||
paths.Add(file);
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user