Move DoesSupportDriveSpeed to DumpEnvironment

This commit is contained in:
Matt Nadareski
2024-05-28 10:15:32 -04:00
parent 80cde96614
commit 3d932705bc
4 changed files with 22 additions and 58 deletions

View File

@@ -128,6 +128,7 @@
- Move ToRedumper* methods to Options
- Move ToMediaType to OptionsLoader
- Move ListPrograms to OptionsLoader
- Move DoesSupportDriveSpeed to DumpEnvironment
### 3.1.9a (2024-05-21)

View File

@@ -1,6 +1,7 @@
using System;
#if NET20 || NET35
using System.Collections.Generic;
#if NET40_OR_GREATER || NETCOREAPP
#else
using System.Collections.Concurrent;
#endif
using System.Reflection;
@@ -173,29 +174,5 @@ namespace MPF.Core
}
#endregion
#region Enum Helpers
/// <summary>
/// Determine if the media supports drive speeds
/// </summary>
/// <param name="type">MediaType value to check</param>
/// <returns>True if the media has variable dumping speeds, false otherwise</returns>
public static bool DoesSupportDriveSpeed(this MediaType? type)
{
return type switch
{
MediaType.CDROM
or MediaType.DVD
or MediaType.GDROM
or MediaType.HDDVD
or MediaType.BluRay
or MediaType.NintendoGameCubeGameDisc
or MediaType.NintendoWiiOpticalDisc => true,
_ => false,
};
}
#endregion
}
}

View File

@@ -264,8 +264,25 @@ namespace MPF.Frontend
/// <inheritdoc cref="Extensions.DetectedByWindows(RedumpSystem?)"/>
public bool DetectedByWindows() => _system.DetectedByWindows();
/// <inheritdoc cref="EnumExtensions.DoesSupportDriveSpeed(MediaType?)"/>
public bool DoesSupportDriveSpeed() => _type.DoesSupportDriveSpeed();
/// <summary>
/// Determine if the media supports drive speeds
/// </summary>
/// <param name="type">MediaType value to check</param>
/// <returns>True if the media has variable dumping speeds, false otherwise</returns>
public bool DoesSupportDriveSpeed()
{
return _type switch
{
MediaType.CDROM
or MediaType.DVD
or MediaType.GDROM
or MediaType.HDDVD
or MediaType.BluRay
or MediaType.NintendoGameCubeGameDisc
or MediaType.NintendoWiiOpticalDisc => true,
_ => false,
};
}
/// <inheritdoc cref="BaseProcessor.FoundAllFiles(string?, string, bool)"/>
public bool FoundAllFiles(string? outputDirectory, string outputFilename, bool preCheck)

View File

@@ -76,19 +76,6 @@ namespace MPF.Test.Core.Utilities
RedumpSystem.MicrosoftXboxSeriesXS,
];
/// <summary>
/// Check that all optical media support drive speeds
/// </summary>
/// <param name="mediaType">DriveType value to check</param>
/// <param name="expected">The expected value to come from the check</param>
[Theory]
[MemberData(nameof(GenerateSupportDriveSpeedsTestData))]
public void DoesSupportDriveSpeedTest(MediaType? mediaType, bool expected)
{
bool actual = mediaType.DoesSupportDriveSpeed();
Assert.Equal(expected, actual);
}
/// <summary>
/// Check that all systems with reversed ringcodes are marked properly
/// </summary>
@@ -141,24 +128,6 @@ namespace MPF.Test.Core.Utilities
Assert.Equal(expected, actual);
}
/// <summary>
/// Generate a test set of MediaType values that support drive speeds
/// </summary>
/// <returns>MemberData-compatible list of MediaType values</returns>
public static List<object?[]> GenerateSupportDriveSpeedsTestData()
{
var testData = new List<object?[]>() { new object?[] { null, false } };
foreach (MediaType mediaType in Enum.GetValues(typeof(MediaType)))
{
if (_supportDriveSpeeds.Contains(mediaType))
testData.Add([mediaType, true]);
else
testData.Add([mediaType, false]);
}
return testData;
}
/// <summary>
/// Generate a test set of RedumpSystem values that are considered Audio
/// </summary>