chore(sonar): adopt Has.Count, Is.Empty, Does.Contain, char overloads in tests (NUnit2046, NUnit2011, CA1866)

- NUnit2046: `Assert.That(x.Count, Is.EqualTo(n))` → `Assert.That(x, Has.Count.EqualTo(n))` (or `Is.Empty` when n==0)
- NUnit2011: `Assert.That(s.Contains(x))` → `Assert.That(s, Does.Contain(x))` for richer failure messages
- CA1866: `.StartsWith("$"|"@"|":")` → `.StartsWith('$'|'@'|':')` char overload

Driven by `dotnet format analyzers --diagnostics NUnit2046 NUnit2011 CA1866`
for the cases the Roslyn fixer handles, plus a regex sweep for the remaining
`Count == n` (n>0) cases which the fixer doesn't address. CA1866 had no
associated code fix and was edited by hand (3 sites in 2 files). All tests
green (1180 passing).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thom Lamb
2026-05-27 11:58:00 -05:00
co-authored by Claude Opus 4.7
parent 5aca8e93fd
commit 505ada5017
24 changed files with 105 additions and 105 deletions
@@ -17,7 +17,7 @@ public class QueryBreakdownCollectionTests
public void Constructor_Empty_CreatesEmptyCollection()
{
// Act & Assert
Assert.That(_collection.Count, Is.EqualTo(0));
Assert.That(_collection, Is.Empty);
Assert.That(_collection.QueryBreakdowns, Is.Empty);
}
@@ -35,8 +35,8 @@ public class QueryBreakdownCollectionTests
var collection = new QueryBreakdownCollection(queries);
// Assert
Assert.That(collection.Count, Is.EqualTo(2));
Assert.That(collection.QueryBreakdowns.Count, Is.EqualTo(2));
Assert.That(collection, Has.Count.EqualTo(2));
Assert.That(collection.QueryBreakdowns, Has.Count.EqualTo(2));
}
[Test]
@@ -49,7 +49,7 @@ public class QueryBreakdownCollectionTests
_collection.Add(query);
// Assert
Assert.That(_collection.Count, Is.EqualTo(1));
Assert.That(_collection, Has.Count.EqualTo(1));
Assert.That(_collection.QueryBreakdowns[0], Is.EqualTo(query));
}
@@ -103,7 +103,7 @@ public class QueryBreakdownCollectionTests
var results = _collection.WhereUseStageReference().ToList();
// Assert
Assert.That(results.Count, Is.EqualTo(1));
Assert.That(results, Has.Count.EqualTo(1));
}
[Test]
@@ -121,7 +121,7 @@ public class QueryBreakdownCollectionTests
// Assert
// Only the stage reference query should be returned, not the parameter query
Assert.That(results.Count, Is.EqualTo(1));
Assert.That(results, Has.Count.EqualTo(1));
Assert.That(results[0], Is.EqualTo(queryWithStage));
}
@@ -139,7 +139,7 @@ public class QueryBreakdownCollectionTests
var results = _collection.WhereUseSemiStructuredData().ToList();
// Assert
Assert.That(results.Count, Is.EqualTo(1));
Assert.That(results, Has.Count.EqualTo(1));
}
[Test]
@@ -168,7 +168,7 @@ public class QueryBreakdownCollectionTests
var tables = _collection.GetUniqueTableReferences().ToList();
// Assert
Assert.That(tables.Count, Is.EqualTo(2));
Assert.That(tables, Has.Count.EqualTo(2));
Assert.That(tables, Does.Contain("Users"));
Assert.That(tables, Does.Contain("Orders"));
}
@@ -187,7 +187,7 @@ public class QueryBreakdownCollectionTests
var summaries = _collection.GetQuerySummaries().ToList();
// Assert
Assert.That(summaries.Count, Is.EqualTo(2));
Assert.That(summaries, Has.Count.EqualTo(2));
Assert.That(summaries[0].UsesSemiStructuredData, Is.True);
Assert.That(summaries[1].UsesStageReference, Is.True);
}
@@ -273,6 +273,6 @@ public class QueryBreakdownCollectionTests
_collection.Clear();
// Assert
Assert.That(_collection.Count, Is.EqualTo(0));
Assert.That(_collection, Is.Empty);
}
}