mirror of
https://github.com/SabreTools/MPF.git
synced 2026-04-26 16:19:28 +00:00
Add tests around UIC helpers
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
- Add tests around XBC helpers
|
||||
- Fix failing XBC test
|
||||
- Perform better path emptiness checks
|
||||
- Add tests around UIC helpers
|
||||
|
||||
### 3.2.4 (2024-11-24)
|
||||
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
TEST DATA
|
||||
<< GetUMDAuxInfo >>
|
||||
TITLE title
|
||||
DISC_ID serial
|
||||
DISC_VERSION version
|
||||
pspUmdTypes GAME
|
||||
L0 length 12345
|
||||
FileSize: 12345
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
TEST DATA
|
||||
<< GetPVD >>
|
||||
========== LBA[000016, 0x0000010]: Main Channel ==========
|
||||
0310 TEST DATA
|
||||
0320 TEST DATA
|
||||
0330 TEST DATA
|
||||
0340 TEST DATA
|
||||
0350 TEST DATA
|
||||
0360 TEST DATA
|
||||
0370 TEST DATA
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
TEST DATA
|
||||
<< GetVolumeLabels >>
|
||||
Primary Volume Descriptor Number: 0
|
||||
Volume Identifier: label
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
@@ -131,5 +132,148 @@ namespace MPF.Processors.Test
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPVD
|
||||
|
||||
[Fact]
|
||||
public void GetPVD_Empty_Null()
|
||||
{
|
||||
string mainInfo = string.Empty;
|
||||
string? actual = UmdImageCreator.GetPVD(mainInfo);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPVD_Invalid_Null()
|
||||
{
|
||||
string mainInfo = "INVALID";
|
||||
string? actual = UmdImageCreator.GetPVD(mainInfo);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPVD_Valid_Filled()
|
||||
{
|
||||
string mainInfo = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD", "test_mainInfo.txt");
|
||||
string? actual = UmdImageCreator.GetPVD(mainInfo);
|
||||
Assert.NotNull(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetUMDAuxInfo
|
||||
|
||||
[Fact]
|
||||
public void GetUMDAuxInfo_Empty_Null()
|
||||
{
|
||||
long expectedSize = -1;
|
||||
|
||||
string disc = string.Empty;
|
||||
bool actual = UmdImageCreator.GetUMDAuxInfo(disc,
|
||||
out string? title,
|
||||
out DiscCategory? category,
|
||||
out string? serial,
|
||||
out string? version,
|
||||
out string? layer,
|
||||
out long size);
|
||||
|
||||
Assert.False(actual);
|
||||
Assert.Null(title);
|
||||
Assert.Null(category);
|
||||
Assert.Null(serial);
|
||||
Assert.Null(version);
|
||||
Assert.Null(layer);
|
||||
Assert.Equal(expectedSize, size);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetUMDAuxInfo_Invalid_Null()
|
||||
{
|
||||
long expectedSize = -1;
|
||||
|
||||
string disc = "INVALID";
|
||||
bool actual = UmdImageCreator.GetUMDAuxInfo(disc,
|
||||
out string? title,
|
||||
out DiscCategory? category,
|
||||
out string? serial,
|
||||
out string? version,
|
||||
out string? layer,
|
||||
out long size);
|
||||
|
||||
Assert.False(actual);
|
||||
Assert.Null(title);
|
||||
Assert.Null(category);
|
||||
Assert.Null(serial);
|
||||
Assert.Null(version);
|
||||
Assert.Null(layer);
|
||||
Assert.Equal(expectedSize, size);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetUMDAuxInfo_Valid_Filled()
|
||||
{
|
||||
string? expectedTitle = "title";
|
||||
DiscCategory? expectedCategory = DiscCategory.Games;
|
||||
string? expectedSerial = "seri-al";
|
||||
string? expectedVersion = "version";
|
||||
string? expectedLayer = "12345";
|
||||
long expectedSize = 12345;
|
||||
|
||||
string disc = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD", "test_disc.txt");
|
||||
bool actual = UmdImageCreator.GetUMDAuxInfo(disc,
|
||||
out string? title,
|
||||
out DiscCategory? category,
|
||||
out string? serial,
|
||||
out string? version,
|
||||
out string? layer,
|
||||
out long size);
|
||||
|
||||
Assert.True(actual);
|
||||
Assert.Equal(expectedTitle, title);
|
||||
Assert.Equal(expectedCategory, category);
|
||||
Assert.Equal(expectedSerial, serial);
|
||||
Assert.Equal(expectedVersion, version);
|
||||
Assert.Equal(expectedLayer, layer);
|
||||
Assert.Equal(expectedSize, size);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetVolumeLabels
|
||||
|
||||
[Fact]
|
||||
public void GetVolumeLabels_Empty_Null()
|
||||
{
|
||||
string volDesc = string.Empty;
|
||||
bool actual = UmdImageCreator.GetVolumeLabels(volDesc, out Dictionary<string, List<string>> volLabels);
|
||||
|
||||
Assert.False(actual);
|
||||
Assert.Empty(volLabels);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetVolumeLabels_Invalid_Null()
|
||||
{
|
||||
string volDesc = "INVALID";
|
||||
bool actual = UmdImageCreator.GetVolumeLabels(volDesc, out Dictionary<string, List<string>> volLabels);
|
||||
|
||||
Assert.False(actual);
|
||||
Assert.Empty(volLabels);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetVolumeLabels_Valid_Filled()
|
||||
{
|
||||
string volDesc = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD", "test_volDesc.txt");
|
||||
bool actual = UmdImageCreator.GetVolumeLabels(volDesc, out Dictionary<string, List<string>> volLabels);
|
||||
|
||||
Assert.True(actual);
|
||||
KeyValuePair<string, List<string>> labelPair = Assert.Single(volLabels);
|
||||
Assert.Equal("label", labelPair.Key);
|
||||
string filesystem = Assert.Single(labelPair.Value);
|
||||
Assert.Equal("UDF", filesystem);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ namespace MPF.Processors
|
||||
/// </summary>
|
||||
/// <param name="disc">_disc.txt file location</param>
|
||||
/// <returns>True on successful extraction of info, false otherwise</returns>
|
||||
private static bool GetUMDAuxInfo(string disc,
|
||||
internal static bool GetUMDAuxInfo(string disc,
|
||||
out string? title,
|
||||
out DiscCategory? category,
|
||||
out string? serial,
|
||||
@@ -218,8 +218,8 @@ namespace MPF.Processors
|
||||
/// </summary>
|
||||
/// <param name="volDesc">_volDesc.txt file location</param>
|
||||
/// <returns>Volume labels (by type), or null if none present</returns>
|
||||
/// <remarks>This is a copy of the code from DiscImageCreator and has extrandous checks</remarks>
|
||||
private static bool GetVolumeLabels(string volDesc, out Dictionary<string, List<string>> volLabels)
|
||||
/// <remarks>This is a copy of the code from DiscImageCreator and has extraneous checks</remarks>
|
||||
internal static bool GetVolumeLabels(string volDesc, out Dictionary<string, List<string>> volLabels)
|
||||
{
|
||||
// If the file doesn't exist, can't get the volume labels
|
||||
volLabels = [];
|
||||
|
||||
Reference in New Issue
Block a user