- Added Microsoft.Extensions.Logging to various projects for enhanced logging capabilities. - Updated AccessDbRepository and AttachmentRepository to include logging for database operations. - Integrated logging into MailListener for better error handling and operational insights. - Modified tests to utilize mocks for ILogger to ensure logging behavior is tested. - Enhanced App.xaml.cs and MainWindow.xaml.cs to log application startup and initialization events. - Created LoggingBootstrapper to configure logging services in the WPF application. - Updated TODOs-and-Roadmap.md to reflect the addition of logging features.
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using ComplianceNFs.Infrastructure.Repositories;
|
|
using ComplianceNFs.Core.Entities;
|
|
using Xunit;
|
|
using Moq;
|
|
using Npgsql;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace ComplianceNFs.Infrastructure.Tests
|
|
{
|
|
public class AttachmentRepositoryTests
|
|
{
|
|
[Fact]
|
|
public async Task SaveRawAsync_DoesNotThrow_WithValidInvoice()
|
|
{
|
|
// Arrange
|
|
var mockLogger = new Mock<ILogger<AttachmentRepository>>();
|
|
var repo = new AttachmentRepository("Host=localhost;Port=5432;Database=test;Username=test;Password=test", mockLogger.Object);
|
|
var invoice = new EnergyInvoice
|
|
{
|
|
MailId = "mailid",
|
|
ConversationId = "convid",
|
|
SupplierEmail = "test@supplier.com",
|
|
ReceivedDate = DateTime.Now,
|
|
InvoiceId = 1,
|
|
Filename = "file.xml",
|
|
Status = InvoiceStatus.Validated
|
|
};
|
|
// This is a placeholder: in a real test, use a test DB or mock NpgsqlConnection/Command
|
|
// For demonstration, we'll just check that the method can be called without throwing
|
|
await Assert.ThrowsAnyAsync<Exception>(async () => await repo.SaveRawAsync(invoice));
|
|
}
|
|
}
|
|
}
|