Refactor EmailSender to use new Email abstraction
Introduced a new `Email` record to simplify the representation of outgoing email messages. Updated the `EmailSender.Send` method to accept `Email` instead of `OutgoingEmailEvent`, with a `ToEvent()` method handling the conversion internally. Refactored test cases to use the `Email` record, removing redundant properties (`Id` and `QueuedAt`) that are now auto-generated. Updated XML documentation to reflect these changes. Adjusted namespaces and added necessary `using` directives for proper referencing. These changes improve code readability, maintainability, and centralize the mapping logic for outgoing email events.
This commit is contained in:
@@ -75,14 +75,12 @@ public sealed class EmailSenderTests
|
||||
[Fact]
|
||||
public void Send_WithValidEmail_DoesNotThrow()
|
||||
{
|
||||
var email = new OutgoingEmailEvent
|
||||
var email = new Email
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Recipient = "hakanttek@gmail.com",
|
||||
Subject = "EmailSender.Send Integration Test",
|
||||
Body = "<p>Sent via EmailSender static client.</p>",
|
||||
IsHtml = true,
|
||||
QueuedAt = DateTime.Now
|
||||
};
|
||||
|
||||
var exception = Record.Exception(() => EmailSender.Send(email));
|
||||
@@ -93,14 +91,12 @@ public sealed class EmailSenderTests
|
||||
[Fact]
|
||||
public void Send_WithPlainTextBody_DoesNotThrow()
|
||||
{
|
||||
var email = new OutgoingEmailEvent
|
||||
var email = new Email
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Recipient = "hakanttek@gmail.com",
|
||||
Subject = "Plain Text Test",
|
||||
Body = "This is a plain text email.",
|
||||
IsHtml = false,
|
||||
QueuedAt = DateTime.Now
|
||||
IsHtml = false
|
||||
};
|
||||
|
||||
var exception = Record.Exception(() => EmailSender.Send(email));
|
||||
|
||||
Reference in New Issue
Block a user