chore: initial git load of code space
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
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.Count, Is.GreaterThanOrEqualTo(1));
|
||||
var statement = collection.GetRawStatementAt(0);
|
||||
Assert.That(statement, Does.Contain("BEGIN TRANSACTION"));
|
||||
Assert.That(statement, Does.Contain("COMMIT"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user