-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: Headers in SendEmail don't overwrite default headers any…
…more; added ReplyTo
- Loading branch information
1 parent
77ff217
commit cdeddf3
Showing
5 changed files
with
51 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,25 +148,40 @@ public async Task SendEmail_DefaultHeadersAdded() | |
} | ||
|
||
[Fact] | ||
public async Task SendEmail_DefaultHeadersOverridden() | ||
public async Task SendEmail_DefaultHeadersOverriddenIfSetTwice() | ||
{ | ||
Fixture.SmtpServer!.ClearReceivedEmail(); | ||
|
||
var options = GetInstance<EmailOptions>(); | ||
|
||
options.DefaultHeaders = new Dictionary<string, string> { ["my-header"] = "value" }; | ||
options.DefaultHeaders = new Dictionary<string, string> { ["replaced"] = "value", ["default"] = "value" }; | ||
|
||
var model = new SendEmailTestEmailViewModel { SomeField = "Some field." }; | ||
await SendAsync(new SendEmail("[email protected]", "The Recipient", new CultureInfo("de-AT"), model, Headers: new Dictionary<string, string> { ["new-header"] = "new-value" })); | ||
await SendAsync(new SendEmail("[email protected]", "The Recipient", new CultureInfo("de-AT"), model, Headers: new Dictionary<string, string> { ["replaced"] = "new-value" })); | ||
|
||
Fixture.SmtpServer.ReceivedEmailCount.Should().Be(1); | ||
var email = Fixture.SmtpServer.ReceivedEmail.Single(); | ||
|
||
email.Headers.AllKeys.Should().NotContain("my-header"); | ||
email.Headers.AllKeys.Should().Contain("new-header"); | ||
email.Headers["new-header"].Should().Be("new-value"); | ||
email.Headers.AllKeys.Should().Contain("replaced"); | ||
email.Headers["replaced"].Should().Be("new-value"); | ||
email.Headers.AllKeys.Should().Contain("default"); | ||
email.Headers["default"].Should().Be("value"); | ||
} | ||
|
||
[Fact] | ||
public async Task SendEmail_ReplyToAdded() | ||
{ | ||
Fixture.SmtpServer!.ClearReceivedEmail(); | ||
|
||
var model = new SendEmailTestEmailViewModel { SomeField = "Some field." }; | ||
await SendAsync(new SendEmail("[email protected]", "The Recipient", new CultureInfo("de-AT"), model, ReplyTo: "[email protected]")); | ||
|
||
Fixture.SmtpServer.ReceivedEmailCount.Should().Be(1); | ||
var email = Fixture.SmtpServer.ReceivedEmail.Single(); | ||
|
||
email.Headers.AllKeys.Should().Contain("Reply-To"); | ||
email.Headers["Reply-To"].Should().Be("[email protected]"); | ||
} | ||
|
||
[Fact] | ||
public async Task SendEmail_InvalidBccEmailAddress_ThrowsException() | ||
|