public async void ChangePasswordRoute_Test() { // Arrange var person = CreatePerson(); var newPassword = "******"; _personRepository .Setup(x => x.Single(It.IsAny <Expression <Func <Person, bool> > >())) .ReturnsAsync(person); _personRepository .Setup(x => x.Update(It.IsAny <Expression <Func <Person, bool> > >(), It.IsAny <Person>())) .ReturnsAsync(true); _emailHelper .Setup(e => e.ChangePasswordBody(It.IsAny <Person>())) .Returns("change password body of email"); _emailHelper .Setup(e => e.ChangePasswordSubject()) .Returns("change password subject of email"); _emailHelper .Setup(e => e.SendEmail(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(true); var personController = new PersonController(_personRepository.Object, _mapper, _emailHelper.Object, _tokenClass.Object); // Act var result = await personController.ChangePassword(person.Name, newPassword, person.HashedPassword); var okResult = result as OkObjectResult; // Assert Assert.True(okResult != null); Assert.Equal(200, okResult.StatusCode); Assert.Equal(bool.TrueString, okResult.Value.ToString()); }