feat(etl): implement DbBulkImportDestination for full table refresh
Add bulk import destination that truncates and loads data using SqlBulkCopy with configurable batch sizes and streaming support.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using JdeScoping.DataAccess.Interfaces;
|
||||
using JdeScoping.DataSync.Etl.Destinations;
|
||||
using NSubstitute;
|
||||
|
||||
namespace JdeScoping.DataSync.Tests.Etl.Destinations;
|
||||
|
||||
public class DbBulkImportDestinationTests
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_SetsDestinationName()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
var dest = new DbBulkImportDestination(factory, "WorkOrder");
|
||||
Assert.Equal("BulkImport:WorkOrder", dest.DestinationName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullFactory_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new DbBulkImportDestination(null!, "WorkOrder"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullTableName_ThrowsArgumentNullException()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
Assert.Throws<ArgumentNullException>(() => new DbBulkImportDestination(factory, null!));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_EmptyTableName_ThrowsArgumentException()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
Assert.Throws<ArgumentException>(() => new DbBulkImportDestination(factory, ""));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0)] // 0 means default
|
||||
[InlineData(5000)]
|
||||
[InlineData(50000)]
|
||||
public void Constructor_VariousBatchSizes_Succeeds(int batchSize)
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
var dest = new DbBulkImportDestination(factory, "WorkOrder", batchSize: batchSize);
|
||||
Assert.NotNull(dest);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\JdeScoping.DataAccess\JdeScoping.DataAccess.csproj" />
|
||||
<ProjectReference Include="..\..\src\JdeScoping.DataSync\JdeScoping.DataSync.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user