Skip to content

Latest commit

 

History

History
172 lines (140 loc) · 4.93 KB

readme.md

File metadata and controls

172 lines (140 loc) · 4.93 KB

Verify.MailMessage

Discussions Build status NuGet Status

Extends Verify to allow verification of MailMessage and related types.

See Milestones for release notes.

NuGet package

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

Usage

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

snippet source | anchor

ContentDisposition

[Fact]
public Task ContentDisposition()
{
    var content = new ContentDisposition("attachment; filename=\"filename.jpg\"");
    return Verify(content);
}

snippet source | anchor

Results in:

{
  DispositionType: attachment,
  FileName: filename.jpg
}

snippet source | anchor

ContentType

[Fact]
public Task ContentType()
{
    var content = new ContentType("text/html; charset=utf-8")
    {
        Name = "name.txt"
    };
    return Verify(content);
}

snippet source | anchor

Results in:

{
  MediaType: text/html,
  Name: name.txt,
  CharSet: utf-8
}

snippet source | anchor

Attachment

[Fact]
public Task Attachment()
{
    var attachment = new Attachment(
        new MemoryStream("file content"u8.ToArray()),
        new ContentType("text/html; charset=utf-8"))
    {
        Name = "name.txt"
    };
    return Verify(attachment);
}

snippet source | anchor

Results in:

{
  Name: name.txt,
  ContentType: {
    MediaType: text/html,
    Name: name.txt,
    CharSet: utf-8
  },
  ContentId: Guid_1,
  ContentDisposition: {
    DispositionType: attachment
  }
}

snippet source | anchor

MailMessage

[Fact]
public Task MailMessage()
{
    var mail = new MailMessage(
        from: "from@mail.com",
        to: "to@mail.com",
        subject: "The subject",
        body: "The body");
    return Verify(mail);
}

snippet source | anchor

Results in:

{
  From: from@mail.com,
  To: to@mail.com,
  Subject: The subject,
  IsBodyHtml: false,
  Body: The body
}

snippet source | anchor

Icon

Mail from The Noun Project.