From 3d932705bc77bf73d855243a3b709c0fe9399986 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 28 May 2024 10:15:32 -0400 Subject: [PATCH] Move DoesSupportDriveSpeed to DumpEnvironment --- CHANGELIST.md | 1 + MPF.Core/EnumExtensions.cs | 27 ++-------------- MPF.Frontend/DumpEnvironment.cs | 21 +++++++++++-- .../Core/Utilities/EnumExtensionsTests.cs | 31 ------------------- 4 files changed, 22 insertions(+), 58 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 6d82d0b0..d6c8ab5f 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -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) diff --git a/MPF.Core/EnumExtensions.cs b/MPF.Core/EnumExtensions.cs index db83e99a..7988f54b 100644 --- a/MPF.Core/EnumExtensions.cs +++ b/MPF.Core/EnumExtensions.cs @@ -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 - - /// - /// Determine if the media supports drive speeds - /// - /// MediaType value to check - /// True if the media has variable dumping speeds, false otherwise - 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 } } diff --git a/MPF.Frontend/DumpEnvironment.cs b/MPF.Frontend/DumpEnvironment.cs index a827f6bd..eeb206e1 100644 --- a/MPF.Frontend/DumpEnvironment.cs +++ b/MPF.Frontend/DumpEnvironment.cs @@ -264,8 +264,25 @@ namespace MPF.Frontend /// public bool DetectedByWindows() => _system.DetectedByWindows(); - /// - public bool DoesSupportDriveSpeed() => _type.DoesSupportDriveSpeed(); + /// + /// Determine if the media supports drive speeds + /// + /// MediaType value to check + /// True if the media has variable dumping speeds, false otherwise + 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, + }; + } /// public bool FoundAllFiles(string? outputDirectory, string outputFilename, bool preCheck) diff --git a/MPF.Test/Core/Utilities/EnumExtensionsTests.cs b/MPF.Test/Core/Utilities/EnumExtensionsTests.cs index 51a41efe..41943d29 100644 --- a/MPF.Test/Core/Utilities/EnumExtensionsTests.cs +++ b/MPF.Test/Core/Utilities/EnumExtensionsTests.cs @@ -76,19 +76,6 @@ namespace MPF.Test.Core.Utilities RedumpSystem.MicrosoftXboxSeriesXS, ]; - /// - /// Check that all optical media support drive speeds - /// - /// DriveType value to check - /// The expected value to come from the check - [Theory] - [MemberData(nameof(GenerateSupportDriveSpeedsTestData))] - public void DoesSupportDriveSpeedTest(MediaType? mediaType, bool expected) - { - bool actual = mediaType.DoesSupportDriveSpeed(); - Assert.Equal(expected, actual); - } - /// /// Check that all systems with reversed ringcodes are marked properly /// @@ -141,24 +128,6 @@ namespace MPF.Test.Core.Utilities Assert.Equal(expected, actual); } - /// - /// Generate a test set of MediaType values that support drive speeds - /// - /// MemberData-compatible list of MediaType values - public static List GenerateSupportDriveSpeedsTestData() - { - var testData = new List() { 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; - } - /// /// Generate a test set of RedumpSystem values that are considered Audio ///