Skip to content

Extends Verify to allow verification of MailMessage and related types.

License

Notifications You must be signed in to change notification settings

VerifyTests/Verify.MailMessage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: "[email protected]",
        to: "[email protected]",
        subject: "The subject",
        body: "The body");
    return Verify(mail);
}

snippet source | anchor

Results in:

{
  From: [email protected],
  To: [email protected],
  Subject: The subject,
  IsBodyHtml: false,
  Body: The body
}

snippet source | anchor

Icon

Mail from The Noun Project.

About

Extends Verify to allow verification of MailMessage and related types.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project