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>
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using Strata.SqlTools.SqlBreakdown.Classes;
|
|
|
|
namespace Strata.SqlTools.SqlBreakdown.Tests.SqlBreakdownCollectionTests;
|
|
|
|
/// <summary>
|
|
/// Unit tests for SqlBreakdownCollection with transaction statements.
|
|
/// </summary>
|
|
[TestFixture]
|
|
public class SqlBreakdownCollectionTransactionTests : SqlBreakdownCollectionTestBase
|
|
{
|
|
[Test]
|
|
public void ParseBatch_WithTransactionStatements_ParsesSuccessfully()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
BEGIN TRANSACTION UpdatePrices
|
|
UPDATE Products SET Price = Price * 1.1 WHERE Category = 'Electronics'
|
|
UPDATE ProductPriceHistory SET NewPrice = Price FROM Products WHERE Products.Id = ProductPriceHistory.ProductId
|
|
COMMIT TRANSACTION UpdatePrices
|
|
GO
|
|
BEGIN TRANSACTION DeleteOldOrders
|
|
DELETE FROM OrderItems WHERE OrderId IN (SELECT OrderId FROM Orders WHERE OrderDate < '2018-01-01')
|
|
DELETE FROM Orders WHERE OrderDate < '2018-01-01'
|
|
COMMIT TRANSACTION DeleteOldOrders
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection, Is.Not.Empty);
|
|
var statement = collection.GetRawStatementAt(0);
|
|
Assert.That(statement, Does.Contain("BEGIN TRANSACTION"));
|
|
Assert.That(statement, Does.Contain("COMMIT"));
|
|
}
|
|
}
|