Convert test data sources to typed TheoryData

Replace untyped MemberData sources with TheoryData<...>, use collection
expressions for array and list literals, drop redundant casts and null
suppressions, and give log-assertion helpers an IsEnabled setup so guarded
log calls stay verifiable.
This commit is contained in:
2026-11-29 21:42:41 +02:00
parent ada3c77778
commit 17774b40b8
31 changed files with 649 additions and 693 deletions
@@ -161,17 +161,17 @@ public class CompactNordPoolDayPriceTests
act.Should().Throw<ArgumentNullException>();
}
public static IEnumerable<object[]> InvalidJsonPayloads =>
[
["empty array", "[]"],
["too few elements", "[1,2]"],
["extra elements", "[1,2,3,4]"],
["missing end of array", "[1,2,3"],
["non-numeric start", "[\"abc\",2,3]"],
["non-numeric end", "[1,\"abc\",3]"],
["non-numeric price", "[1,2,\"abc\"]"],
["object instead of array", "{\"start\":1}"]
];
public static TheoryData<string, string> InvalidJsonPayloads => new()
{
{ "empty array", "[]" },
{ "too few elements", "[1,2]" },
{ "extra elements", "[1,2,3,4]" },
{ "missing end of array", "[1,2,3" },
{ "non-numeric start", "[\"abc\",2,3]" },
{ "non-numeric end", "[1,\"abc\",3]" },
{ "non-numeric price", "[1,2,\"abc\"]" },
{ "object instead of array", "{\"start\":1}" }
};
[Theory]
[MemberData(nameof(InvalidJsonPayloads))]
@@ -249,7 +249,7 @@ public class CompactNordPoolDayPriceTests
var roundTripped = JsonSerializer.Deserialize<List<CompactNordPoolDayPrice>>(json);
roundTripped.Should().NotBeNull();
roundTripped!.Should().HaveCount(compact.Count);
roundTripped.Should().HaveCount(compact.Count);
roundTripped.Should().BeEquivalentTo(compact);
}