feat(etl): implement SqlScriptRunner
Add SqlScriptRunner class that implements IScriptRunner for executing SQL scripts against the LotFinderDB cache database. Includes constructor validation and configurable timeout support (default 1 hour).
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using JdeScoping.DataAccess.Interfaces;
|
||||
using JdeScoping.DataSync.Etl.Scripts;
|
||||
using NSubstitute;
|
||||
|
||||
namespace JdeScoping.DataSync.Tests.Etl.Scripts;
|
||||
|
||||
public class SqlScriptRunnerTests
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_SetsScriptName()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
var runner = new SqlScriptRunner(factory, "SELECT 1", "TestScript");
|
||||
Assert.Equal("TestScript", runner.ScriptName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WithNullName_DefaultsToSqlScript()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
var runner = new SqlScriptRunner(factory, "SELECT 1");
|
||||
Assert.Equal("SqlScript", runner.ScriptName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullFactory_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new SqlScriptRunner(null!, "SELECT 1"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullSql_ThrowsArgumentNullException()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
Assert.Throws<ArgumentNullException>(() => new SqlScriptRunner(factory, null!));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_EmptySql_ThrowsArgumentException()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
Assert.Throws<ArgumentException>(() => new SqlScriptRunner(factory, ""));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user