summaryrefslogtreecommitdiff
path: root/src/SMAPI.Tests/WikiClient/ChangeDescriptorTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Tests/WikiClient/ChangeDescriptorTests.cs')
-rw-r--r--src/SMAPI.Tests/WikiClient/ChangeDescriptorTests.cs24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/SMAPI.Tests/WikiClient/ChangeDescriptorTests.cs b/src/SMAPI.Tests/WikiClient/ChangeDescriptorTests.cs
index 7695fbf8..8e7e1fb8 100644
--- a/src/SMAPI.Tests/WikiClient/ChangeDescriptorTests.cs
+++ b/src/SMAPI.Tests/WikiClient/ChangeDescriptorTests.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System.Collections.Generic;
using NUnit.Framework;
using StardewModdingAPI;
@@ -22,15 +20,14 @@ namespace SMAPI.Tests.WikiClient
{
// arrange
string rawDescriptor = "-Nexus:2400, -B, XX → YY, Nexus:451,+A, XXX → YYY, invalidA →, → invalidB";
- string[] expectedAdd = new[] { "Nexus:451", "A" };
- string[] expectedRemove = new[] { "Nexus:2400", "B" };
+ string[] expectedAdd = { "Nexus:451", "A" };
+ string[] expectedRemove = { "Nexus:2400", "B" };
IDictionary<string, string> expectedReplace = new Dictionary<string, string>
{
["XX"] = "YY",
["XXX"] = "YYY"
};
- string[] expectedErrors = new[]
- {
+ string[] expectedErrors = {
"Failed parsing ' invalidA →': can't map to a blank value. Use the '-value' format to remove a value.",
"Failed parsing ' → invalidB': can't map from a blank old value. Use the '+value' format to add a value."
};
@@ -50,15 +47,14 @@ namespace SMAPI.Tests.WikiClient
{
// arrange
string rawDescriptor = "-1.0.1, -2.0-beta, 1.00 → 1.0, 1.0.0,+2.0-beta.15, 2.0 → 2.0-beta, invalidA →, → invalidB";
- string[] expectedAdd = new[] { "1.0.0", "2.0.0-beta.15" };
- string[] expectedRemove = new[] { "1.0.1", "2.0.0-beta" };
+ string[] expectedAdd = { "1.0.0", "2.0.0-beta.15" };
+ string[] expectedRemove = { "1.0.1", "2.0.0-beta" };
IDictionary<string, string> expectedReplace = new Dictionary<string, string>
{
["1.00"] = "1.0.0",
["2.0.0"] = "2.0.0-beta"
};
- string[] expectedErrors = new[]
- {
+ string[] expectedErrors = {
"Failed parsing ' invalidA →': can't map to a blank value. Use the '-value' format to remove a value.",
"Failed parsing ' → invalidB': can't map from a blank old value. Use the '+value' format to add a value."
};
@@ -67,7 +63,7 @@ namespace SMAPI.Tests.WikiClient
ChangeDescriptor parsed = ChangeDescriptor.Parse(
rawDescriptor,
out string[] errors,
- formatValue: raw => SemanticVersion.TryParse(raw, out ISemanticVersion version)
+ formatValue: raw => SemanticVersion.TryParse(raw, out ISemanticVersion? version)
? version.ToString()
: raw
);
@@ -111,9 +107,9 @@ namespace SMAPI.Tests.WikiClient
[TestCase("", "+Nexus:A, Nexus:B, -Chucklefish:14, Nexus:2400 → Nexus:2401, Nexus:A→Nexus:B", ExpectedResult = "Nexus:A, Nexus:B")]
[TestCase("Nexus:2400", "+Nexus:A, Nexus:B, -Chucklefish:14, Nexus:2400 → Nexus:2401, Nexus:A→Nexus:B", ExpectedResult = "Nexus:2401, Nexus:A, Nexus:B")]
[TestCase("Nexus:2400, Nexus:2401, Nexus:B,Chucklefish:14", "+Nexus:A, Nexus:B, -Chucklefish:14, Nexus:2400 → Nexus:2401, Nexus:A→Nexus:B", ExpectedResult = "Nexus:2401, Nexus:2401, Nexus:B, Nexus:A")]
- public string Apply_Raw(string input, string descriptor)
+ public string Apply_Raw(string input, string? descriptor)
{
- var parsed = ChangeDescriptor.Parse(descriptor, out string[] errors);
+ ChangeDescriptor parsed = ChangeDescriptor.Parse(descriptor, out string[] errors);
Assert.IsEmpty(errors, "Parsing the descriptor failed.");
@@ -128,7 +124,7 @@ namespace SMAPI.Tests.WikiClient
[TestCase("-Nexus:2400", ExpectedResult = "-Nexus:2400")]
[TestCase(" Nexus:2400 →Nexus:2401 ", ExpectedResult = "Nexus:2400 → Nexus:2401")]
[TestCase("+Nexus:A, Nexus:B, -Chucklefish:14, Nexus:2400 → Nexus:2401, Nexus:A→Nexus:B", ExpectedResult = "+Nexus:A, +Nexus:B, -Chucklefish:14, Nexus:2400 → Nexus:2401, Nexus:A → Nexus:B")]
- public string ToString(string descriptor)
+ public string ToString(string? descriptor)
{
var parsed = ChangeDescriptor.Parse(descriptor, out string[] errors);