82573df023
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).
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
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, ""));
|
|
}
|
|
}
|