- 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.
30 lines
957 B
C#
30 lines
957 B
C#
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using ComplianceNFs.Core.Entities;
|
|
using ComplianceNFs.Core.Ports;
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace ComplianceNFs.Infrastructure.Archiving
|
|
{
|
|
// Moves files to archive folders by status
|
|
public class FileArchiver(string basePath) : IFileArchiver
|
|
{
|
|
private readonly string _basePath = basePath;
|
|
|
|
public async Task ArchiveAsync(EnergyInvoice invoice, byte[] rawFile)
|
|
{
|
|
// Create subfolder for invoice.Status
|
|
var statusFolder = Path.Combine(_basePath, invoice.Status.ToString());
|
|
if (!Directory.Exists(statusFolder))
|
|
{
|
|
Directory.CreateDirectory(statusFolder);
|
|
}
|
|
// Build file path
|
|
var filePath = Path.Combine(statusFolder, invoice.Filename);
|
|
// Write file (overwrite if exists)
|
|
await File.WriteAllBytesAsync(filePath, rawFile);
|
|
}
|
|
}
|
|
}
|