I have the following code:
var userStore = new Mock<IUserStore<AspNetUser, int>>();
var userManager = new ApplicationUserManager(userStore.Object);
controller.UserManager = userManager;
userStore.Setup(x => x.CreateAsync(It.IsAny<PixlocateDB.AspNetUser>())).Returns(Task.FromResult(IdentityResult.Success));
It works fine. Now I want to create a stub for AddToRoleAsync. I try to do the following:
userStore.Setup(x => x.AddToRoleAsync(It.IsAny<int>(), It.IsAny<string>())).Returns(Task.FromResult(IdentityResult.Success));
but I get an error:
Severity Code Description Project File Line Suppression State Error CS1061 'IUserStore' does not contain a definition for 'AddToRoleAsync' and no extension method 'AddToRoleAsync' accepting a first argument of type 'IUserStore' could be found (are you missing a using directive or an assembly reference?) Pixlocate.Tests
Why?
Aucun commentaire:
Enregistrer un commentaire