I am using Asp.Net Identity in my MVC application and I have a class named ApplicationSignInManager that looks like this:
public class ApplicationSignInManager : SignInManager<ApplicationUser, string>
{
public ApplicationSignInManager(ApplicationUserManager userManager,
IAuthenticationManager authenticationManager)
: base(userManager, authenticationManager)
{
}
public override Task<ClaimsIdentity> CreateUserIdentityAsync(ApplicationUser user)
{
return user.GenerateUserIdentityAsync((ApplicationUserManager)UserManager);
}
public static ApplicationSignInManager Create(IdentityFactoryOptions<ApplicationSignInManager> options,
IOwinContext context)
{
return new ApplicationSignInManager(context.GetUserManager<ApplicationUserManager>(),
context.Authentication);
}
}
Now, I would like to write a unit test for an action on a controller. I am using the Microsoft Visual Studio Unit Test framework with Moq 4.5.10.
The action calls the PasswordSignInAsync method that is declared virtual in the base class SignInManager<ApplicationUser, string> but it is not overriden in the child class ApplicationSignInManager.
I have tried this option, too:
var mockSignInManager = new Mock<ApplicationSignInManager>()
{ CallBase = true };
mockSignInManager.Setup(
m => m.PasswordSignInAsync(string.Empty, string.Empty, true, true));
But PasswordSignInAsync does not show up in the Intellisense and the compiler complains it cannot find that method on ApplicationSignInManager.
How do I get it to show up?
Aucun commentaire:
Enregistrer un commentaire