mirror of
https://github.com/SabreTools/MPF.git
synced 2026-02-04 05:35:52 +00:00
Fill out DetermineMediaType for DiscImageCreator
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
- Add DetermineMediaType scaffolding and tests
|
||||
- Fill out DetermineMediaType for Redumper
|
||||
- Fill out DetermineMediaType for Aaru
|
||||
- Fill out DetermineMediaType for DiscImageCreator
|
||||
|
||||
### 3.3.2 (2025-06-12)
|
||||
|
||||
|
||||
@@ -13,27 +13,61 @@ namespace MPF.Processors.Test
|
||||
#region DetermineMediaType
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Null_Throws()
|
||||
public void DetermineMediaType_Null_Null()
|
||||
{
|
||||
string? basePath = null;
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Invalid_Throws()
|
||||
public void DetermineMediaType_Invalid_Null()
|
||||
{
|
||||
string? basePath = "INVALID";
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_Valid_Throws()
|
||||
public void DetermineMediaType_BD_Filled()
|
||||
{
|
||||
MediaType? expected = MediaType.BluRay;
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "BluRay", "test");
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_CD_Filled()
|
||||
{
|
||||
MediaType? expected = MediaType.CDROM;
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "CDROM", "test");
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
Assert.Throws<NotImplementedException>(() => processor.DetermineMediaType(basePath));
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_DVD_Filled()
|
||||
{
|
||||
MediaType? expected = MediaType.DVD;
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "DVD", "test");
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetermineMediaType_HDDVD_Filled()
|
||||
{
|
||||
MediaType? expected = MediaType.HDDVD;
|
||||
string? basePath = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "HDDVD", "test");
|
||||
var processor = new DiscImageCreator(RedumpSystem.IBMPCcompatible, MediaType.CDROM);
|
||||
var actual = processor.DetermineMediaType(basePath);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -379,15 +413,45 @@ namespace MPF.Processors.Test
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDiscType_Valid_Filled()
|
||||
public void GetDiscType_BD_Filled()
|
||||
{
|
||||
string? expected = "CD-ROM, GD-ROM, DVD-ROM, BD-ROM";
|
||||
string? expected = "BDO";
|
||||
string disc = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "BluRay", "test_disc.txt");
|
||||
bool actual = DiscImageCreator.GetDiscType(disc, out string? discTypeOrBookType);
|
||||
Assert.True(actual);
|
||||
Assert.Equal(expected, discTypeOrBookType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDiscType_CD_Filled()
|
||||
{
|
||||
string? expected = "CD-ROM";
|
||||
string disc = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "CDROM", "test_disc.txt");
|
||||
bool actual = DiscImageCreator.GetDiscType(disc, out string? discTypeOrBookType);
|
||||
Assert.True(actual);
|
||||
Assert.Equal(expected, discTypeOrBookType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDiscType_DVD_Filled()
|
||||
{
|
||||
string? expected = "DVD-ROM";
|
||||
string disc = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "DVD", "test_disc.txt");
|
||||
bool actual = DiscImageCreator.GetDiscType(disc, out string? discTypeOrBookType);
|
||||
Assert.True(actual);
|
||||
Assert.Equal(expected, discTypeOrBookType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDiscType_HDDVD_Filled()
|
||||
{
|
||||
string? expected = "HD DVD-ROM";
|
||||
string disc = Path.Combine(Environment.CurrentDirectory, "TestData", "DiscImageCreator", "HDDVD", "test_disc.txt");
|
||||
bool actual = DiscImageCreator.GetDiscType(disc, out string? discTypeOrBookType);
|
||||
Assert.True(actual);
|
||||
Assert.Equal(expected, discTypeOrBookType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDVDProtection
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<< GetDiscType >>
|
||||
DiscTypeIdentifier: BDO
|
||||
@@ -1,8 +1,5 @@
|
||||
<< GetDiscType >>
|
||||
DiscType: CD-ROM
|
||||
DiscTypeIdentifier: GD-ROM
|
||||
DiscTypeSpecific: DVD-ROM
|
||||
BookType: BD-ROM
|
||||
|
||||
<< GetDVDProtection >>
|
||||
========== CopyrightInformation ==========
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<< GetDiscType >>
|
||||
BookType: DVD-ROM
|
||||
@@ -0,0 +1,2 @@
|
||||
<< GetDiscType >>
|
||||
BookType: HD DVD-ROM
|
||||
@@ -70,7 +70,75 @@ namespace MPF.Processors
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? basePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// If the base path is invalid
|
||||
if (string.IsNullOrEmpty(basePath))
|
||||
return null;
|
||||
|
||||
// Get the comma-separated list of values
|
||||
if (GetDiscType($"{basePath}_disc.txt", out var discType) && discType != null)
|
||||
{
|
||||
// CD-ROM
|
||||
if (discType.Contains("CD-DA or CD-ROM Disc"))
|
||||
return MediaType.CDROM;
|
||||
else if (discType.Contains("CD-I Disc"))
|
||||
return MediaType.CDROM;
|
||||
else if (discType.Contains("CD-ROM XA Disc"))
|
||||
return MediaType.CDROM;
|
||||
|
||||
// HD-DVD
|
||||
if (discType.Contains("HD DVD-ROM"))
|
||||
return MediaType.HDDVD;
|
||||
else if (discType.Contains("HD DVD-RAM"))
|
||||
return MediaType.HDDVD;
|
||||
else if (discType.Contains("HD DVD-R"))
|
||||
return MediaType.HDDVD;
|
||||
|
||||
// DVD
|
||||
if (discType.Contains("DVD-ROM"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("DVD-RAM"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("DVD-R"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("DVD-RW"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("Reserved1"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("Reserved2"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("DVD+RW"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("DVD+R"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("Reserved3"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("Reserved4"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("DVD+RW DL"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("DVD+R DL"))
|
||||
return MediaType.DVD;
|
||||
else if (discType.Contains("Reserved5"))
|
||||
return MediaType.NintendoWiiOpticalDisc;
|
||||
|
||||
// Blu-ray
|
||||
if (discType.Contains("BDO"))
|
||||
return MediaType.BluRay;
|
||||
else if (discType.Contains("BDU"))
|
||||
return MediaType.BluRay;
|
||||
else if (discType.Contains("BDW"))
|
||||
return MediaType.BluRay;
|
||||
else if (discType.Contains("BDR"))
|
||||
return MediaType.BluRay;
|
||||
else if (discType.Contains("XG4"))
|
||||
return MediaType.BluRay;
|
||||
|
||||
// Assume CD-ROM for everything else
|
||||
return MediaType.CDROM;
|
||||
}
|
||||
|
||||
// The type could not be determined
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
Reference in New Issue
Block a user