FastMoq
Search Results for

    Show / Hide Table of Contents

    Class HttpRequestDataBuilder

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

    Inheritance
    object
    HttpRequestDataBuilder
    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 HttpRequestDataBuilder

    Constructors

    HttpRequestDataBuilder(FunctionContext)

    Initializes a new HttpRequestDataBuilder instance.

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

    The function context to associate with the request.

    Methods

    Build()

    Builds the configured HttpRequestData instance.

    Declaration
    public HttpRequestData Build()
    Returns
    Type Description
    HttpRequestData

    A concrete HttpRequestData suitable for tests.

    WithBody(Stream, string?)

    Sets the request body from an existing stream.

    Declaration
    public HttpRequestDataBuilder 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
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

    WithBody(string, Encoding?, string?)

    Sets the request body from a string payload.

    Declaration
    public HttpRequestDataBuilder 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
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

    WithClaimsPrincipal(ClaimsPrincipal)

    Adds all identities from the supplied principal to the request.

    Declaration
    public HttpRequestDataBuilder WithClaimsPrincipal(ClaimsPrincipal principal)
    Parameters
    Type Name Description
    ClaimsPrincipal principal

    The principal whose identities should be added.

    Returns
    Type Description
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

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

    Adds a request cookie.

    Declaration
    public HttpRequestDataBuilder WithCookie(string name, string value, string? path = null, string? domain = 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.

    Returns
    Type Description
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

    WithHeader(string, string)

    Adds a request header.

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

    The header name.

    string value

    The header value.

    Returns
    Type Description
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

    WithIdentity(ClaimsIdentity)

    Adds a claims identity to the request.

    Declaration
    public HttpRequestDataBuilder WithIdentity(ClaimsIdentity identity)
    Parameters
    Type Name Description
    ClaimsIdentity identity

    The identity to add.

    Returns
    Type Description
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

    WithJsonBody<TValue>(TValue, JsonSerializerOptions?)

    Sets the request body from a JSON payload.

    Declaration
    public HttpRequestDataBuilder 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
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

    Type Parameters
    Name Description
    TValue

    The payload type.

    WithMethod(string)

    Sets the HTTP method.

    Declaration
    public HttpRequestDataBuilder WithMethod(string method)
    Parameters
    Type Name Description
    string method

    The HTTP method.

    Returns
    Type Description
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

    WithQueryParameter(string, string?)

    Adds a query-string parameter.

    Declaration
    public HttpRequestDataBuilder WithQueryParameter(string name, string? value)
    Parameters
    Type Name Description
    string name

    The parameter name.

    string value

    The parameter value.

    Returns
    Type Description
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

    WithUrl(string)

    Sets the request URL.

    Declaration
    public HttpRequestDataBuilder WithUrl(string url)
    Parameters
    Type Name Description
    string url

    The absolute request URL.

    Returns
    Type Description
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder instance.

    WithUrl(Uri)

    Sets the request URL.

    Declaration
    public HttpRequestDataBuilder WithUrl(Uri url)
    Parameters
    Type Name Description
    Uri url

    The absolute request URL.

    Returns
    Type Description
    HttpRequestDataBuilder

    The current HttpRequestDataBuilder 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