An open API service indexing awesome lists of open source software.

https://github.com/verifytests/verify.mailmessage

Extends Verify to allow verification of MailMessage and related types.
https://github.com/verifytests/verify.mailmessage

Last synced: 8 months ago
JSON representation

Extends Verify to allow verification of MailMessage and related types.

Awesome Lists containing this project

README

          

# Verify.MailMessage

[![Discussions](https://img.shields.io/badge/Verify-Discussions-yellow?svg=true&label=)](https://github.com/orgs/VerifyTests/discussions)
[![Build status](https://ci.appveyor.com/api/projects/status/cpmnux3i0euge195?svg=true)](https://ci.appveyor.com/project/SimonCropp/verify-mailmessage)
[![NuGet Status](https://img.shields.io/nuget/v/Verify.MailMessage.svg)](https://www.nuget.org/packages/Verify.MailMessage/)

Extends [Verify](https://github.com/VerifyTests/Verify) to allow verification of [MailMessage](https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.mailmessage) and related types.

**See [Milestones](../../milestones?state=closed) for release notes.**

## Sponsors

### Entity Framework Extensions

[Entity Framework Extensions](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=Verify.MailMessage) is a major sponsor and is proud to contribute to the development this project.

[![Entity Framework Extensions](https://raw.githubusercontent.com/VerifyTests/Verify.MailMessage/refs/heads/main/docs/zzz.png)](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=Verify.MailMessage)

## NuGet

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

## Usage


```cs
[ModuleInitializer]
public static void Initialize() =>
VerifyMailMessage.Initialize();
```
snippet source | anchor

### ContentDisposition


```cs
[Fact]
public Task ContentDisposition()
{
var content = new ContentDisposition("attachment; filename=\"filename.jpg\"");
return Verify(content);
}
```
snippet source | anchor

Results in:


```txt
{
DispositionType: attachment,
FileName: filename.jpg
}
```
snippet source | anchor

### ContentType


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

Results in:


```txt
{
MediaType: text/html,
Name: name.txt,
CharSet: utf-8
}
```
snippet source | anchor

### Attachment


```cs
[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:


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

### MailMessage


```cs
[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:


```txt
{
From: from@mail.com,
To: to@mail.com,
Subject: The subject,
IsBodyHtml: false,
Body: The body
}
```
snippet source | anchor

## Icon

[Mail](https://thenounproject.com/icon/mail-5633084/) from [The Noun Project](https://thenounproject.com).