Class BunitAuthenticationStateProvider
- Namespace
- Bunit.TestDoubles
- Assembly
- bunit.dll
Represents a implementation of AuthenticationStateProvider for testing purposes that allows user to test components that use authentication and authorization.
public class BunitAuthenticationStateProvider : AuthenticationStateProvider
- Inheritance
-
BunitAuthenticationStateProvider
- Inherited Members
- Extension Methods
Constructors
BunitAuthenticationStateProvider()
Initializes a new instance of the BunitAuthenticationStateProvider class.
public BunitAuthenticationStateProvider()
BunitAuthenticationStateProvider(string, IEnumerable<string>?, IEnumerable<Claim>?, string?)
Initializes a new instance of the BunitAuthenticationStateProvider class with an initial AuthenticationState.
public BunitAuthenticationStateProvider(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()