chore: initial git load of code space
This commit is contained in:
+76
@@ -0,0 +1,76 @@
|
||||
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.Count, Is.EqualTo(3));
|
||||
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.Count, Is.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.Count, Is.EqualTo(2));
|
||||
Assert.That(collection.GetRawStatementAt(0), Does.Contain("BULK INSERT"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user