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>
77 lines
2.5 KiB
C#
77 lines
2.5 KiB
C#
using Strata.SqlTools.SqlBreakdown.Classes;
|
|
|
|
namespace Strata.SqlTools.SqlBreakdown.Tests.SqlBreakdownCollectionTests;
|
|
|
|
/// <summary>
|
|
/// Unit tests for SqlBreakdownCollection with parameterized statements.
|
|
/// </summary>
|
|
[TestFixture]
|
|
public class SqlBreakdownCollectionParameterTests : SqlBreakdownCollectionTestBase
|
|
{
|
|
[Test]
|
|
public void ParseBatch_WithParameterizedInsertStatements_PreservesParameters()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
INSERT INTO Users (Id, Name, Email) VALUES (@UserId, @UserName, @UserEmail)
|
|
GO
|
|
INSERT INTO Orders (OrderId, UserId, OrderDate) VALUES (@OrderId, @UserId, @OrderDate)
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection, Has.Count.EqualTo(2));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("@UserId"));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("@UserEmail"));
|
|
}
|
|
|
|
[Test]
|
|
public void ParseBatch_WithParameterizedUpdateStatements_PreservesParameters()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
UPDATE Users SET Name = @Name, Email = @Email WHERE Id = @UserId
|
|
GO
|
|
UPDATE Orders SET Status = @Status, ModifiedDate = @ModifiedDate WHERE OrderId = @OrderId
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection, Has.Count.EqualTo(2));
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("@Name"));
|
|
Assert.That(collection.GetRawStatementAt(1), Does.Contain("@Status"));
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void GetCombinedSql_WithMixedCrudOperations_CombinesCorrectly()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
collection.ParseBatch(@"
|
|
INSERT INTO Users (Id, Name) VALUES (1, 'John')
|
|
GO
|
|
UPDATE Users SET Name = 'Jane' WHERE Id = 1
|
|
GO
|
|
DELETE FROM Users WHERE Id = 1
|
|
");
|
|
|
|
// Act
|
|
var combined = collection.GetCombinedSql();
|
|
|
|
// Assert
|
|
Assert.That(combined, Does.Contain("INSERT"));
|
|
Assert.That(combined, Does.Contain("UPDATE"));
|
|
Assert.That(combined, Does.Contain("DELETE"));
|
|
Assert.That(combined, Does.Contain("GO"));
|
|
}
|
|
}
|