Table of Contents

Method AddAttachment

Namespace
Xunit
Assembly
xunit.v3.core.dll

AddAttachment(string, string)

Adds an attachment that is a string value.

void AddAttachment(string name, string value)

Parameters

name string

The name of the attachment

value string

The value of the attachment

AddAttachment(string, string, bool)

Adds an attachment that is a string value.

void AddAttachment(string name, string value, bool replaceExistingValue)

Parameters

name string

The name of the attachment

value string

The value of the attachment

replaceExistingValue bool

Set to true to allow an existing value to be replaced; set to false to throw an exception if an existing value already exists.

AddAttachment(string, byte[], string)

Adds an attachment that is a binary value (represented by a byte array and media type).

void AddAttachment(string name, byte[] value, string mediaType = "application/octet-stream")

Parameters

name string

The name of the attachment

value byte[]

The value of the attachment

mediaType string

The media type of the attachment; defaults to "application/octet-stream"

Remarks

The mediaType value must be in the MIME "type/subtype" form, and does not support parameter values. The subtype is allowed to have a single "+" to denote specialization of the subtype (i.e., "application/xhtml+xml"). For more information on media types, see https://datatracker.ietf.org/doc/html/rfc2045#section-5.1.

AddAttachment(string, byte[], bool, string)

Adds an attachment that is a binary value (represented by a byte array and media type).

void AddAttachment(string name, byte[] value, bool replaceExistingValue, string mediaType = "application/octet-stream")

Parameters

name string

The name of the attachment

value byte[]

The value of the attachment

replaceExistingValue bool

Set to true to allow an existing value to be replaced; set to false to throw an exception if an existing value already exists.

mediaType string

The media type of the attachment; defaults to "application/octet-stream"

Remarks

The mediaType value must be in the MIME "type/subtype" form, and does not support parameter values. The subtype is allowed to have a single "+" to denote specialization of the subtype (i.e., "application/xhtml+xml"). For more information on media types, see https://datatracker.ietf.org/doc/html/rfc2045#section-5.1.