chore(sonar): wrap independent assertions in Assert.Multiple (NUnit2045)

Driven by `dotnet format analyzers --diagnostics NUnit2045`. The fixer
groups consecutive independent `Assert.That(...)` calls into
`Assert.Multiple(() => { ... })`, so a failing assertion no longer
short-circuits the block — every failure inside the group is reported,
which gives much better diagnostics on multi-property tests.

Audit confirmed no Assert.Throws / Assert.Fail / Assert.Catch / Assert.Pass
/ Assert.DoesNotThrow got pulled inside a Multiple block (those need to
short-circuit). All 1180 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thom Lamb
2026-05-27 11:59:47 -05:00
co-authored by Claude Opus 4.7
parent 505ada5017
commit 67512d23e1
47 changed files with 2132 additions and 1113 deletions
@@ -33,24 +33,30 @@ public class JsonTokenReaderTests
// Validate JSON starts with StartObject and ends with EndObject
Assert.That(tokens.Count, Is.GreaterThan(2));
Assert.That(tokens[0].Type, Is.EqualTo(JsonTokenType.StartObject));
Assert.That(tokens[^1].Type, Is.EqualTo(JsonTokenType.EndObject));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.PropertyName && t.Value == "foo"), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.String && t.Value == "bar"), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.PropertyName && t.Value == "myList"), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.StartArray), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.PropertyName && t.Value == "another"), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.Number && t.Value == "12"), Is.EqualTo(1));
Assert.Multiple(() =>
{
Assert.That(tokens[0].Type, Is.EqualTo(JsonTokenType.StartObject));
Assert.That(tokens[^1].Type, Is.EqualTo(JsonTokenType.EndObject));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.PropertyName && t.Value == "foo"), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.String && t.Value == "bar"), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.PropertyName && t.Value == "myList"), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.StartArray), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.PropertyName && t.Value == "another"), Is.EqualTo(1));
Assert.That(tokens.Count(t => t.Type == JsonTokenType.Number && t.Value == "12"), Is.EqualTo(1));
});
// Deep validation of JSON content structure
var tokenIndex = 4;
// Token 4: [
Assert.That(tokens[tokenIndex++].Type, Is.EqualTo(JsonTokenType.StartArray));
Assert.Multiple(() =>
{
// Token 4: [
Assert.That(tokens[tokenIndex++].Type, Is.EqualTo(JsonTokenType.StartArray));
// Token 5-8: Array elements [1,2,3,4]
Assert.That(tokens[tokenIndex].Type, Is.EqualTo(JsonTokenType.Number));
Assert.That(tokens[tokenIndex++].Value, Is.EqualTo("1"));
// Token 5-8: Array elements [1,2,3,4]
Assert.That(tokens[tokenIndex].Type, Is.EqualTo(JsonTokenType.Number));
Assert.That(tokens[tokenIndex++].Value, Is.EqualTo("1"));
});
Assert.That(tokens[tokenIndex].Type, Is.EqualTo(JsonTokenType.Number));
Assert.That(tokens[tokenIndex++].Value, Is.EqualTo("2"));
Assert.That(tokens[tokenIndex].Type, Is.EqualTo(JsonTokenType.Number));