- Added ComplianceNFs.Infrastructure.Tests project to the solution. - Implemented unit tests for AccessDbRepository, ArchivingService, AttachmentRepository, InvoiceIngestionService, MailListener, MonitorViewModel, and Worker. - Enhanced existing tests with additional assertions and mock setups. - Updated TODOs and roadmap documentation to reflect changes in service implementations and testing coverage. - Modified ComplianceNFs.sln to include new test project and adjust solution properties.
47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using ComplianceNFs.Service;
|
|
using ComplianceNFs.Core.Application;
|
|
using ComplianceNFs.Core.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
using Moq;
|
|
using Xunit;
|
|
|
|
namespace ComplianceNFs.Infrastructure.Tests
|
|
{
|
|
public class WorkerTests
|
|
{
|
|
[Fact]
|
|
public async Task ExecuteAsync_StartsIngestionAndOrchestratesWorkflow()
|
|
{
|
|
// Arrange
|
|
var loggerMock = new Mock<ILogger<Worker>>();
|
|
var ingestionMock = new Mock<IInvoiceIngestionService>();
|
|
var matchingMock = new Mock<IMatchingService>();
|
|
var complianceMock = new Mock<IComplianceService>();
|
|
var notificationMock = new Mock<INotificationService>();
|
|
var archivingMock = new Mock<IArchivingService>();
|
|
|
|
var worker = new Worker(
|
|
loggerMock.Object,
|
|
ingestionMock.Object,
|
|
matchingMock.Object,
|
|
complianceMock.Object,
|
|
notificationMock.Object,
|
|
archivingMock.Object
|
|
);
|
|
|
|
var cts = new CancellationTokenSource();
|
|
cts.CancelAfter(100); // Cancel quickly for test
|
|
|
|
// Act
|
|
var task = worker.StartAsync(cts.Token);
|
|
await Task.Delay(200); // Give it time to start
|
|
|
|
// Assert
|
|
ingestionMock.Verify(i => i.IngestAsync(), Times.Once);
|
|
}
|
|
}
|
|
}
|