public void Handle_GivenInvalidCodeAndPassword_ThrowsException() { var command = new ConfirmRestoreCodeCommand { Email = DefaultUserEmail, Code = Guid.NewGuid().ToString(), Password = string.Empty }; var handler = GetNewHandler(); Assert.ThrowsAsync <ValidationException>(async() => await handler.Handle(command, CancellationToken.None)); }
public void Handle_GivenNonexistentEmail_ThrowsException() { var command = new ConfirmRestoreCodeCommand { Email = "*****@*****.**", Code = "12345678", Password = "******" }; var handler = GetNewHandler(); Assert.ThrowsAsync <ValidationException>(async() => await handler.Handle(command, CancellationToken.None)); }
public void IsValid_ShouldBeTrue() { var command = new ConfirmRestoreCodeCommand { Code = "177602", Email = DefaultUserEmail, Password = DefaultUserPassword }; var validator = GetNewValidator(); var result = validator.Validate(command); Assert.That(result.IsValid); }
public async Task Handle_ShouldGetSuccessInfo() { var user = Context.Users.First(); var code = await UserManager.GeneratePasswordResetTokenAsync(user); var command = new ConfirmRestoreCodeCommand { Email = user.Email, Code = code, Password = "******" }; var handler = GetNewHandler(); var result = await handler.Handle(command, CancellationToken.None); Assert.That(result.Info, IsNotNullOrEmpty); }
public async Task <ActionResult <ConfirmRestoreCodeResponseDto> > ConfirmRestoreCode( [FromBody] ConfirmRestoreCodeCommand command) { return(await Mediator.Send(command)); }