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>
79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using Strata.SqlTools.SqlBreakdown.Classes;
|
|
|
|
namespace Strata.SqlTools.SqlBreakdown.Tests.SqlBreakdownCollectionTests;
|
|
|
|
/// <summary>
|
|
/// Unit tests for SqlBreakdownCollection with DELETE statements.
|
|
/// </summary>
|
|
[TestFixture]
|
|
public class SqlBreakdownCollectionDeleteTests : SqlBreakdownCollectionTestBase
|
|
{
|
|
[Test]
|
|
public void ParseBatch_WithDeleteStatements_ParsesSuccessfully()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
DELETE FROM Orders WHERE OrderDate < '2019-01-01'
|
|
GO
|
|
DELETE FROM UserProfiles WHERE UserId NOT IN (SELECT Id FROM Users)
|
|
GO
|
|
DELETE FROM AuditLog WHERE LogDate < DATEADD(year, -2, GETDATE())
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection, Has.Count.EqualTo(3));
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("DELETE FROM Orders"));
|
|
Assert.That(collection.GetRawStatementAt(1), Does.Contain("NOT IN"));
|
|
Assert.That(collection.GetRawStatementAt(2), Does.Contain("DATEADD"));
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void ParseBatch_WithDeleteFromSelectStatements_ParsesSuccessfully()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
DELETE o FROM Orders o
|
|
WHERE NOT EXISTS (SELECT 1 FROM OrderItems oi WHERE oi.OrderId = o.OrderId)
|
|
GO
|
|
DELETE FROM Users
|
|
WHERE Id IN (SELECT UserId FROM Orders WHERE OrderStatus = 'Cancelled')
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection, Has.Count.EqualTo(2));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("EXISTS"));
|
|
}
|
|
|
|
[Test]
|
|
public void ParseBatch_WithDeleteWithJoinStatements_ParsesSuccessfully()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
DELETE Orders
|
|
FROM Orders o
|
|
INNER JOIN OrderStatuses os ON o.StatusId = os.Id
|
|
WHERE os.StatusName = 'Archived'
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection.Count, Is.GreaterThanOrEqualTo(1));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("DELETE Orders"));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("INNER JOIN"));
|
|
}
|
|
}
|