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
userNamestringIdentity's user name.
rolesIEnumerable<string>Roles that this user principal has.
claimsIEnumerable<Claim>Claims to add to user principal.
authenticationTypestringThe 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
userNamestringIdentity's user name.
rolesIEnumerable<string>Roles that this user principal has.
claimsIEnumerable<Claim>Claims to add to user principal.
authenticationTypestringThe 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()