public async Task Given_CorrectInformationProvided_When_ChangePassword_Then_SavesRedirectsAndEmails() { // Arrange var model = new ChangePasswordViewModel { OldPassword = "******", NewPassword = "******", ConfirmPassword = "******" }; _userManager.Expect(a => a.ChangePasswordAsync(Arg <int> .Is.Anything, Arg <string> .Is.Anything, Arg <string> .Is.Anything)) .Return(Task.FromResult(new SeIdentityResult())); UserIdentity.Expect(a => a.GetUserId(Arg <Controller> .Is.Anything)).Return(5); _recaptcha.Expect(a => a.ValidateRecaptcha(Arg <Controller> .Is.Anything)).Return(true); // Act var result = await _sut.ChangePasswordAsync(model); // Assert AssertViewResultReturned(result, "ChangePasswordSuccess"); _services.AssertWasCalled(a => a.SendEmail(Arg <string> .Is.Anything, Arg <List <string> > .Is.Anything, Arg <List <string> > .Is.Anything, Arg <List <string> > .Is.Anything, Arg <string> .Is.Anything, Arg <string> .Is.Anything, Arg <bool> .Is.Anything)); _formsAuth.AssertWasCalled(a => a.SignOut()); Context.AssertWasCalled(a => a.SaveChanges()); _httpCache.AssertWasCalled(a => a.RemoveFromCache(Arg <string> .Is.Equal("MustChangePassword-5"))); }
public async Task Given_CorrectInformationProvided_When_ChangePassword_Then_SavesRedirectsAndEmails() { // Arrange var model = new ViewModel.ChangePasswordViewModel() { OldPassword = "******", NewPassword = "******", ConfirmPassword = "******" }; _userManager.Expect(a => a.ChangePasswordAsync(Arg <int> .Is.Anything, Arg <string> .Is.Anything, Arg <string> .Is.Anything)) .Return(Task.FromResult(new SEIdentityResult() { })); _userIdentity.Stub(u => u.GetRequester(Arg <Controller> .Is.Anything, Arg <AppSensorDetectionPointKind> .Is.Anything)).Return(new Requester() { LoggedOnUserId = 5 }); _recaptcha.Expect(a => a.ValidateRecaptcha(Arg <Controller> .Is.Anything)).Return(true); // Act var result = await _sut.ChangePassword(model); // Assert AssertViewResultReturned(result, "ChangePasswordSuccess"); _services.AssertWasCalled(a => a.SendEmail(Arg <string> .Is.Anything, Arg <List <string> > .Is.Anything, Arg <List <string> > .Is.Anything, Arg <List <string> > .Is.Anything, Arg <string> .Is.Anything, Arg <string> .Is.Anything, Arg <bool> .Is.Anything)); _formsAuth.AssertWasCalled(a => a.SignOut()); _context.AssertWasCalled(a => a.SaveChanges()); }