FastMoq
Search Results for

    Show / Hide Table of Contents

    Class TestAuthorizationContext

    Backward-compatible wrapper around Bunit.TestDoubles.BunitAuthorizationContext.

    Inheritance
    object
    TestAuthorizationContext
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Bunit.TestDoubles
    Assembly: FastMoq.Web.dll
    Syntax
    public sealed class TestAuthorizationContext
    Remarks

    This wrapper preserves the older FastMoq-facing helper name while the underlying bUnit authorization implementation comes from the current bUnit 2 package line.

    Constructors

    TestAuthorizationContext(BunitAuthorizationContext)

    Initializes a new instance of the TestAuthorizationContext class.

    Declaration
    public TestAuthorizationContext(BunitAuthorizationContext inner)
    Parameters
    Type Name Description
    BunitAuthorizationContext inner

    The underlying bUnit authorization context.

    Properties

    Claims

    Gets the active claims.

    Declaration
    public IEnumerable<Claim> Claims { get; }
    Property Value
    Type Description
    IEnumerable<Claim>

    InnerContext

    Gets the underlying bUnit authorization context.

    Declaration
    public BunitAuthorizationContext InnerContext { get; }
    Property Value
    Type Description
    BunitAuthorizationContext

    IsAuthenticated

    Gets a value indicating whether the current user is authenticated.

    Declaration
    public bool IsAuthenticated { get; }
    Property Value
    Type Description
    bool

    Policies

    Gets the active policies.

    Declaration
    public IEnumerable<string> Policies { get; }
    Property Value
    Type Description
    IEnumerable<string>

    PolicySchemeName

    Gets the configured policy scheme name.

    Declaration
    public string PolicySchemeName { get; }
    Property Value
    Type Description
    string

    Roles

    Gets the active roles.

    Declaration
    public IEnumerable<string> Roles { get; }
    Property Value
    Type Description
    IEnumerable<string>

    State

    Gets the current authorization state.

    Declaration
    public AuthorizationState State { get; }
    Property Value
    Type Description
    AuthorizationState

    UserName

    Gets the current user name.

    Declaration
    public string UserName { get; }
    Property Value
    Type Description
    string

    Methods

    SetAuthenticationType(string)

    Sets the authentication type for the current identity.

    Declaration
    public void SetAuthenticationType(string authenticationType)
    Parameters
    Type Name Description
    string authenticationType

    The authentication type.

    SetAuthorized(string)

    Sets an authenticated user with the default authorized state.

    Declaration
    public void SetAuthorized(string userName)
    Parameters
    Type Name Description
    string userName

    The user name.

    Examples
    AuthContext.SetAuthorized("migration.user");

    SetAuthorized(string, AuthorizationState)

    Sets an authenticated user with the specified authorization state.

    Declaration
    public void SetAuthorized(string userName, AuthorizationState state)
    Parameters
    Type Name Description
    string userName

    The user name.

    AuthorizationState state

    The authorization state.

    SetAuthorizing()

    Puts the authorization services into the authorizing state.

    Declaration
    public void SetAuthorizing()

    SetClaims(params Claim[])

    Sets the active claims.

    Declaration
    public void SetClaims(params Claim[] claims)
    Parameters
    Type Name Description
    Claim[] claims

    The claims to apply.

    SetNotAuthorized()

    Puts the authorization services into the unauthenticated state.

    Declaration
    public void SetNotAuthorized()

    SetPolicies(params string[])

    Sets the active policies.

    Declaration
    public void SetPolicies(params string[] policies)
    Parameters
    Type Name Description
    string[] policies

    The policies to apply.

    SetRoles(params string[])

    Sets the active roles.

    Declaration
    public void SetRoles(params string[] roles)
    Parameters
    Type Name Description
    string[] roles

    The roles to apply.

    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-29 03:53 UTC