public async Task VerifyAccountExistsAsync_Should_Return_VerificationResult_With_Success_True() { var accountId = Guid.NewGuid(); const string email = "*****@*****.**"; var account = new GetAccountResponse { Id = accountId, Email = email }; var expectedResult = VerificationResult.Ok(); _rivaIdentityApiClientServiceMock.Setup(x => x.GetAccountAsync(It.IsAny <Guid>())) .ReturnsAsync(account); var result = await _service.VerifyAccountExistsAsync(accountId, email); result.Should().BeEquivalentTo(expectedResult); }
public async Task HandleAsync(CreateUserCommand command, CancellationToken cancellationToken = default) { var userDoesNotExistsVerificationResult = await _userVerificationService.VerifyUserDoesNotExistAsync(command.UserId); if (!userDoesNotExistsVerificationResult.Success) { throw new ConflictException(userDoesNotExistsVerificationResult.Errors); } var accountExistsVerificationResult = await _accountVerificationService.VerifyAccountExistsAsync(command.UserId, command.Email); if (!accountExistsVerificationResult.Success) { throw new ValidationException(accountExistsVerificationResult.Errors); } var user = _mapper.Map <CreateUserCommand, User>(command); user.AddCreatedEvent(Guid.NewGuid()); await _communicationBus.DispatchDomainEventsAsync(user, cancellationToken); await _userRepository.AddAsync(user); }