diff --git a/CHANGELIST.md b/CHANGELIST.md index dec5db7b..e23a2284 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -13,6 +13,7 @@ - Prepare XAML for ancient .NET support - Suppress deprecation warnings - Fix reversed ringcode test +- Add C#12 syntax to tests ### 3.0.0 (2023-11-14) diff --git a/MPF.Test/Core/Converters/EnumConverterTests.cs b/MPF.Test/Core/Converters/EnumConverterTests.cs index f2954a8b..8db25ca5 100644 --- a/MPF.Test/Core/Converters/EnumConverterTests.cs +++ b/MPF.Test/Core/Converters/EnumConverterTests.cs @@ -15,12 +15,12 @@ namespace MPF.Test.Core.Converters /// /// DiscType values that map to InternalDriveType /// - private static readonly DriveType[] _mappableDriveTypes = new DriveType[] - { + private static readonly DriveType[] _mappableDriveTypes = + [ DriveType.CDRom, DriveType.Fixed, DriveType.Removable, - }; + ]; /// /// Check that every supported DriveType maps to an InternalDriveType @@ -49,9 +49,9 @@ namespace MPF.Test.Core.Converters foreach (DriveType driveType in Enum.GetValues(typeof(DriveType))) { if (_mappableDriveTypes.Contains(driveType)) - testData.Add(new object?[] { driveType, false }); + testData.Add([driveType, false]); else - testData.Add(new object?[] { driveType, true }); + testData.Add([driveType, true]); } return testData; @@ -84,7 +84,7 @@ namespace MPF.Test.Core.Converters var testData = new List() { new object?[] { null } }; foreach (InternalProgram? internalProgram in Enum.GetValues(typeof(InternalProgram))) { - testData.Add(new object?[] { internalProgram }); + testData.Add([internalProgram]); } return testData; diff --git a/MPF.Test/Core/Utilities/EnumExtensionsTests.cs b/MPF.Test/Core/Utilities/EnumExtensionsTests.cs index 8aafcbc7..1a4412aa 100644 --- a/MPF.Test/Core/Utilities/EnumExtensionsTests.cs +++ b/MPF.Test/Core/Utilities/EnumExtensionsTests.cs @@ -12,8 +12,8 @@ namespace MPF.Test.Core.Utilities /// /// MediaType values that support drive speeds /// - private static readonly MediaType?[] _supportDriveSpeeds = new MediaType?[] - { + private static readonly MediaType?[] _supportDriveSpeeds = + [ MediaType.CDROM, MediaType.DVD, MediaType.GDROM, @@ -21,13 +21,13 @@ namespace MPF.Test.Core.Utilities MediaType.BluRay, MediaType.NintendoGameCubeGameDisc, MediaType.NintendoWiiOpticalDisc, - }; + ]; /// /// RedumpSystem values that are considered Audio /// - private static readonly RedumpSystem?[] _audioSystems = new RedumpSystem?[] - { + private static readonly RedumpSystem?[] _audioSystems = + [ RedumpSystem.AtariJaguarCDInteractiveMultimediaSystem, RedumpSystem.AudioCD, RedumpSystem.DVDAudio, @@ -39,41 +39,41 @@ namespace MPF.Test.Core.Utilities RedumpSystem.PlayStationGameSharkUpdates, RedumpSystem.PhilipsCDi, RedumpSystem.SuperAudioCD, - }; + ]; /// /// RedumpSystem values that are considered markers /// - private static readonly RedumpSystem?[] _markerSystems = new RedumpSystem?[] - { + private static readonly RedumpSystem?[] _markerSystems = + [ RedumpSystem.MarkerArcadeEnd, RedumpSystem.MarkerComputerEnd, RedumpSystem.MarkerDiscBasedConsoleEnd, RedumpSystem.MarkerOtherEnd, - }; + ]; /// /// RedumpSystem values that are have reversed ringcodes /// - private static readonly RedumpSystem?[] _reverseRingcodeSystems = new RedumpSystem?[] - { + private static readonly RedumpSystem?[] _reverseRingcodeSystems = + [ RedumpSystem.SonyPlayStation2, RedumpSystem.SonyPlayStation3, RedumpSystem.SonyPlayStation4, RedumpSystem.SonyPlayStation5, RedumpSystem.SonyPlayStationPortable, - }; + ]; /// /// RedumpSystem values that are considered XGD /// - private static readonly RedumpSystem?[] _xgdSystems = new RedumpSystem?[] - { + private static readonly RedumpSystem?[] _xgdSystems = + [ RedumpSystem.MicrosoftXbox, RedumpSystem.MicrosoftXbox360, RedumpSystem.MicrosoftXboxOne, RedumpSystem.MicrosoftXboxSeriesXS, - }; + ]; /// /// Check that all optical media support drive speeds @@ -150,9 +150,9 @@ namespace MPF.Test.Core.Utilities foreach (MediaType mediaType in Enum.GetValues(typeof(MediaType))) { if (_supportDriveSpeeds.Contains(mediaType)) - testData.Add(new object?[] { mediaType, true }); + testData.Add([mediaType, true]); else - testData.Add(new object?[] { mediaType, false }); + testData.Add([mediaType, false]); } return testData; @@ -168,9 +168,9 @@ namespace MPF.Test.Core.Utilities foreach (RedumpSystem redumpSystem in Enum.GetValues(typeof(RedumpSystem))) { if (_audioSystems.Contains(redumpSystem)) - testData.Add(new object?[] { redumpSystem, true }); + testData.Add([redumpSystem, true]); else - testData.Add(new object?[] { redumpSystem, false }); + testData.Add([redumpSystem, false]); } return testData; @@ -186,9 +186,9 @@ namespace MPF.Test.Core.Utilities foreach (RedumpSystem redumpSystem in Enum.GetValues(typeof(RedumpSystem))) { if (_markerSystems.Contains(redumpSystem)) - testData.Add(new object?[] { redumpSystem, true }); + testData.Add([redumpSystem, true]); else - testData.Add(new object?[] { redumpSystem, false }); + testData.Add([redumpSystem, false]); } return testData; @@ -204,9 +204,9 @@ namespace MPF.Test.Core.Utilities foreach (RedumpSystem redumpSystem in Enum.GetValues(typeof(RedumpSystem))) { if (_reverseRingcodeSystems.Contains(redumpSystem)) - testData.Add(new object?[] { redumpSystem, true }); + testData.Add([redumpSystem, true]); else - testData.Add(new object?[] { redumpSystem, false }); + testData.Add([redumpSystem, false]); } return testData; @@ -222,9 +222,9 @@ namespace MPF.Test.Core.Utilities foreach (RedumpSystem redumpSystem in Enum.GetValues(typeof(RedumpSystem))) { if (_xgdSystems.Contains(redumpSystem)) - testData.Add(new object?[] { redumpSystem, true }); + testData.Add([redumpSystem, true]); else - testData.Add(new object?[] { redumpSystem, false }); + testData.Add([redumpSystem, false]); } return testData; diff --git a/MPF.Test/Library/ProtectionTests.cs b/MPF.Test/Library/ProtectionTests.cs index d393bb9f..2a100d9e 100644 --- a/MPF.Test/Library/ProtectionTests.cs +++ b/MPF.Test/Library/ProtectionTests.cs @@ -11,11 +11,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsActiveMARKTest() { - List protections = new() - { + List protections = + [ "ActiveMARK", "ActiveMARK 5", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("ActiveMARK 5", sanitized); @@ -24,11 +24,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsCactusDataShieldTest() { - List protections = new() - { + List protections = + [ "Cactus Data Shield 200", "Cactus Data Shield 200 (Build 3.0.100a)", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("Cactus Data Shield 200 (Build 3.0.100a)", sanitized); @@ -37,11 +37,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsCDCheckTest() { - List protections = new() - { + List protections = + [ "Anything Else Protection", "Executable-Based CD Check", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("Anything Else Protection", sanitized); @@ -50,11 +50,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsCDCopsTest() { - List protections = new() - { + List protections = + [ "CD-Cops", "CD-Cops v1.2.0", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("CD-Cops v1.2.0", sanitized); @@ -63,11 +63,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsCDKeyTest() { - List protections = new() - { + List protections = + [ "Anything Else Protection", "CD-Key / Serial", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("Anything Else Protection", sanitized); @@ -76,11 +76,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsEACdKeyTest() { - List protections = new() - { + List protections = + [ "EA CdKey Registration Module", "EA CdKey Registration Module v1.2.0", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("EA CdKey Registration Module v1.2.0", sanitized); @@ -89,11 +89,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsEADRMTest() { - List protections = new() - { + List protections = + [ "EA DRM Protection", "EA DRM Protection v1.2.0", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("EA DRM Protection v1.2.0", sanitized); @@ -102,11 +102,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsGFWLTest() { - List protections = new() - { + List protections = + [ "Games for Windows LIVE", "Games for Windows LIVE v1.2.0", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("Games for Windows LIVE v1.2.0", sanitized); @@ -115,11 +115,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsGFWLZDPPTest() { - List protections = new() - { + List protections = + [ "Games for Windows LIVE", "Games for Windows LIVE Zero Day Piracy Protection", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("Games for Windows LIVE, Games for Windows LIVE Zero Day Piracy Protection", sanitized); @@ -128,11 +128,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsImpulseReactorTest() { - List protections = new() - { + List protections = + [ "Impulse Reactor", "Impulse Reactor Core Module v1.2.0", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("Impulse Reactor Core Module v1.2.0", sanitized); @@ -145,14 +145,14 @@ namespace MPF.Test.Library [InlineData(3)] public void SanitizeFoundProtectionsJoWoodXProtTest(int skip) { - List protections = new() - { + List protections = + [ "JoWood X-Prot 1.2.0.00", "JoWood X-Prot v2", "JoWood X-Prot v1.4+", "JoWood X-Prot v1.0-v1.3", "JoWood X-Prot", - }; + ]; // Safeguard for the future if (skip >= protections.Count) @@ -168,11 +168,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsOnlineRegistrationTest() { - List protections = new() - { + List protections = + [ "Anything Else Protection", "Executable-Based Online Registration", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("Anything Else Protection", sanitized); @@ -185,14 +185,14 @@ namespace MPF.Test.Library [InlineData(3)] public void SanitizeFoundProtectionStarForceTest(int skip) { - List protections = new() - { + List protections = + [ "StarForce 1.20.000.000", "StarForce 5 [Protected Module]", "StarForce 5", "StarForce 3-5", "StarForce", - }; + ]; // Safeguard for the future if (skip >= protections.Count) @@ -208,11 +208,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsSysiphusTest() { - List protections = new() - { + List protections = + [ "Sysiphus", "Sysiphus v1.2.0", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("Sysiphus v1.2.0", sanitized); @@ -221,11 +221,11 @@ namespace MPF.Test.Library [Fact] public void SanitizeFoundProtectionsXCPTest() { - List protections = new() - { + List protections = + [ "XCP", "XCP v1.2.0", - }; + ]; string sanitized = Protection.SanitizeFoundProtections(protections); Assert.Equal("XCP v1.2.0", sanitized);