feat(etl): implement DbQuerySource for database queries

Adds DbQuerySource, an IImportSource implementation that executes SQL
queries against the LotFinder database. Supports parameterized queries
using anonymous objects and configurable command timeouts.
This commit is contained in:
Joseph Doherty
2026-01-03 09:18:58 -05:00
parent 74c3f37446
commit 8594baf11d
2 changed files with 131 additions and 0 deletions
@@ -0,0 +1,44 @@
using JdeScoping.DataAccess.Interfaces;
using JdeScoping.DataSync.Etl.Sources;
using NSubstitute;
namespace JdeScoping.DataSync.Tests.Etl.Sources;
public class DbQuerySourceTests
{
[Fact]
public void Constructor_SetsSourceName()
{
var factory = Substitute.For<IDbConnectionFactory>();
var source = new DbQuerySource(factory, "SELECT 1", "TestSource");
Assert.Equal("DbQuery:TestSource", source.SourceName);
}
[Fact]
public void Constructor_NullName_UsesDefault()
{
var factory = Substitute.For<IDbConnectionFactory>();
var source = new DbQuerySource(factory, "SELECT 1");
Assert.Equal("DbQuery:Query", source.SourceName);
}
[Fact]
public void Constructor_NullFactory_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>(() => new DbQuerySource(null!, "SELECT 1"));
}
[Fact]
public void Constructor_NullSql_ThrowsArgumentNullException()
{
var factory = Substitute.For<IDbConnectionFactory>();
Assert.Throws<ArgumentNullException>(() => new DbQuerySource(factory, null!));
}
[Fact]
public void Constructor_EmptySql_ThrowsArgumentException()
{
var factory = Substitute.For<IDbConnectionFactory>();
Assert.Throws<ArgumentException>(() => new DbQuerySource(factory, ""));
}
}