- 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.
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using ComplianceNFs.Infrastructure.Repositories;
|
|
using ComplianceNFs.Core.Entities;
|
|
using ComplianceNFs.Core.Ports;
|
|
using Xunit;
|
|
using Moq;
|
|
|
|
namespace ComplianceNFs.Infrastructure.Tests
|
|
{
|
|
public class AccessDbRepositoryTests
|
|
{
|
|
[Fact]
|
|
public void GetByCnpj_ReturnsExpectedRecords()
|
|
{
|
|
// Arrange
|
|
var expected = new List<BuyingRecord> {
|
|
new BuyingRecord { CodTE = 180310221018240701, CnpjComp = "06272575007403", CnpjVend = "13777004000122", MontLO = 24.72m, PrecLO = 147.29m }
|
|
};
|
|
var mockRepo = new Mock<IAccessDbRepository>();
|
|
mockRepo.Setup(r => r.GetByCnpj("06272575007403")).Returns(expected);
|
|
// Act
|
|
var result = mockRepo.Object.GetByCnpj("06272575007403");
|
|
// Assert
|
|
Assert.NotNull(result);
|
|
Assert.Equal("06272575007403", result.First().CnpjComp);
|
|
Assert.Equal("13777004000122", result.First().CnpjVend);
|
|
Assert.Equal(24.72m, result.First().MontLO);
|
|
Assert.Equal(147.29m, result.First().PrecLO);
|
|
}
|
|
}
|
|
}
|