public async Task Post(bool returnValue) { const string password = "******"; const int userId = 123; var userManager = new Mock <IUserManager>(); userManager.Setup(c => c.UpdatePassword(userId, password)) .Returns(Task.FromResult(returnValue)); var sut = new PasswordController(userManager.Object); sut.Token = new AuthToken { Token = "token", UserId = userId, ValidUntil = DateTime.Now.AddDays(1), IsVerified = true }; var result = await sut.Post(new PasswordChangeRequest { Password = password, DeviceId = "deviceId" }); Assert.AreEqual(returnValue, result); }
public async Task PostException() { const string password = "******"; const int userId = 123; var userManager = new Mock <IUserManager>(); userManager.Setup(c => c.UpdatePassword(userId, password)) .Returns(Task.FromResult(false)); var sut = new PasswordController(userManager.Object); var result = await sut.Post(new PasswordChangeRequest { Password = password, DeviceId = "deviceId" }); Assert.AreEqual(false, result); }