Skip to content

Latest commit

 

History

History
113 lines (91 loc) · 3.55 KB

readme.md

File metadata and controls

113 lines (91 loc) · 3.55 KB

Verify.SendGrid

Discussions Build status NuGet Status

Extends Verify to allow verification of SendGrid.

See Milestones for release notes.

NuGet package

https://nuget.org/packages/Verify.SendGrid/

Usage

[ModuleInitializer]
public static void Initialize() =>
    VerifySendGrid.Initialize();

snippet source | anchor

Attachment

[Fact]
public Task Attachment()
{
    var contentBytes = "The content"u8.ToArray();
    var attachment = new Attachment
    {
        Filename = "name.txt",
        Content = Convert.ToBase64String(contentBytes),
        Type = "text/html",
        Disposition = "attachment"
    };
    return Verify(attachment);
}

snippet source | anchor

Results in:

{
  Filename: name.txt,
  Disposition: attachment,
  Type: text/html,
  Content: The content
}

snippet source | anchor

SendGridMessage

[Fact]
public Task SendGridMessage()
{
    var mail = new SendGridMessage
    {
        From = new("test@example.com", "DX Team"),
        Subject = "Sending with Twilio SendGrid is Fun",
        PlainTextContent = "and easy to do anywhere, even with C#",
        HtmlContent = "<strong>and easy to do anywhere, even with C#</strong>"
    };
    mail.AddTo(new EmailAddress("test@example.com", "Test User"));
    return Verify(mail);
}

snippet source | anchor

Results in:

{
  From: DX Team <test@example.com>,
  Personalizations: [
    {
      To: Test User <test@example.com>
    }
  ],
  Subject: Sending with Twilio SendGrid is Fun,
  PlainTextContent: and easy to do anywhere, even with C#,
  HtmlContent: <strong>and easy to do anywhere, even with C#</strong>
}

snippet source | anchor

Icon

Grid from The Noun Project.