refactor: remove unused CMS/JDE repositories and data sources
Remove legacy JDE and CMS direct-access code that is no longer used: - Delete ICmsDataSource, IJdeDataSource interfaces - Delete ISearchProcessor, IUpdateProcessor interfaces - Delete IJdeRepository and ICmsRepository (all partials) - Delete JdeRepository and CmsRepository implementations - Delete JdeQueries and CmsQueries - Delete JdeFileDataSource, JdeOracleDataSource - Delete CmsFileDataSource, CmsOracleDataSource - Remove unused methods from LotFinderRepository interfaces - Delete associated unit tests (CmsRepositoryTests, JdeRepositoryTests) All data sync now uses ETL pipelines via DataSync project.
This commit is contained in:
@@ -1,228 +0,0 @@
|
||||
using JdeScoping.DataAccess.Options;
|
||||
using JdeScoping.DataAccess.Exceptions;
|
||||
using JdeScoping.DataAccess.Interfaces;
|
||||
using JdeScoping.DataAccess.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NSubstitute;
|
||||
using NSubstitute.ExceptionExtensions;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
namespace JdeScoping.DataAccess.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Unit tests for CmsRepository.
|
||||
/// </summary>
|
||||
public class CmsRepositoryTests
|
||||
{
|
||||
private readonly IDbConnectionFactory _connectionFactory;
|
||||
private readonly ILogger<CmsRepository> _logger;
|
||||
private readonly IOptions<DataAccessOptions> _options;
|
||||
|
||||
public CmsRepositoryTests()
|
||||
{
|
||||
_connectionFactory = Substitute.For<IDbConnectionFactory>();
|
||||
_logger = Substitute.For<ILogger<CmsRepository>>();
|
||||
_options = Microsoft.Extensions.Options.Options.Create(new DataAccessOptions
|
||||
{
|
||||
DefaultTimeoutSeconds = 30,
|
||||
MisDataTimeoutSeconds = 60000
|
||||
});
|
||||
}
|
||||
|
||||
#region Constructor Tests
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullConnectionFactory_ThrowsArgumentNullException()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(
|
||||
() => new CmsRepository(null!, _logger, _options))
|
||||
.ParamName.ShouldBe("connectionFactory");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullLogger_ThrowsArgumentNullException()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(
|
||||
() => new CmsRepository(_connectionFactory, null!, _options))
|
||||
.ParamName.ShouldBe("logger");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullOptions_ThrowsArgumentNullException()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(
|
||||
() => new CmsRepository(_connectionFactory, _logger, null!))
|
||||
.ParamName.ShouldBe("options");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ValidParameters_CreatesInstance()
|
||||
{
|
||||
// Act
|
||||
var repository = new CmsRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Assert
|
||||
repository.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetMisDataAsync Tests
|
||||
|
||||
[Fact]
|
||||
public async Task GetMisDataAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateCmsConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "CMS"));
|
||||
|
||||
var repository = new CmsRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetMisDataAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
ex.DataSource.ShouldBe("CMS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetMisDataAsync_UsesCmsConnection()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateCmsConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "CMS"));
|
||||
|
||||
var repository = new CmsRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act
|
||||
try
|
||||
{
|
||||
await foreach (var _ in repository.GetMisDataAsync())
|
||||
{
|
||||
}
|
||||
}
|
||||
catch (ConnectionException)
|
||||
{
|
||||
// Expected
|
||||
}
|
||||
|
||||
// Assert - verify correct connection factory method was called
|
||||
await _connectionFactory.Received(1).CreateCmsConnectionAsync(Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cancellation Tests
|
||||
|
||||
[Fact]
|
||||
public async Task GetMisDataAsync_CancellationRequested_ThrowsOperationCanceledException()
|
||||
{
|
||||
// Arrange
|
||||
using var cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
|
||||
_connectionFactory.CreateCmsConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new OperationCanceledException(cts.Token));
|
||||
|
||||
var repository = new CmsRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<OperationCanceledException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetMisDataAsync(ct: cts.Token))
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Incremental Sync Tests
|
||||
|
||||
[Fact]
|
||||
public async Task GetMisDataAsync_WithLastUpdateDT_UsesFilteredQuery()
|
||||
{
|
||||
// Arrange
|
||||
var lastUpdate = new DateTime(2024, 1, 15, 10, 30, 0);
|
||||
_connectionFactory.CreateCmsConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "CMS"));
|
||||
|
||||
var repository = new CmsRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert - this just verifies the method accepts the parameter
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetMisDataAsync(lastUpdate))
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetMisDataAsync_WithoutLastUpdateDT_UsesFullQuery()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateCmsConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "CMS"));
|
||||
|
||||
var repository = new CmsRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetMisDataAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Timeout Configuration Tests
|
||||
|
||||
[Fact]
|
||||
public void Constructor_UsesMisDataTimeout()
|
||||
{
|
||||
// Arrange
|
||||
var customOptions = Microsoft.Extensions.Options.Options.Create(new DataAccessOptions
|
||||
{
|
||||
MisDataTimeoutSeconds = 999999
|
||||
});
|
||||
|
||||
// Act
|
||||
var repository = new CmsRepository(_connectionFactory, _logger, customOptions);
|
||||
|
||||
// Assert
|
||||
repository.ShouldNotBeNull();
|
||||
// The timeout value is internal, verified through behavior
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_DefaultMisDataTimeout_Is60000Seconds()
|
||||
{
|
||||
// Arrange
|
||||
var defaultOptions = Microsoft.Extensions.Options.Options.Create(new DataAccessOptions());
|
||||
|
||||
// Act
|
||||
var repository = new CmsRepository(_connectionFactory, _logger, defaultOptions);
|
||||
|
||||
// Assert
|
||||
repository.ShouldNotBeNull();
|
||||
// Default timeout of 60000 seconds is verified implicitly
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,674 +0,0 @@
|
||||
using JdeScoping.DataAccess.Options;
|
||||
using JdeScoping.DataAccess.Exceptions;
|
||||
using JdeScoping.DataAccess.Interfaces;
|
||||
using JdeScoping.DataAccess.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NSubstitute;
|
||||
using NSubstitute.ExceptionExtensions;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
namespace JdeScoping.DataAccess.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Unit tests for JdeRepository.
|
||||
/// </summary>
|
||||
public class JdeRepositoryTests
|
||||
{
|
||||
private readonly IDbConnectionFactory _connectionFactory;
|
||||
private readonly ILogger<JdeRepository> _logger;
|
||||
private readonly IOptions<DataAccessOptions> _options;
|
||||
|
||||
public JdeRepositoryTests()
|
||||
{
|
||||
_connectionFactory = Substitute.For<IDbConnectionFactory>();
|
||||
_logger = Substitute.For<ILogger<JdeRepository>>();
|
||||
_options = Microsoft.Extensions.Options.Options.Create(new DataAccessOptions
|
||||
{
|
||||
DefaultTimeoutSeconds = 30,
|
||||
LotUsageTimeoutSeconds = 60,
|
||||
ProductionSchema = "PRODDTA",
|
||||
ArchiveSchema = "ARCDTAPD",
|
||||
StageSchema = "JDESTAGE"
|
||||
});
|
||||
}
|
||||
|
||||
#region Constructor Tests
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullConnectionFactory_ThrowsArgumentNullException()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(
|
||||
() => new JdeRepository(null!, _logger, _options))
|
||||
.ParamName.ShouldBe("connectionFactory");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullLogger_ThrowsArgumentNullException()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(
|
||||
() => new JdeRepository(_connectionFactory, null!, _options))
|
||||
.ParamName.ShouldBe("logger");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullOptions_ThrowsArgumentNullException()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(
|
||||
() => new JdeRepository(_connectionFactory, _logger, null!))
|
||||
.ParamName.ShouldBe("options");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ValidParameters_CreatesInstance()
|
||||
{
|
||||
// Act
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Assert
|
||||
repository.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Schema Replacement Tests - Work Orders
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrdersAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrdersAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
ex.DataSource.ShouldBe("JDE");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrdersArchiveAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrdersArchiveAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
ex.DataSource.ShouldBe("JDE");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Schema Replacement Tests - Work Order Steps
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrderStepsAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrderStepsAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
ex.DataSource.ShouldBe("JDE");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrderStepsArchiveAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrderStepsArchiveAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Schema Replacement Tests - Work Order Times
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrderTimesAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrderTimesAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrderTimesArchiveAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrderTimesArchiveAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Schema Replacement Tests - Work Order Routings
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrderRoutingsAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrderRoutingsAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Schema Replacement Tests - Work Order Components
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrderComponentsAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrderComponentsAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrderComponentsArchiveAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrderComponentsArchiveAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Schema Replacement Tests - Lots
|
||||
|
||||
[Fact]
|
||||
public async Task GetLotsAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetLotsAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Schema Replacement Tests - Lot Usages
|
||||
|
||||
[Fact]
|
||||
public async Task GetLotUsagesAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetLotUsagesAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetLotUsagesArchiveAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetLotUsagesArchiveAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JDE Stage Connection Tests - Lot Locations
|
||||
|
||||
[Fact]
|
||||
public async Task GetLotLocationsAsync_UsesJdeStageConnection()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeStageConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDEStage"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert - verify it uses Stage connection
|
||||
var ex = await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetLotLocationsAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
ex.DataSource.ShouldBe("JDEStage");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Reference Data Tests
|
||||
|
||||
[Fact]
|
||||
public async Task GetItemsAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetItemsAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetUsersAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetUsersAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetBranchesAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetBranchesAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetProfitCentersAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetProfitCentersAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkCentersAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkCentersAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetStatusCodesAsync_UsesJdeStageConnection()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeStageConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDEStage"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert - verify it uses Stage connection
|
||||
var ex = await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetStatusCodesAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
ex.DataSource.ShouldBe("JDEStage");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetFunctionCodesAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetFunctionCodesAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetOrgHierarchyAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetOrgHierarchyAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetRouteMastersAsync_ConnectionFails_ThrowsConnectionException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetRouteMastersAsync())
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cancellation Tests
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrdersAsync_CancellationRequested_ThrowsOperationCanceledException()
|
||||
{
|
||||
// Arrange
|
||||
using var cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new OperationCanceledException(cts.Token));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<OperationCanceledException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrdersAsync(ct: cts.Token))
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetLotUsagesAsync_CancellationRequested_ThrowsOperationCanceledException()
|
||||
{
|
||||
// Arrange
|
||||
using var cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new OperationCanceledException(cts.Token));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<OperationCanceledException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetLotUsagesAsync(ct: cts.Token))
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Incremental Sync Tests
|
||||
|
||||
[Fact]
|
||||
public async Task GetWorkOrdersAsync_WithLastUpdateDT_UsesFilteredQuery()
|
||||
{
|
||||
// Arrange
|
||||
var lastUpdate = new DateTime(2024, 1, 15, 10, 30, 0);
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert - this just verifies the method accepts the parameter
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetWorkOrdersAsync(lastUpdate))
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetLotsAsync_WithLastUpdateDT_UsesFilteredQuery()
|
||||
{
|
||||
// Arrange
|
||||
var lastUpdate = new DateTime(2024, 1, 15, 10, 30, 0);
|
||||
_connectionFactory.CreateJdeConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "JDE"));
|
||||
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
await Should.ThrowAsync<ConnectionException>(
|
||||
async () =>
|
||||
{
|
||||
await foreach (var _ in repository.GetLotsAsync(lastUpdate))
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Options Configuration Tests
|
||||
|
||||
[Fact]
|
||||
public void Constructor_UsesConfiguredSchemas()
|
||||
{
|
||||
// Arrange
|
||||
var customOptions = Microsoft.Extensions.Options.Options.Create(new DataAccessOptions
|
||||
{
|
||||
ProductionSchema = "CUSTOM_PROD",
|
||||
ArchiveSchema = "CUSTOM_ARC",
|
||||
StageSchema = "CUSTOM_STG"
|
||||
});
|
||||
|
||||
// Act
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, customOptions);
|
||||
|
||||
// Assert
|
||||
repository.ShouldNotBeNull();
|
||||
// The schema values are internal, verified through integration tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_UsesConfiguredTimeouts()
|
||||
{
|
||||
// Arrange
|
||||
var customOptions = Microsoft.Extensions.Options.Options.Create(new DataAccessOptions
|
||||
{
|
||||
DefaultTimeoutSeconds = 120,
|
||||
LotUsageTimeoutSeconds = 999999
|
||||
});
|
||||
|
||||
// Act
|
||||
var repository = new JdeRepository(_connectionFactory, _logger, customOptions);
|
||||
|
||||
// Assert
|
||||
repository.ShouldNotBeNull();
|
||||
// The timeout values are internal, verified through integration tests
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
using JdeScoping.Core.Models;
|
||||
using JdeScoping.Core.Models.Enums;
|
||||
using JdeScoping.Core.Models.Inventory;
|
||||
using JdeScoping.Core.Models.Search;
|
||||
using JdeScoping.Core.ViewModels;
|
||||
using JdeScoping.DataAccess.Options;
|
||||
@@ -31,8 +28,7 @@ public class LotFinderRepositoryTests
|
||||
_logger = Substitute.For<ILogger<LotFinderRepository>>();
|
||||
_options = Microsoft.Extensions.Options.Options.Create(new DataAccessOptions
|
||||
{
|
||||
DefaultTimeoutSeconds = 30,
|
||||
RebuildIndexTimeoutSeconds = 60
|
||||
DefaultTimeoutSeconds = 30
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,160 +73,6 @@ public class LotFinderRepositoryTests
|
||||
|
||||
#endregion
|
||||
|
||||
#region RebuildIndicesAsync - Table Name Validation Tests
|
||||
|
||||
[Theory]
|
||||
[InlineData("Branch")]
|
||||
[InlineData("DataUpdate")]
|
||||
[InlineData("FunctionCode")]
|
||||
[InlineData("Item")]
|
||||
[InlineData("JdeUser")]
|
||||
[InlineData("Lot")]
|
||||
[InlineData("LotLocation")]
|
||||
[InlineData("LotUsage_Curr")]
|
||||
[InlineData("LotUsage_Hist")]
|
||||
[InlineData("MisData")]
|
||||
[InlineData("OrgHierarchy")]
|
||||
[InlineData("ProfitCenter")]
|
||||
[InlineData("RouteMaster")]
|
||||
[InlineData("Search")]
|
||||
[InlineData("StatusCode")]
|
||||
[InlineData("WorkCenter")]
|
||||
[InlineData("WorkOrder_Curr")]
|
||||
[InlineData("WorkOrder_Hist")]
|
||||
[InlineData("WorkOrderComponent_Curr")]
|
||||
[InlineData("WorkOrderComponent_Hist")]
|
||||
[InlineData("WorkOrderRouting")]
|
||||
[InlineData("WorkOrderStep_Curr")]
|
||||
[InlineData("WorkOrderStep_Hist")]
|
||||
[InlineData("WorkOrderTime_Curr")]
|
||||
[InlineData("WorkOrderTime_Hist")]
|
||||
public async Task RebuildIndicesAsync_ValidTableName_DoesNotThrowArgumentException(string tableName)
|
||||
{
|
||||
// Arrange - expect connection exception since we have no real connection
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert - should throw QueryException (wrapped ConnectionException), not ArgumentException
|
||||
var ex = await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.RebuildIndicesAsync(tableName));
|
||||
|
||||
ex.QueryName.ShouldBe("SQL_REBUILD_INDICES");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("InvalidTable")]
|
||||
[InlineData("DropTable")]
|
||||
[InlineData("Users")]
|
||||
[InlineData("sys.tables")]
|
||||
[InlineData("'; DROP TABLE Users; --")]
|
||||
[InlineData("WorkOrder")]
|
||||
[InlineData("branch")] // Case-insensitive should still work
|
||||
public async Task RebuildIndicesAsync_InvalidTableName_ThrowsArgumentException(string tableName)
|
||||
{
|
||||
// Arrange
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
// Note: "branch" is case-insensitive match for "Branch", so it should NOT throw
|
||||
if (tableName.Equals("branch", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Case-insensitive match - will try to connect and throw QueryException
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection", "LotFinderDB"));
|
||||
|
||||
await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.RebuildIndicesAsync(tableName));
|
||||
}
|
||||
else
|
||||
{
|
||||
var ex = await Should.ThrowAsync<ArgumentException>(
|
||||
async () => await repository.RebuildIndicesAsync(tableName));
|
||||
|
||||
ex.ParamName.ShouldBe("tableName");
|
||||
ex.Message.ShouldContain($"Invalid table name: {tableName}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TruncateTableAsync - Table Name Validation Tests
|
||||
|
||||
[Theory]
|
||||
[InlineData("Branch")]
|
||||
[InlineData("Item")]
|
||||
[InlineData("WorkOrder_Curr")]
|
||||
public async Task TruncateTableAsync_ValidTableName_DoesNotThrowArgumentException(string tableName)
|
||||
{
|
||||
// Arrange - expect connection exception since we have no real connection
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert - should throw QueryException (wrapped ConnectionException), not ArgumentException
|
||||
await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.TruncateTableAsync(tableName));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("InvalidTable")]
|
||||
[InlineData("'; DELETE FROM Users; --")]
|
||||
public async Task TruncateTableAsync_InvalidTableName_ThrowsArgumentException(string tableName)
|
||||
{
|
||||
// Arrange
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<ArgumentException>(
|
||||
async () => await repository.TruncateTableAsync(tableName));
|
||||
|
||||
ex.ParamName.ShouldBe("tableName");
|
||||
ex.Message.ShouldContain($"Invalid table name: {tableName}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BulkInsertAsync - Table Name Validation Tests
|
||||
|
||||
[Theory]
|
||||
[InlineData("Branch")]
|
||||
[InlineData("Item")]
|
||||
public async Task BulkInsertAsync_ValidTableName_DoesNotThrowArgumentException(string tableName)
|
||||
{
|
||||
// Arrange - expect connection exception since we have no real connection
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
var records = new List<Item>();
|
||||
|
||||
// Act & Assert - should throw QueryException (wrapped ConnectionException), not ArgumentException
|
||||
await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.BulkInsertAsync(tableName, records));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("InvalidTable")]
|
||||
[InlineData("'; TRUNCATE TABLE Users; --")]
|
||||
public async Task BulkInsertAsync_InvalidTableName_ThrowsArgumentException(string tableName)
|
||||
{
|
||||
// Arrange
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
var records = new List<Item>();
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<ArgumentException>(
|
||||
async () => await repository.BulkInsertAsync(tableName, records));
|
||||
|
||||
ex.ParamName.ShouldBe("tableName");
|
||||
ex.Message.ShouldContain($"Invalid table name: {tableName}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Connection Exception Handling Tests
|
||||
|
||||
[Fact]
|
||||
@@ -315,38 +157,6 @@ public class LotFinderRepositoryTests
|
||||
ex.QueryName.ShouldBe(SqlObjects.SubmitSearch);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateSearchStatusAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.UpdateSearchStatusAsync(1, SearchStatus.Running));
|
||||
|
||||
ex.QueryName.ShouldBe("SQL_UPDATE_SEARCH_STATUS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateSearchResultsAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.UpdateSearchResultsAsync(1, [1, 2, 3]));
|
||||
|
||||
ex.QueryName.ShouldBe("SQL_UPDATE_SEARCH_RESULTS");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Reference Data Lookup Exception Handling Tests
|
||||
@@ -415,22 +225,6 @@ public class LotFinderRepositoryTests
|
||||
ex.QueryName.ShouldBe("SQL_SEARCH_WORK_CENTERS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LookupWorkCentersAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.LookupWorkCentersAsync(["WC01"]));
|
||||
|
||||
ex.QueryName.ShouldBe("SQL_LOOKUP_WORK_CENTERS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SearchProfitCentersAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
@@ -447,22 +241,6 @@ public class LotFinderRepositoryTests
|
||||
ex.QueryName.ShouldBe("SQL_SEARCH_PROFIT_CENTERS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LookupProfitCentersAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.LookupProfitCentersAsync(["PC01"]));
|
||||
|
||||
ex.QueryName.ShouldBe("SQL_LOOKUP_PROFIT_CENTERS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SearchUsersAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
@@ -479,22 +257,6 @@ public class LotFinderRepositoryTests
|
||||
ex.QueryName.ShouldBe("SQL_SEARCH_USERS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LookupUsersAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.LookupUsersAsync(["USER01"]));
|
||||
|
||||
ex.QueryName.ShouldBe("SQL_LOOKUP_USERS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LookupLotsAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
@@ -532,38 +294,6 @@ public class LotFinderRepositoryTests
|
||||
ex.QueryName.ShouldBe("SQL_GET_LAST_DATA_UPDATES");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetTableSpecAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.GetTableSpecAsync("Item"));
|
||||
|
||||
ex.QueryName.ShouldBe("SQL_GET_TABLE_COLUMNS");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostProcessMisDataAsync_ConnectionFails_ThrowsQueryException()
|
||||
{
|
||||
// Arrange
|
||||
_connectionFactory.CreateLotFinderConnectionAsync(Arg.Any<CancellationToken>())
|
||||
.ThrowsAsync(new ConnectionException("Test connection error", "LotFinderDB"));
|
||||
|
||||
var repository = new LotFinderRepository(_connectionFactory, _logger, _options);
|
||||
|
||||
// Act & Assert
|
||||
var ex = await Should.ThrowAsync<QueryException>(
|
||||
async () => await repository.PostProcessMisDataAsync());
|
||||
|
||||
ex.QueryName.ShouldBe("SQL_POSTPROCESS_MISDATA");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cancellation Tests
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using JdeScoping.DataAccess.Models.Results;
|
||||
using JdeScoping.Core.Models.SearchResults;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user