Add C#12 syntax to tests

This commit is contained in:
Matt Nadareski
2023-11-15 16:39:52 -05:00
parent 39a524e3cc
commit fbdb9875f3
4 changed files with 77 additions and 76 deletions

View File

@@ -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)

View File

@@ -15,12 +15,12 @@ namespace MPF.Test.Core.Converters
/// <summary>
/// DiscType values that map to InternalDriveType
/// </summary>
private static readonly DriveType[] _mappableDriveTypes = new DriveType[]
{
private static readonly DriveType[] _mappableDriveTypes =
[
DriveType.CDRom,
DriveType.Fixed,
DriveType.Removable,
};
];
/// <summary>
/// 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<object?[]>() { new object?[] { null } };
foreach (InternalProgram? internalProgram in Enum.GetValues(typeof(InternalProgram)))
{
testData.Add(new object?[] { internalProgram });
testData.Add([internalProgram]);
}
return testData;

View File

@@ -12,8 +12,8 @@ namespace MPF.Test.Core.Utilities
/// <summary>
/// MediaType values that support drive speeds
/// </summary>
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,
};
];
/// <summary>
/// RedumpSystem values that are considered Audio
/// </summary>
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,
};
];
/// <summary>
/// RedumpSystem values that are considered markers
/// </summary>
private static readonly RedumpSystem?[] _markerSystems = new RedumpSystem?[]
{
private static readonly RedumpSystem?[] _markerSystems =
[
RedumpSystem.MarkerArcadeEnd,
RedumpSystem.MarkerComputerEnd,
RedumpSystem.MarkerDiscBasedConsoleEnd,
RedumpSystem.MarkerOtherEnd,
};
];
/// <summary>
/// RedumpSystem values that are have reversed ringcodes
/// </summary>
private static readonly RedumpSystem?[] _reverseRingcodeSystems = new RedumpSystem?[]
{
private static readonly RedumpSystem?[] _reverseRingcodeSystems =
[
RedumpSystem.SonyPlayStation2,
RedumpSystem.SonyPlayStation3,
RedumpSystem.SonyPlayStation4,
RedumpSystem.SonyPlayStation5,
RedumpSystem.SonyPlayStationPortable,
};
];
/// <summary>
/// RedumpSystem values that are considered XGD
/// </summary>
private static readonly RedumpSystem?[] _xgdSystems = new RedumpSystem?[]
{
private static readonly RedumpSystem?[] _xgdSystems =
[
RedumpSystem.MicrosoftXbox,
RedumpSystem.MicrosoftXbox360,
RedumpSystem.MicrosoftXboxOne,
RedumpSystem.MicrosoftXboxSeriesXS,
};
];
/// <summary>
/// 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;

View File

@@ -11,11 +11,11 @@ namespace MPF.Test.Library
[Fact]
public void SanitizeFoundProtectionsActiveMARKTest()
{
List<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> 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<string> protections = new()
{
List<string> protections =
[
"XCP",
"XCP v1.2.0",
};
];
string sanitized = Protection.SanitizeFoundProtections(protections);
Assert.Equal("XCP v1.2.0", sanitized);