Contact: ontvangstadres uit de site-instellingen (instelling > env), PUT /contact-settings/recipient en Berichten-veld (CMS-U11)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,14 @@ public class ContactMailSenderTests
|
||||
public CapturingLoggerProvider Logs { get; } = new();
|
||||
public OutgoingMail? Sent;
|
||||
|
||||
private readonly ContactDbContext _db = new(new DbContextOptionsBuilder<ContactDbContext>()
|
||||
.UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
|
||||
|
||||
/// <summary>The real settings service on an in-memory database: the administrator's setting and the environment.</summary>
|
||||
public IContactSettingsService ContactSettings => new ContactSettingsService(
|
||||
new ContactRepository(_db), new ContactSettingsCache(TimeProvider.System), Options.Create(Contact),
|
||||
TimeProvider.System, Substitute.For<IContactMailSignal>());
|
||||
|
||||
public Rig()
|
||||
{
|
||||
Availability.IsEnabled.Returns(true);
|
||||
@@ -62,7 +70,7 @@ public class ContactMailSenderTests
|
||||
var settings = Substitute.For<ISiteSettingsService>();
|
||||
settings.GetEffectiveSenderAsync(Arg.Any<CancellationToken>()).Returns(("noreply@example.org", "De Site"));
|
||||
return new ContactMailSender(
|
||||
Email, new MailTemplateRenderer(), languages, settings, Availability,
|
||||
Email, new MailTemplateRenderer(), languages, settings, ContactSettings, Availability,
|
||||
Options.Create(new EmailOptions()), Options.Create(new AppMailOptions { PublicBaseUrl = "https://example.org" }),
|
||||
Options.Create(Contact), LoggerFactory.Create(b => b.AddProvider(Logs)).CreateLogger<ContactMailSender>());
|
||||
}
|
||||
@@ -179,7 +187,7 @@ public class ContactMailSenderTests
|
||||
var result = await sut.SendAsync(Message(), CancellationToken.None);
|
||||
|
||||
result.Should().Be(new ContactMailResult(ContactMailOutcome.Skipped, "disabled"));
|
||||
sut.NotReadyReason().Should().Be("disabled");
|
||||
(await sut.NotReadyReasonAsync(CancellationToken.None)).Should().Be("disabled");
|
||||
await rig.Email.DidNotReceive().SendAsync(Arg.Any<OutgoingMail>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
@@ -212,7 +220,7 @@ public class ContactMailServiceTests : IDisposable
|
||||
|
||||
public ContactMailServiceTests()
|
||||
{
|
||||
_sender.NotReadyReason().Returns((string?)null);
|
||||
_sender.NotReadyReasonAsync(Arg.Any<CancellationToken>()).Returns((string?)null);
|
||||
_sender.SendAsync(Arg.Any<ContactMessage>(), Arg.Any<CancellationToken>()).Returns(ContactMailOutcome.Sent);
|
||||
|
||||
var services = new ServiceCollection();
|
||||
@@ -330,7 +338,7 @@ public class ContactMailServiceTests : IDisposable
|
||||
[Fact]
|
||||
public async Task WhenMailCannotBeSent_NothingIsAttemptedOrCounted_AndTheReasonIsShown()
|
||||
{
|
||||
_sender.NotReadyReason().Returns("disabled");
|
||||
_sender.NotReadyReasonAsync(Arg.Any<CancellationToken>()).Returns("disabled");
|
||||
var id = Add();
|
||||
|
||||
(await Sut().SweepAsync(CancellationToken.None)).Should().Be(0);
|
||||
@@ -342,7 +350,7 @@ public class ContactMailServiceTests : IDisposable
|
||||
await _sender.DidNotReceive().SendAsync(Arg.Any<ContactMessage>(), Arg.Any<CancellationToken>());
|
||||
|
||||
// Once mail works again the same message goes out without any lost attempts.
|
||||
_sender.NotReadyReason().Returns((string?)null);
|
||||
_sender.NotReadyReasonAsync(Arg.Any<CancellationToken>()).Returns((string?)null);
|
||||
(await Sut().SweepAsync(CancellationToken.None)).Should().Be(1);
|
||||
Get(id).MailAttempts.Should().Be(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user