public AccountControllerTest() { //_userManager = new Mock<UserManager<User>>(); _userManager = MockUserManager.GetUserManager <User>(); _signInManager = MockSignInManager.GetSignInManager <User>(); // // Summary: // Creates a new instance of Microsoft.AspNetCore.Identity.SignInManager`1. // // Parameters: // userManager: // An instance of Microsoft.AspNetCore.Identity.SignInManager`1.UserManager used // to retrieve users from and persist users. // // contextAccessor: // The accessor used to access the Microsoft.AspNetCore.Http.HttpContext. // // claimsFactory: // The factory to use to create claims principals for a user. // // optionsAccessor: // The accessor used to access the Microsoft.AspNetCore.Builder.IdentityOptions. // // logger: // The logger used to log messages, warnings and errors. //_signInManager = new Mock<SignInManager<User>>(_userManager, null, null, null, null); }
public static Mock <SignInManager <User> > GetSignInManager <TUser>() where TUser : class { Mock <UserManager <TUser> > userManager = MockUserManager.GetUserManager <TUser>(); Mock <IHttpContextAccessor> contextAccessor = new Mock <IHttpContextAccessor>(); Mock <IUserClaimsPrincipalFactory <TUser> > claimsFactory = new Mock <IUserClaimsPrincipalFactory <TUser> >(); Mock <IOptions <IdentityOptions> > optionsAccessor = new Mock <IOptions <IdentityOptions> >(); Mock <ILogger <SignInManager <TUser> > > logger = new Mock <ILogger <SignInManager <TUser> > >(); return(new Mock <SignInManager <User> >(userManager.Object, contextAccessor.Object, claimsFactory.Object, optionsAccessor.Object, logger.Object)); }