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:
co-authored by
Claude Opus 4.7
parent
5aca8e93fd
commit
505ada5017
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ public class QueryBreakdownTests
|
||||
mainQueryBreakdown.AddWithClause("PRODUCT_ORDERS", cteSql);
|
||||
|
||||
// Assert
|
||||
Assert.That(mainQueryBreakdown.WithClauses.Count, Is.EqualTo(1));
|
||||
Assert.That(mainQueryBreakdown.WithClauses, Has.Count.EqualTo(1));
|
||||
Assert.That(mainQueryBreakdown.WithClauses[0].TableName, Is.EqualTo("PRODUCT_ORDERS"));
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class QueryBreakdownTests
|
||||
mainQueryBreakdown.AddWithClause("ProductOrders", cteSql, isMicrosoftSql: true);
|
||||
|
||||
// Assert
|
||||
Assert.That(mainQueryBreakdown.WithClauses.Count, Is.EqualTo(1));
|
||||
Assert.That(mainQueryBreakdown.WithClauses, Has.Count.EqualTo(1));
|
||||
Assert.That(mainQueryBreakdown.WithClauses[0].TableName, Is.EqualTo("ProductOrders"));
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class QueryBreakdownTests
|
||||
mainQueryBreakdown.AddWithClause("PRODUCT_ORDERS", cteQuery);
|
||||
|
||||
// Assert
|
||||
Assert.That(mainQueryBreakdown.WithClauses.Count, Is.EqualTo(1));
|
||||
Assert.That(mainQueryBreakdown.WithClauses, Has.Count.EqualTo(1));
|
||||
Assert.That(mainQueryBreakdown.WithClauses[0].Query, Is.EqualTo(cteQuery));
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ public class QueryBreakdownTests
|
||||
|
||||
// Assert - Now using WITH clause
|
||||
Assert.That(query.IsUsingWithClause, Is.True);
|
||||
Assert.That(query.WithClauses.Count, Is.EqualTo(1));
|
||||
Assert.That(query.WithClauses, Has.Count.EqualTo(1));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -688,7 +688,7 @@ public class QueryBreakdownTests
|
||||
queryBreakdown.AddWithClause("ORDER_CTE", cte);
|
||||
|
||||
// Assert
|
||||
Assert.That(queryBreakdown.WithClauses.Count, Is.EqualTo(1));
|
||||
Assert.That(queryBreakdown.WithClauses, Has.Count.EqualTo(1));
|
||||
Assert.That(queryBreakdown.IsUsingWithClause, Is.True);
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ public class QueryBreakdownTests
|
||||
// Assert
|
||||
Assert.That(sql, Does.Contain("WITH"));
|
||||
Assert.That(sql, Does.Contain("MIDDLE_CTE AS ("));
|
||||
Assert.That(mainQueryBreakdown.WithClauses.Count, Is.EqualTo(1));
|
||||
Assert.That(mainQueryBreakdown.WithClauses, Has.Count.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -1511,7 +1511,7 @@ public class QueryBreakdownTests
|
||||
var snowflakeSql = result.GetSql();
|
||||
|
||||
// Assert
|
||||
Assert.That(result.WithClauses.Count, Is.EqualTo(1));
|
||||
Assert.That(result.WithClauses, Has.Count.EqualTo(1));
|
||||
Assert.That(snowflakeSql, Does.Contain("WITH"));
|
||||
Assert.That(snowflakeSql, Does.Contain("ProductSummary AS ("));
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class RecursiveCTETests
|
||||
|
||||
// Assert
|
||||
// Snowflake stores parameters with both @ and : formats
|
||||
var statusKey = merged.Keys.FirstOrDefault(k => k.Contains("Status") && (k.StartsWith("@") || k.StartsWith(":")));
|
||||
var statusKey = merged.Keys.FirstOrDefault(k => k.Contains("Status") && (k.StartsWith('@') || k.StartsWith(':')));
|
||||
Assert.That(statusKey, Is.Not.Null);
|
||||
Assert.That(merged[statusKey], Is.EqualTo("active"), "Main query parameter should take precedence");
|
||||
}
|
||||
@@ -247,8 +247,8 @@ public class RecursiveCTETests
|
||||
|
||||
// Assert
|
||||
Assert.That(sql, Contains.Substring("WITH RECURSIVE"));
|
||||
Assert.That(sql.Contains("base AS"), "Non-recursive CTE should be included");
|
||||
Assert.That(sql.Contains("tree_hierarchy AS"), "Recursive CTE should be included");
|
||||
Assert.That(sql, Does.Contain("base AS"), "Non-recursive CTE should be included");
|
||||
Assert.That(sql, Does.Contain("tree_hierarchy AS"), "Recursive CTE should be included");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user