using System.Data;
using JdeScoping.DataSync.Contracts;
using JdeScoping.DataSync.Generated;
namespace JdeScoping.DataSync.IntegrationTests.Infrastructure;
///
/// DataReaderFactory for integration tests that supports both test entities and production entities.
///
public class TestDataReaderFactory : IDataReaderFactory
{
private readonly DataReaderFactory _innerFactory = new();
public IDataReader CreateReader(IAsyncEnumerable source) where T : class
{
// Handle test entity
if (typeof(T) == typeof(BulkMergeTestEntity))
{
return new BulkMergeTestEntityDataReader((IAsyncEnumerable)(object)source);
}
// Delegate to production factory for other types
return _innerFactory.CreateReader(source);
}
public IReadOnlyList GetColumnNames() where T : class
{
// Handle test entity
if (typeof(T) == typeof(BulkMergeTestEntity))
{
return BulkMergeTestEntityDataReader.GetColumnNames();
}
// Delegate to production factory for other types
return _innerFactory.GetColumnNames();
}
}