feat(etl): implement DbBulkMergeDestination for incremental updates
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using JdeScoping.DataAccess.Interfaces;
|
||||
using JdeScoping.DataSync.Etl.Destinations;
|
||||
using NSubstitute;
|
||||
|
||||
namespace JdeScoping.DataSync.Tests.Etl.Destinations;
|
||||
|
||||
public class DbBulkMergeDestinationTests
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_SetsDestinationName()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
var dest = new DbBulkMergeDestination(factory, "WorkOrder", new[] { "OrderNumber" });
|
||||
Assert.Equal("BulkMerge:WorkOrder", dest.DestinationName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullFactory_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
new DbBulkMergeDestination(null!, "WorkOrder", new[] { "Id" }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullTableName_ThrowsArgumentNullException()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
new DbBulkMergeDestination(factory, null!, new[] { "Id" }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_EmptyTableName_ThrowsArgumentException()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
new DbBulkMergeDestination(factory, "", new[] { "Id" }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_EmptyMatchColumns_ThrowsArgumentException()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
new DbBulkMergeDestination(factory, "WorkOrder", Array.Empty<string>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullMatchColumns_ThrowsArgumentNullException()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
new DbBulkMergeDestination(factory, "WorkOrder", null!));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WithUpdateColumns_Succeeds()
|
||||
{
|
||||
var factory = Substitute.For<IDbConnectionFactory>();
|
||||
var dest = new DbBulkMergeDestination(factory, "WorkOrder",
|
||||
new[] { "OrderNumber" },
|
||||
updateColumns: new[] { "Status", "Description" });
|
||||
Assert.Equal("BulkMerge:WorkOrder", dest.DestinationName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user