chore(sonar): second sweep — catch .Length, Is.Not.Empty, and newly-exposed Multiple groups (NUnit2046, NUnit2045)
SonarQube Analysis / sonarqube (pull_request) Successful in 2m59s
SonarQube Analysis / sonarqube (pull_request) Successful in 2m59s
Re-runs `dotnet format analyzers --diagnostics NUnit2046 NUnit2045` after the Tier 2 Assert.Multiple wrap, which exposed: - `Has.Length.EqualTo(n)` rewrites for `string[]`/array `.Length` checks (the first pass only knew about `.Count`). - `Is.Not.Empty` rewrites for `Count, Is.GreaterThan(0)`. - A handful of new NUnit2045 groups that became wrappable once the initial Multiple blocks settled the surrounding indentation. Tests still 1180/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
470cb009b9
commit
4fe9eb36e6
@@ -406,7 +406,7 @@ public class QueryCollectionAnalyzerTests
|
||||
var similar = analyzer.FindSimilarQueries(0.5); // Lower threshold for testing
|
||||
|
||||
// Assert
|
||||
Assert.That(similar.Count, Is.GreaterThan(0));
|
||||
Assert.That(similar, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -550,7 +550,7 @@ public class QueryValidatorTests
|
||||
|
||||
// Assert
|
||||
Assert.That(validator, Is.Not.Null);
|
||||
Assert.That(validator.Issues.Count, Is.GreaterThan(0));
|
||||
Assert.That(validator.Issues, Is.Not.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -39,7 +39,7 @@ public class QueryBreakdownCollectionTests
|
||||
_collection.Add(query);
|
||||
|
||||
// Assert
|
||||
Assert.That(_collection.Count, Is.GreaterThan(0));
|
||||
Assert.That(_collection, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -186,7 +186,7 @@ public class QueryBreakdownCollectionTests
|
||||
{
|
||||
// Assert
|
||||
Assert.That(result, Is.True);
|
||||
Assert.That(_collection.Count, Is.GreaterThan(0));
|
||||
Assert.That(_collection, Is.Not.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public class QueryBreakdownCollectionTests
|
||||
{
|
||||
// Assert
|
||||
Assert.That(result, Is.True);
|
||||
Assert.That(_collection.Count, Is.GreaterThan(0));
|
||||
Assert.That(_collection, Is.Not.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public class QueryBreakdownTests
|
||||
|
||||
// Assert
|
||||
// The @ prefix is stripped
|
||||
Assert.That(queryBreakdown.Parameters.Count, Is.GreaterThan(0));
|
||||
Assert.That(queryBreakdown.Parameters, Is.Not.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -95,7 +95,7 @@ public class StatementReaderTests
|
||||
}
|
||||
|
||||
// Assert
|
||||
Assert.That(tokens.Count, Is.GreaterThan(0));
|
||||
Assert.That(tokens, Is.Not.Empty);
|
||||
var paramTokens = tokens.Where(t => t.Type == TokenType.Parameter).ToList();
|
||||
Assert.That(paramTokens, Has.Count.EqualTo(2));
|
||||
Assert.Multiple(() =>
|
||||
@@ -173,7 +173,7 @@ public class StatementReaderTests
|
||||
}
|
||||
|
||||
// Assert
|
||||
Assert.That(tokens.Count, Is.GreaterThan(0));
|
||||
Assert.That(tokens, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -191,7 +191,7 @@ public class StatementReaderTests
|
||||
}
|
||||
|
||||
// Assert
|
||||
Assert.That(tokens.Count, Is.GreaterThan(0));
|
||||
Assert.That(tokens, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -229,6 +229,6 @@ public class StatementReaderTests
|
||||
|
||||
// Assert
|
||||
var numberTokens = tokens.Where(t => t.Type == TokenType.Number).ToList();
|
||||
Assert.That(numberTokens.Count, Is.GreaterThan(0));
|
||||
Assert.That(numberTokens, Is.Not.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public class QueryBreakdownCollectionTests
|
||||
var report = _collection.GetParameterUsageReport().ToList();
|
||||
|
||||
// Assert
|
||||
Assert.That(report.Count, Is.GreaterThan(0));
|
||||
Assert.That(report, Is.Not.Empty);
|
||||
var userIdReport = report.FirstOrDefault(r => r.ParameterName == "UserId");
|
||||
Assert.That(userIdReport, Is.Not.Null);
|
||||
Assert.That(userIdReport?.UsedInQueryCount, Is.EqualTo(2));
|
||||
|
||||
@@ -127,7 +127,7 @@ public class QueryBreakdownTests
|
||||
// Verify 4-space Snowflake indentation
|
||||
var lines = sql.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
var indentedLines = lines.Where(l => l.StartsWith(" ")).ToList();
|
||||
Assert.That(indentedLines.Count, Is.GreaterThan(0));
|
||||
Assert.That(indentedLines, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -306,10 +306,13 @@ public class QueryBreakdownTests
|
||||
Assert.That(withIndex, Is.GreaterThan(-1));
|
||||
Assert.That(mainSelectIndex, Is.GreaterThan(-1));
|
||||
});
|
||||
Assert.That(withIndex, Is.LessThan(mainSelectIndex));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(withIndex, Is.LessThan(mainSelectIndex));
|
||||
|
||||
// Assert - Verify CTE definition
|
||||
Assert.That(sql, Does.Contain("PRODUCT_TOTALS"));
|
||||
// Assert - Verify CTE definition
|
||||
Assert.That(sql, Does.Contain("PRODUCT_TOTALS"));
|
||||
});
|
||||
Assert.That(sql, Does.Contain("AS"));
|
||||
Assert.That(sql, Does.Contain("PRODUCT_ID"));
|
||||
Assert.That(sql, Does.Contain("TOTAL_QUANTITY"));
|
||||
@@ -457,7 +460,7 @@ public class QueryBreakdownTests
|
||||
// Assert
|
||||
// Main query value should win
|
||||
var keys = merged.Keys.Where(k => k.Contains("QueryLimit")).ToList();
|
||||
Assert.That(keys.Count, Is.GreaterThan(0));
|
||||
Assert.That(keys, Is.Not.Empty);
|
||||
// All QueryLimit entries should be 100 (main query's value)
|
||||
foreach (var key in keys)
|
||||
{
|
||||
@@ -614,7 +617,7 @@ public class QueryBreakdownTests
|
||||
var queryBreakdown = QueryBreakdown.Parse(sql, false);
|
||||
|
||||
// Assert
|
||||
Assert.That(queryBreakdown.Parameters.Count, Is.GreaterThan(0));
|
||||
Assert.That(queryBreakdown.Parameters, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -1070,7 +1073,7 @@ public class QueryBreakdownTests
|
||||
|
||||
// Assert
|
||||
// Base class normalizes to @, but Snowflake might handle differently
|
||||
Assert.That(queryBreakdown.Parameters.Count, Is.GreaterThan(0));
|
||||
Assert.That(queryBreakdown.Parameters, Is.Not.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1188,7 +1191,7 @@ public class QueryBreakdownTests
|
||||
// Assert - Snowflake should use 4-space indent, base uses 5-space
|
||||
var snowflakeLines = snowflakeSql.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
var snowflakeIndentedLines = snowflakeLines.Where(l => l.StartsWith(" ") && !l.StartsWith(" ")).ToList();
|
||||
Assert.That(snowflakeIndentedLines.Count, Is.GreaterThan(0), "Snowflake should use 4-space indentation");
|
||||
Assert.That(snowflakeIndentedLines, Is.Not.Empty, "Snowflake should use 4-space indentation");
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1407,7 +1410,7 @@ public class QueryBreakdownTests
|
||||
// Verify Snowflake-style formatting (4-space indentation)
|
||||
var lines = snowflakeSql.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
var indentedLines = lines.Where(l => l.StartsWith(" ")).ToList();
|
||||
Assert.That(indentedLines.Count, Is.GreaterThan(0), "Should have Snowflake-style indentation");
|
||||
Assert.That(indentedLines, Is.Not.Empty, "Should have Snowflake-style indentation");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DateFunctionTests : ExpressionTestsBase
|
||||
{
|
||||
var sql = (string)result;
|
||||
Assert.That(sql, Is.Not.Null);
|
||||
Assert.That(sql.Length, Is.GreaterThan(0));
|
||||
Assert.That(sql, Is.Not.Empty);
|
||||
Assert.That(sql, Is.EqualTo("DATE_TRUNC('month', DATEADD('month', 6, PES.DISCHARGE_DATE))"));
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class ExpressionFactoryFilterTests : ExpressionTestsBase
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.Not.Null);
|
||||
Assert.That(result.Length, Is.GreaterThan(0));
|
||||
Assert.That(result, Is.Not.Empty);
|
||||
Assert.That(result, Is.EqualTo(expectedSql));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -65,9 +65,8 @@ public class GenericColumnExpressionTests : ExpressionTestsBase
|
||||
Assertions = result =>
|
||||
{
|
||||
var results = (Dictionary<string, string>)result;
|
||||
Assert.That(results["priceCondition"], Does.Contain("Price"));
|
||||
Assert.That(results["priceCondition"], Does.Contain("100"));
|
||||
Assert.That(results["categoryCondition"], Does.Contain("Category"));
|
||||
Assert.That(results["priceCondition"], Does.Contain("Price")); Assert.Multiple(() => { Assert.That(results["priceCondition"], Does.Contain("100"));
|
||||
Assert.That(results["categoryCondition"], Does.Contain("Category")); });
|
||||
Assert.That(results["categoryCondition"], Does.Contain("Electronics"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -57,8 +57,11 @@ public class JsonTokenReaderTests
|
||||
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.Multiple(() =>
|
||||
{
|
||||
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));
|
||||
Assert.That(tokens[tokenIndex++].Value, Is.EqualTo("3"));
|
||||
Assert.That(tokens[tokenIndex].Type, Is.EqualTo(JsonTokenType.Number));
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ public class SqlBreakdownCollectionCreateTests : SqlBreakdownCollectionTestBase
|
||||
collection.ParseBatch(batchSql);
|
||||
|
||||
// Assert
|
||||
Assert.That(collection.Count, Is.GreaterThanOrEqualTo(1));
|
||||
Assert.That(collection, Is.Not.Empty);
|
||||
Assert.That(collection.GetRawStatementAt(0), Does.Contain("CREATE PROCEDURE"));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class SqlBreakdownCollectionDeleteTests : SqlBreakdownCollectionTestBase
|
||||
collection.ParseBatch(batchSql);
|
||||
|
||||
// Assert
|
||||
Assert.That(collection.Count, Is.GreaterThanOrEqualTo(1));
|
||||
Assert.That(collection, Is.Not.Empty);
|
||||
Assert.That(collection.GetRawStatementAt(0), Does.Contain("DELETE Orders"));
|
||||
Assert.That(collection.GetRawStatementAt(0), Does.Contain("INNER JOIN"));
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class SqlBreakdownCollectionSelectTests : SqlBreakdownCollectionTestBase
|
||||
collection.ParseBatch(batchSql);
|
||||
|
||||
// Assert
|
||||
Assert.That(collection.Count, Is.GreaterThanOrEqualTo(1));
|
||||
Assert.That(collection, Is.Not.Empty);
|
||||
Assert.That(collection.GetRawStatementAt(0), Does.Contain("WITH UserOrders AS"));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class SqlBreakdownCollectionTransactionTests : SqlBreakdownCollectionTest
|
||||
collection.ParseBatch(batchSql);
|
||||
|
||||
// Assert
|
||||
Assert.That(collection.Count, Is.GreaterThanOrEqualTo(1));
|
||||
Assert.That(collection, Is.Not.Empty);
|
||||
var statement = collection.GetRawStatementAt(0);
|
||||
Assert.That(statement, Does.Contain("BEGIN TRANSACTION"));
|
||||
Assert.That(statement, Does.Contain("COMMIT"));
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ public class SqlBreakdownCollectionUpdateTests : SqlBreakdownCollectionTestBase
|
||||
collection.ParseBatch(batchSql);
|
||||
|
||||
// Assert
|
||||
Assert.That(collection.Count, Is.GreaterThanOrEqualTo(1));
|
||||
Assert.That(collection, Is.Not.Empty);
|
||||
Assert.That(collection.GetRawStatementAt(0), Does.Contain("UPDATE Orders"));
|
||||
Assert.That(collection.GetRawStatementAt(0), Does.Contain("JOIN"));
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ public class QueryBreakdownCollectionTests
|
||||
var report = _collection.GetParameterUsageReport().ToList();
|
||||
|
||||
// Assert
|
||||
Assert.That(report.Count, Is.GreaterThan(0));
|
||||
Assert.That(report, Is.Not.Empty);
|
||||
var userIdReport = report.FirstOrDefault(r => r.ParameterName == "UserId");
|
||||
Assert.That(userIdReport, Is.Not.Null);
|
||||
Assert.That(userIdReport?.UsedInQueryCount, Is.EqualTo(2));
|
||||
|
||||
@@ -29,9 +29,12 @@ public class QueryBreakdownTests
|
||||
Assert.That(query.FinishClauses, Is.Not.Null);
|
||||
Assert.That(query.WithClauses, Is.Not.Null);
|
||||
});
|
||||
Assert.That(query.WithClauses, Is.Empty);
|
||||
Assert.That(query.Parameters, Is.Not.Null);
|
||||
Assert.That(query.ParameterList, Is.Not.Null);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(query.WithClauses, Is.Empty);
|
||||
Assert.That(query.Parameters, Is.Not.Null);
|
||||
Assert.That(query.ParameterList, Is.Not.Null);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -778,10 +781,13 @@ public class QueryBreakdownTests
|
||||
Assert.That(withIndex, Is.GreaterThan(-1));
|
||||
Assert.That(mainSelectIndex, Is.GreaterThan(-1));
|
||||
});
|
||||
Assert.That(withIndex, Is.LessThan(mainSelectIndex));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(withIndex, Is.LessThan(mainSelectIndex));
|
||||
|
||||
// Assert - Verify CTE definition
|
||||
Assert.That(sql, Does.Contain("ProductTotals"));
|
||||
// Assert - Verify CTE definition
|
||||
Assert.That(sql, Does.Contain("ProductTotals"));
|
||||
});
|
||||
Assert.That(sql, Does.Contain("AS"));
|
||||
Assert.That(sql, Does.Contain("ProductID"));
|
||||
Assert.That(sql, Does.Contain("TotalQuantity"));
|
||||
|
||||
Reference in New Issue
Block a user