Introduce Yavsc.Interfaces.ISmtpClient and a recording test fake
Narrow ISmtpClient to the four operations MailSender actually uses, behind a Yavsc.Interfaces.ISmtpClientFactory. Production wires MailKitSmtpClient (SmtpClientFactory); tests wire a recording fake (RecordingSmtpClientFactory). The fake is pre-registered in WebServerFixture so SMTP calls are short-circuited; the EMailling test now asserts the Connect -> Authenticate -> Send -> Disconnect sequence. Yavsc.Abstract stays free of MailKit/MimeKit.
This commit is contained in:
parent
16508e9fb2
commit
2dec799d71
13 changed files with 264 additions and 10 deletions
14
src/Yavsc.Server/Services/SmtpClientFactory.cs
Normal file
14
src/Yavsc.Server/Services/SmtpClientFactory.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using Yavsc.Interfaces;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Production <see cref="ISmtpClientFactory"/>: hands out a
|
||||
/// fresh <see cref="MailKitSmtpClient"/> per call. Stateless;
|
||||
/// safe to register as a singleton.
|
||||
/// </summary>
|
||||
public sealed class SmtpClientFactory : ISmtpClientFactory
|
||||
{
|
||||
public ISmtpClient CreateClient() => new MailKitSmtpClient();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue