chore: initial git load of code space
This commit is contained in:
+73
@@ -0,0 +1,73 @@
|
||||
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.Count, Is.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.Count, Is.EqualTo(2));
|
||||
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"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user