56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using Strata.SqlTools.SqlBreakdown.Classes;
|
|
|
|
namespace Strata.SqlTools.SqlBreakdown.Tests.SqlBreakdownCollectionTests;
|
|
|
|
/// <summary>
|
|
/// Unit tests for SqlBreakdownCollection with DROP statements.
|
|
/// </summary>
|
|
[TestFixture]
|
|
public class SqlBreakdownCollectionDropTests : SqlBreakdownCollectionTestBase
|
|
{
|
|
[Test]
|
|
public void ParseBatch_WithDropTableStatements_ParsesSuccessfully()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
DROP TABLE IF EXISTS OrderItems
|
|
GO
|
|
DROP TABLE IF EXISTS Orders
|
|
GO
|
|
DROP TABLE IF EXISTS Users
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection.Count, Is.EqualTo(3));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("DROP TABLE"));
|
|
Assert.That(collection.GetRawStatementAt(1), Does.Contain("DROP TABLE"));
|
|
}
|
|
|
|
[Test]
|
|
public void ParseBatch_WithDropIndexAndProcedureStatements_ParsesSuccessfully()
|
|
{
|
|
// Arrange
|
|
var collection = new SqlBreakdownCollection();
|
|
var batchSql = @"
|
|
DROP INDEX IF EXISTS idx_Users_Email ON Users
|
|
GO
|
|
DROP PROCEDURE IF EXISTS sp_GetUserById
|
|
GO
|
|
DROP VIEW IF EXISTS vw_UserOrders
|
|
";
|
|
|
|
// Act
|
|
collection.ParseBatch(batchSql);
|
|
|
|
// Assert
|
|
Assert.That(collection.Count, Is.EqualTo(3));
|
|
Assert.That(collection.GetRawStatementAt(0), Does.Contain("DROP INDEX"));
|
|
Assert.That(collection.GetRawStatementAt(1), Does.Contain("PROCEDURE"));
|
|
Assert.That(collection.GetRawStatementAt(2), Does.Contain("VIEW"));
|
|
}
|
|
}
|