public async Task VerifyEmailIsNotTakenAsync_Should_Return_VerificationResult_With_Success_True() { const string email = "*****@*****.**"; var getAccountResult = GetResult <Account> .Fail(new List <IError>()); var expectedResult = VerificationResult.Ok(); _accountGetterServiceMock.Setup(x => x.GetByEmailAsync(It.IsAny <string>())).ReturnsAsync(getAccountResult); var result = await _accountVerificationService.VerifyEmailIsNotTakenAsync(email); result.Should().BeEquivalentTo(expectedResult); }
public async Task HandleAsync(CreateAccountCommand command, CancellationToken cancellationToken = default) { var emailIsNotTakenVerificationResult = await _accountVerificationService.VerifyEmailIsNotTakenAsync(command.Email); if (!emailIsNotTakenVerificationResult.Success) { throw new ConflictException(emailIsNotTakenVerificationResult.Errors); } await _accountCreatorService.CreateAsync(command.AccountId, command.Email, command.Password, command.CorrelationId); var accountCreatedIntegrationEvent = new AccountCreatedIntegrationEvent(command.CorrelationId, command.AccountId, command.Email, string.Empty); await _integrationEventBus.PublishIntegrationEventAsync(accountCreatedIntegrationEvent); }