public async Task ValidateRoleAsnc() { var contextAccessor = Substitute.For <IHttpContextAccessor>(); var claimsFactory = Substitute.For <IUserClaimsPrincipalFactory <ApplicationUser> >(); var logger = Substitute.For <ILogger <SignInManager <ApplicationUser> > >(); var schemes = Substitute.For <IAuthenticationSchemeProvider>(); var confirmation = Substitute.For <IUserConfirmation <ApplicationUser> >(); var signInManager = Substitute.For <SignInManager <ApplicationUser> >(_userManager, contextAccessor, claimsFactory, _optionsAccessor, logger, schemes, confirmation); var loginValidator = new LoginValidator(signInManager, _userManager); var user = new ApplicationUser(); await loginValidator.ValidateRoleAsync(user, "admin"); await _userManager.Received().IsInRoleAsync(Arg.Any <ApplicationUser>(), Arg.Any <string>()); }