fix: test infrastructure with in-memory DB, SMTP mocking, and thread-safe billing configuration

- Add in-memory database support for test isolation in WebServerFixture
- Implement TestMailSender fake SMTP provider for email test support
- Add thread synchronization to billing service registration to prevent race conditions
- Make RegisterBilling<T> idempotent to safely handle reconfiguration
- Configure test environment via in-memory settings (UseTestEmailSender, UseInMemoryDatabase)
- Add regression tests for billing module idempotency and duplicate registration detection
- Fix tests: EMaillingTests.SendEMailSynchrone, BillingServiceTests (2 tests), HaveConfigurationRoot (3 tests)

All core test infrastructure tests now passing.
This commit is contained in:
Paul Schneider 2026-04-19 14:40:40 +01:00
commit 87d62791b8
10 changed files with 223 additions and 58 deletions

View file

@ -0,0 +1,30 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.Extensions.Logging;
using Yavsc.Interface;
namespace Yavsc.Services
{
public class TestMailSender : ITrueEmailSender, IEmailSender
{
private readonly ILogger<TestMailSender> logger;
public TestMailSender(ILoggerFactory loggerFactory)
{
logger = loggerFactory.CreateLogger<TestMailSender>();
}
public Task SendEmailAsync(string email, string subject, string htmlMessage)
{
logger.LogInformation("[TestMailSender] SendEmailAsync to {Email} subject={Subject}", email, subject);
return Task.CompletedTask;
}
public Task<string> SendEmailAsync(string name, string email, string subject, string htmlMessage)
{
logger.LogInformation("[TestMailSender] SendEmailAsync to {Email} subject={Subject} name={Name}", email, subject, name);
return Task.FromResult($"test-message-{Guid.NewGuid()}");
}
}
}