FastMoq
Search Results for

    Show / Hide Table of Contents

    Class HttpResponseDataBuilder

    Builds concrete HttpResponseData instances for Azure Functions HTTP-trigger tests.

    Inheritance
    object
    HttpResponseDataBuilder
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastMoq.AzureFunctions.Http
    Assembly: FastMoq.AzureFunctions.dll
    Syntax
    public sealed class HttpResponseDataBuilder

    Constructors

    HttpResponseDataBuilder(FunctionContext)

    Initializes a new HttpResponseDataBuilder instance.

    Declaration
    public HttpResponseDataBuilder(FunctionContext functionContext)
    Parameters
    Type Name Description
    FunctionContext functionContext

    The function context to associate with the response.

    Methods

    Build()

    Builds the configured HttpResponseData instance.

    Declaration
    public HttpResponseData Build()
    Returns
    Type Description
    HttpResponseData

    A concrete HttpResponseData suitable for tests.

    WithBody(Stream, string?)

    Sets the response body from an existing stream.

    Declaration
    public HttpResponseDataBuilder WithBody(Stream body, string? contentType = null)
    Parameters
    Type Name Description
    Stream body

    The body stream.

    string contentType

    An optional content-type header value.

    Returns
    Type Description
    HttpResponseDataBuilder

    The current HttpResponseDataBuilder instance.

    WithBody(string, Encoding?, string?)

    Sets the response body from a string payload.

    Declaration
    public HttpResponseDataBuilder WithBody(string body, Encoding? encoding = null, string? contentType = null)
    Parameters
    Type Name Description
    string body

    The body payload.

    Encoding encoding

    The text encoding. Defaults to UTF-8.

    string contentType

    An optional content-type header value.

    Returns
    Type Description
    HttpResponseDataBuilder

    The current HttpResponseDataBuilder instance.

    WithCookie(string, string, string?, string?, bool?, bool?)

    Adds a response cookie.

    Declaration
    public HttpResponseDataBuilder WithCookie(string name, string value, string? path = null, string? domain = null, bool? httpOnly = null, bool? secure = null)
    Parameters
    Type Name Description
    string name

    The cookie name.

    string value

    The cookie value.

    string path

    An optional cookie path.

    string domain

    An optional cookie domain.

    bool? httpOnly

    An optional HttpOnly flag.

    bool? secure

    An optional Secure flag.

    Returns
    Type Description
    HttpResponseDataBuilder

    The current HttpResponseDataBuilder instance.

    WithHeader(string, string)

    Adds a response header.

    Declaration
    public HttpResponseDataBuilder WithHeader(string name, string value)
    Parameters
    Type Name Description
    string name

    The header name.

    string value

    The header value.

    Returns
    Type Description
    HttpResponseDataBuilder

    The current HttpResponseDataBuilder instance.

    WithJsonBody<TValue>(TValue, JsonSerializerOptions?)

    Sets the response body from a JSON payload.

    Declaration
    public HttpResponseDataBuilder WithJsonBody<TValue>(TValue value, JsonSerializerOptions? jsonSerializerOptions = null)
    Parameters
    Type Name Description
    TValue value

    The payload to serialize.

    JsonSerializerOptions jsonSerializerOptions

    Optional serializer options.

    Returns
    Type Description
    HttpResponseDataBuilder

    The current HttpResponseDataBuilder instance.

    Type Parameters
    Name Description
    TValue

    The payload type.

    WithStatusCode(HttpStatusCode)

    Sets the response status code.

    Declaration
    public HttpResponseDataBuilder WithStatusCode(HttpStatusCode statusCode)
    Parameters
    Type Name Description
    HttpStatusCode statusCode

    The HTTP status code.

    Returns
    Type Description
    HttpResponseDataBuilder

    The current HttpResponseDataBuilder instance.

    Extension Methods

    ObjectExtensions.RaiseIfNull<T>(T?, string?, string?, int?, string?)
    TestClassExtensions.GetFieldValue<TObject>(TObject, string, TObject?)
    TestClassExtensions.GetField<TObject>(TObject, string)
    TestClassExtensions.GetMemberName<T, TValue>(T, Expression<Func<T, TValue>>)
    TestClassExtensions.GetMember<T, TValue>(T, Expression<Func<T, TValue>>)
    TestClassExtensions.GetMethodValue<TObject>(TObject, string, object?, params object[])
    TestClassExtensions.GetMethod<TObject>(TObject, string)
    TestClassExtensions.GetPropertyValue<TObject>(TObject, string, object?)
    TestClassExtensions.GetProperty<TObject>(TObject, string)
    TestClassExtensions.SetFieldValue<TObject>(TObject, string, object?)
    TestClassExtensions.SetPropertyValue<TObject>(TObject, string, object?)
    MockerHttpMoqExtensions.SetupHttpMessage(object, Func<HttpResponseMessage>, Expression?, Expression?)
    MockerHttpMoqExtensions.SetupMessageAsync<TMock, TReturn>(object, Expression<Func<TMock, Task<TReturn>>>, Func<TReturn>)
    MockerHttpMoqExtensions.SetupMessageProtectedAsync<TMock, TReturn>(object, string, Func<TReturn>, params object?[]?)
    MockerHttpMoqExtensions.SetupMessageProtected<TMock, TReturn>(object, string, Func<TReturn>, params object?[]?)
    MockerHttpMoqExtensions.SetupMessage<TMock, TReturn>(object, Expression<Func<TMock, TReturn>>, Func<TReturn>)
    TestClassExtensions.GetFieldInfo<TType>(object, string)
    TestClassExtensions.GetFieldValue<T>(object?, FieldInfo)
    TestClassExtensions.GetFieldValue<T, TType>(object, string)
    In this article
    Back to top
    Generated 2026-04-12 00:48 UTC