public async Task AccountExistsAsync_WithAccountAndCustomerNotExists_ReturnFalse()
        {
            // Arrange
            var accountRequest = new AccountRequest
            {
                AccountIban = "CCCC",
                FirstName   = "test",
                LastName    = "test",
                Balance     = 1000,
                Email       = "*****@*****.**",
                Address     = "123456"
            };

            customerRepository
            .CustomerExistsAsync(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>())
            .Returns(false);

            accountRepository
            .AccountExistsAsync(Arg.Any <string>())
            .Returns(false);

            // Act
            var result = await customerAccountsService.AccountExistsAsync(accountRequest);

            // Assert
            Assert.False(result);
        }
        public async Task <bool> AccountExistsAsync(AccountRequest request)
        {
            var customerExists = await customerRepository.CustomerExistsAsync(request.FirstName, request.LastName, request.Email);

            var accountExists = await accountRepository.AccountExistsAsync(request.AccountIban);

            if (customerExists || accountExists)
            {
                return(true);
            }

            return(false);
        }
        public async Task <CreateAccountResponse> ExecuteCommandAsync(AccountCreateCommand command)
        {
            var newAccountId = CreateRandomAccountId();

            while (await _accountRepository.AccountExistsAsync(newAccountId) == false)
            {
                newAccountId = CreateRandomAccountId();
            }

            var newAccount = new Account(newAccountId, command.Name, command.StartingBalance);
            var created    = await _accountRepository.AddNewAccountAsync(newAccount);

            if (created == false)
            {
                return(null);
            }

            return(new CreateAccountResponse(newAccountId));
        }
Esempio n. 4
0
 public async Task <bool> AccountExistsAsync(UserId userId)
 {
     return(await _accountRepository.AccountExistsAsync(userId));
 }