public async Task Should_Not_Create_new_Email_Confirmation_Token_If_Email_Is_Already_Confirmed() { // Arrange var dto = new CreateEmailConfirmationTokenDto { UsernameOrEmail = UserTestSeedData.Performer.Email, ClientUri = "http://localhost:4200" }; // Act HttpResponseMessage responseMessage = await _unAuthenticatedServer .CreateClient() .PostAsync(ApiEndpoints.AuthController.CreateNewEmailConfirmationToken(), BuildStringContent(dto)); // Assert responseMessage.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); _fakeSmtpServer.ReceivedEmailCount.Should().Be(0); ValidationProblemDetails errorMessage = await DeserializeResponseMessageAsync <ValidationProblemDetails>(responseMessage); errorMessage.Title.Should().Be("One or more validation errors occurred."); errorMessage.Status.Should().Be(422); errorMessage.Errors.Should().BeEquivalentTo(new Dictionary <string, string[]>() { { "UsernameOrEmail", new[] { "The email address is already confirmed" } } }); }
public async Task <ActionResult> CreateNewEmailConfirmationToken( [FromBody] CreateEmailConfirmationTokenDto createEmailConfirmationTokenDto) { await _authService.CreateNewEmailConfirmationTokenAsync(createEmailConfirmationTokenDto); return(NoContent()); }
public void Should_Map() { // Arrange var dto = new CreateEmailConfirmationTokenDto { UsernameOrEmail = UserTestSeedData.Performer.Email, ClientUri = "Http://localhost:4200" }; // Act CreateEmailConfirmationToken.Command command = _mapper.Map <CreateEmailConfirmationToken.Command>(dto); // Assert command.Should().BeEquivalentTo(dto); }
public async Task Should_Create_new_Email_Confirmation_Token() { // Arrange var dto = new CreateEmailConfirmationTokenDto { UsernameOrEmail = UserTestSeedData.UnconfirmedUser.Email, ClientUri = "http://localhost:4200" }; // Act HttpResponseMessage responseMessage = await _unAuthenticatedServer .CreateClient() .PostAsync(ApiEndpoints.AuthController.CreateNewEmailConfirmationToken(), BuildStringContent(dto)); // Assert responseMessage.StatusCode.Should().Be(HttpStatusCode.NoContent); _fakeSmtpServer.ReceivedEmailCount.Should().Be(1); }
public async Task CreateNewEmailConfirmationTokenAsync(CreateEmailConfirmationTokenDto createEmailConfirmationTokenDto) { CreateEmailConfirmationToken.Command command = _mapper.Map <CreateEmailConfirmationToken.Command>(createEmailConfirmationTokenDto); await _mediator.Send(command); }