Table of Contents

Class MockedResponseContent

Namespace
Fluxzy.Clients.Mock
Assembly
Fluxzy.Core.dll

Represents a mocked response content.

public class MockedResponseContent : PreMadeResponse
Inheritance
MockedResponseContent
Inherited Members

Constructors

MockedResponseContent(int, BodyContent)

public MockedResponseContent(int statusCode, BodyContent body)

Parameters

statusCode int
body BodyContent

Properties

Body

public BodyContent? Body { get; set; }

Property Value

BodyContent

Headers

[JsonInclude]
public List<MockedResponseHeader> Headers { get; set; }

Property Value

List<MockedResponseHeader>

StatusCode

public int StatusCode { get; set; }

Property Value

int

Methods

CreateEmptyWithStatusCode(int)

Creates a mocked response content with the specified status code.

public static MockedResponseContent CreateEmptyWithStatusCode(int statusCode)

Parameters

statusCode int

The status code of the mocked response content.

Returns

MockedResponseContent

A mocked response content object with the specified status code.

CreateFromByteArray(byte[], int, string)

Creates a MockedResponseContent object from a byte array.

public static MockedResponseContent CreateFromByteArray(byte[] data, int statusCode = 200, string contentType = "application/octet-stream")

Parameters

data byte[]

The data to be included in the response body.

statusCode int

The status code of the response (optional, default is 200).

contentType string

The content type of the response (optional, default is "application/octet-stream").

Returns

MockedResponseContent

A new instance of MockedResponseContent with the specified data, status code, and content type.

Exceptions

ArgumentNullException

Thrown when the data parameter is null.

ArgumentOutOfRangeException

Thrown when the statusCode parameter is less than 100 or greater than 599.

CreateFromFile(string, int, string?)

Create a body content from a file, if contentType is null, it will be inferred from the file extension

public static MockedResponseContent CreateFromFile(string fileName, int statusCode = 200, string? contentType = null)

Parameters

fileName string
statusCode int
contentType string

Returns

MockedResponseContent

Exceptions

ArgumentNullException
ArgumentException

CreateFromHtmlContent(string, int, string)

Creates a mocked response content from HTML content.

public static MockedResponseContent CreateFromHtmlContent(string htmlContent, int statusCode = 200, string contentType = "text/html")

Parameters

htmlContent string

The HTML content of the response.

statusCode int

The status code of the response (default is 200).

contentType string

The content type of the response (default is "text/html").

Returns

MockedResponseContent

A mocked response content object.

CreateFromHtmlFile(string, int, string)

Creates a MockedResponseContent object by reading the contents of an HTML file.

public static MockedResponseContent CreateFromHtmlFile(string fileName, int statusCode = 200, string contentType = "text/html")

Parameters

fileName string

The path to the HTML file to be read.

statusCode int

The HTTP status code to be associated with the mocked response. Default value is 200.

contentType string

The content-type of the mocked response. Default value is "text/html".

Returns

MockedResponseContent

A MockedResponseContent object representing the contents of the HTML file.

CreateFromJsonContent(string, int, string)

Creates a mocked response content object from a JSON content string.

public static MockedResponseContent CreateFromJsonContent(string jsonContent, int statusCode = 200, string contentType = "application/json")

Parameters

jsonContent string

The JSON content string to be used.

statusCode int

The status code of the response (default is 200).

contentType string

The content type of the response (default is "application/json").

Returns

MockedResponseContent

A MockedResponseContent object created from the provided JSON content.

CreateFromJsonFile(string, int, string)

Creates a mocked response content from a JSON file.

public static MockedResponseContent CreateFromJsonFile(string fileName, int statusCode = 200, string contentType = "application/json")

Parameters

fileName string

The name of the JSON file.

statusCode int

The status code of the response content (default is 200).

contentType string

The content type of the response content (default is "application/json").

Returns

MockedResponseContent

A mocked response content object.

CreateFromPlainText(string, int, string)

Creates a mocked response content object from plain text.

public static MockedResponseContent CreateFromPlainText(string text, int statusCode = 200, string contentType = "text/plain")

Parameters

text string

The text content.

statusCode int

The HTTP status code of the mocked response content. Default value is 200.

contentType string

The content type of the mocked response content. Default value is "text/plain".

Returns

MockedResponseContent

A MockedResponseContent object representing the mocked response content.

CreateFromPlainTextFile(string, int, string)

Creates a MockedResponseContent object from a plain text file.

public static MockedResponseContent CreateFromPlainTextFile(string fileName, int statusCode = 200, string contentType = "text/plain")

Parameters

fileName string

The name of the plain text file.

statusCode int

The status code of the response. Defaults to 200.

contentType string

The content type of the response. Defaults to "text/plain".

Returns

MockedResponseContent

A MockedResponseContent object.

CreateFromString(string, int, string)

Creates a new instance of the MockedResponseContent class with the specified text, status code, and content type.

public static MockedResponseContent CreateFromString(string text, int statusCode, string contentType)

Parameters

text string

The content of the response as a string.

statusCode int

The HTTP status code to be returned.

contentType string

The MIME type of the content.

Returns

MockedResponseContent

A new instance of the MockedResponseContent class with the specified parameters.

Exceptions

ArgumentNullException

Thrown when the 'text' parameter is null.

ArgumentOutOfRangeException

Thrown when the 'statusCode' parameter is not within the range of 100 to 599.

CreateFromXmlContent(string, int, string)

Creates a MockedResponseContent object from XML content.

public static MockedResponseContent CreateFromXmlContent(string xmlContent, int statusCode = 200, string contentType = "text/xml")

Parameters

xmlContent string

The XML content to be used in the response.

statusCode int

The HTTP status code for the response. Default value is 200.

contentType string

The content type for the response. Default value is "text/xml".

Returns

MockedResponseContent

A MockedResponseContent object representing the response.

CreateFromXmlFile(string, int, string)

Creates a MockedResponseContent object from an XML file.

public static MockedResponseContent CreateFromXmlFile(string fileName, int statusCode = 200, string contentType = "text/xml")

Parameters

fileName string

The path of the XML file.

statusCode int

The status code of the mock response. Default is 200.

contentType string

The content type of the mock response. Default is 'text/xml'.

Returns

MockedResponseContent

A MockedResponseContent object representing the XML file content.

GetFlatH11Header(Authority, ExchangeContext?)

public override string GetFlatH11Header(Authority authority, ExchangeContext? exchangeContext)

Parameters

authority Authority
exchangeContext ExchangeContext

Returns

string

ReadBody(Authority)

public override Stream ReadBody(Authority authority)

Parameters

authority Authority

Returns

Stream