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>
80 lines
2.7 KiB
C#
80 lines
2.7 KiB
C#
using Strata.SqlTools.SqlBreakdown.Classes;
|
|
|
|
namespace Strata.SqlTools.SqlBreakdown.Tests.SqlBreakdownCollectionTests;
|
|
|
|
/// <summary>
|
|
/// Unit tests for SqlBreakdownCollection with INSERT statements.
|
|
/// </summary>
|
|
[TestFixture]
|
|
public class SqlBreakdownCollectionInsertTests : SqlBreakdownCollectionTestBase
|
|
{
|
|
[Test]
|
|
public void ParseBatch_WithInsertStatements_ParsesSuccessfully()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
INSERT INTO Users (Id, Name, Email) VALUES (1, 'John Doe', 'john@example.com')
|
|
GO
|
|
INSERT INTO Users (Id, Name, Email) VALUES (2, 'Jane Smith', 'jane@example.com')
|
|
GO
|
|
INSERT INTO Users (Id, Name, Email) VALUES (3, 'Bob Johnson', 'bob@example.com')
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection, Has.Count.EqualTo(3));
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("INSERT INTO Users"));
|
|
Assert.That(collection.GetRawStatementAt(1), Does.Contain("Jane Smith"));
|
|
Assert.That(collection.GetRawStatementAt(2), Does.Contain("Bob Johnson"));
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void ParseBatch_WithInsertSelectStatements_ParsesSuccessfully()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
INSERT INTO UsersArchive
|
|
SELECT Id, Name, Email FROM Users WHERE CreatedDate < '2020-01-01'
|
|
GO
|
|
INSERT INTO OrdersBackup
|
|
SELECT OrderId, UserId, OrderDate FROM Orders WHERE OrderDate < DATEADD(year, -1, GETDATE())
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection, Has.Count.EqualTo(2));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("INSERT INTO UsersArchive"));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("SELECT"));
|
|
}
|
|
|
|
[Test]
|
|
public void ParseBatch_WithBulkInsertStatements_ParsesSuccessfully()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
BULK INSERT Users FROM 'C:\data\users.csv'
|
|
WITH (FIELDTERMINATOR=',', ROWTERMINATOR='\n')
|
|
GO
|
|
BULK INSERT Orders FROM 'C:\data\orders.csv'
|
|
WITH (FIELDTERMINATOR=',', ROWTERMINATOR='\n')
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection, Has.Count.EqualTo(2));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("BULK INSERT"));
|
|
}
|
|
}
|