chore: initial git load of code space
This commit is contained in:
+66
@@ -0,0 +1,66 @@
|
||||
using Strata.SqlTools.SqlBreakdown.Interfaces;
|
||||
using System.Text;
|
||||
|
||||
namespace Strata.SqlTools.SqlBreakdown.Tests.SqlBreakdownCollectionTests;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for SqlBreakdownCollection tests containing shared test utilities and mock implementations.
|
||||
/// </summary>
|
||||
public class SqlBreakdownCollectionTestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Mock implementation of ISqlBreakdown for testing purposes.
|
||||
/// </summary>
|
||||
public class MockSqlBreakdown : ISqlBreakdown
|
||||
{
|
||||
private readonly string _sql;
|
||||
|
||||
public MockSqlBreakdown(string sql)
|
||||
{
|
||||
_sql = sql;
|
||||
SetupClauses = new List<string>();
|
||||
FinishClauses = new System.Collections.ArrayList();
|
||||
}
|
||||
|
||||
public string? RawSql { get; set; }
|
||||
public List<string> SetupClauses { get; set; }
|
||||
public bool IsUsingSetupClause => SetupClauses.Count > 0;
|
||||
public System.Collections.ArrayList FinishClauses { get; set; }
|
||||
public bool IsUsingFinishClause => FinishClauses.Count > 0;
|
||||
|
||||
public string GetSql(bool includeSetupFinish = true)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
if (includeSetupFinish)
|
||||
{
|
||||
foreach (string setup in SetupClauses)
|
||||
{
|
||||
sb.AppendLine(setup);
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append(_sql);
|
||||
|
||||
if (includeSetupFinish)
|
||||
{
|
||||
foreach (string finish in FinishClauses)
|
||||
{
|
||||
sb.AppendLine(finish);
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public override string ToString() => GetSql();
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var clone = (MockSqlBreakdown)MemberwiseClone();
|
||||
clone.SetupClauses = new List<string>(SetupClauses);
|
||||
clone.FinishClauses = new System.Collections.ArrayList(FinishClauses);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user