Table of Contents

Class FakeAuthenticationStateProvider

Namespace
Bunit.TestDoubles
Assembly
Bunit.Web.dll

Represents a fake implementation of AuthenticationStateProvider for testing purposes that allows user to test components that use authentication and authorization.

public class FakeAuthenticationStateProvider : AuthenticationStateProvider
Inheritance
FakeAuthenticationStateProvider
Inherited Members
Extension Methods

Constructors

FakeAuthenticationStateProvider()

Initializes a new instance of the FakeAuthenticationStateProvider class.

public FakeAuthenticationStateProvider()

FakeAuthenticationStateProvider(string, IEnumerable<string>?, IEnumerable<Claim>?, string?)

Initializes a new instance of the FakeAuthenticationStateProvider class with an initial AuthenticationState.

public FakeAuthenticationStateProvider(string userName, IEnumerable<string>? roles = null, IEnumerable<Claim>? claims = null, string? authenticationType = null)

Parameters

userName string

Identity's user name.

roles IEnumerable<string>

Roles that this user principal has.

claims IEnumerable<Claim>

Claims to add to user principal.

authenticationType string

The authentication type for the user principal.

Methods

GetAuthenticationStateAsync()

Overridden method to get the current authentication state.

public override Task<AuthenticationState> GetAuthenticationStateAsync()

Returns

Task<AuthenticationState>

Current authentication state.

TriggerAuthenticationStateChanged(string, IEnumerable<string>?, IEnumerable<Claim>?, string?)

Method to sets the authentication state and authenticated user.

public void TriggerAuthenticationStateChanged(string userName, IEnumerable<string>? roles = null, IEnumerable<Claim>? claims = null, string? authenticationType = null)

Parameters

userName string

Identity's user name.

roles IEnumerable<string>

Roles that this user principal has.

claims IEnumerable<Claim>

Claims to add to user principal.

authenticationType string

The authentication type for the user principal.

TriggerAuthorizingStateChanged()

Method to sets the authentication state to authorizing state.

public void TriggerAuthorizingStateChanged()

TriggerUnauthenticationStateChanged()

Method to sets the authentication state to unauthenticated.

public void TriggerUnauthenticationStateChanged()
Progress Telerik

Premium sponsor: Progress Telerik.

Packt

Editorial support provided by Packt.

.NET Foundation

Supported by the .NET Foundation.