public void CreateAccount_Success()
        {
            var customer = _customerTests.RegisterCustomer_Success(
                Constants.Country.GreekCountryCode);

            Assert.NotNull(customer);

            var accountOptions = new CreateAccountOptions()
            {
                CurrencyCode = Constants.CurrencyCode.Euro,
                Description  = "My test account"
            };

            var accountResult = _accounts.Create(
                customer.CustomerId, accountOptions);

            Assert.True(accountResult.IsSuccessful());

            var account = accountResult.Data;

            Assert.StartsWith(customer.CountryCode, account.AccountId);
            Assert.Equal(customer.CustomerId, account.CustomerId);
            Assert.Equal(0M, account.Balance);
            Assert.Equal(Constants.AccountState.Active, account.State);
        }
Beispiel #2
0
        public void Card_Register_Success()
        {
            var customer = _customerTests.RegisterCustomer_Success(
                Constants.Country.GreekCountryCode);

            var account = new Account()
            {
                Balance      = 1000M,
                CurrencyCode = "EUR",
                State        = Constants.AccountState.Active,
                AccountId    = $"GR{DateTimeOffset.Now:ssfffffff}"
            };

            customer.Accounts.Add(account);
            _dbContext.SaveChanges();

            var card = new Card()
            {
                Active     = true,
                CardNumber = $"4111111111111{DateTimeOffset.Now:fff}",
                CardType   = Constants.CardType.Debit
            };

            account.Cards.Add(card);

            _dbContext.Add(card);
            _dbContext.SaveChanges();

            var customerFromDb = _dbContext.Set <Customer>()
                                 .Where(c => c.VatNumber == customer.VatNumber)
                                 .Include(c => c.Accounts)
                                 .ThenInclude(a => a.Cards)
                                 .SingleOrDefault();

            var customerCard = customerFromDb.Accounts
                               .SelectMany(a => a.Cards)
                               .Where(c => c.CardNumber == card.CardNumber)
                               .SingleOrDefault();

            Assert.NotNull(customerCard);
            Assert.Equal(Constants.CardType.Debit, customerCard.CardType);
            Assert.True(customerCard.Active);
        }