I am using Moq framework to mock objects in my project. I want to save the user profile which is calling UserManager.SetPhoneNUmberAsync of AspNet.Identity. Here is my code:
public async Task<ActionResult> SaveProfile(DistributorViewModel distributorModel)
{
if (ModelState.IsValid)
{
string currentUserId = User.Identity.GetUserId();
distributorModel.UserDetailViewModel.ModifiedDate = System.DateTime.Now;
distributorModel.UserDetailViewModel.ModifiedBy =Guid.Parse( currentUserId);
var isUpdated = this.distributorService.Update(distributorModel.UserDetailViewModel);
IdentityResult result = await UserManager.SetPhoneNumberAsync(currentUserId, distributorModel.UserDetailViewModel.MobileNo);
if (result.Succeeded && isUpdated)
{
Flash.Success(Messages.ProfileUpdatedSuccessfully);
}
else
{
Flash.Error(Messages.ProfileUpdationError);
}
}
return RedirectToAction("Index", distributorModel);
}
Its throwing error on UserManager.SetPhoneNumberAsync. How can I mock this method?