Example #1
0
        public async void Test_Transfer()
        {
            string currency = "GBP";
            var    accounts = await _accountApiClient.GetAccounts();

            GetAccountResp accountResp1 = null;
            GetAccountResp accountResp2 = null;

            try
            {
                accountResp1 = accounts.Where(x => x.Currency == currency).First();
                accounts.Remove(accountResp1);
                accountResp2 = accounts.Where(x => x.Currency == currency).First();
            }
            catch (InvalidOperationException ex)
            {
                throw new Exception($"Missing account with {currency} currency");
            }

            TransferReq req = new TransferReq
            {
                RequestId       = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString(),
                SourceAccountId = accountResp1.Id,
                TargetAccountId = accountResp2.Id,
                Amount          = 100,
                Currency        = currency
            };

            var resp = await _paymentClient.CreateTransfer(req);

            Assert.NotNull(resp);
        }
Example #2
0
        public async void Test_Transfer_InSameCurrencys()
        {
            var currency = "EUR";
            var accounts = (await _accountApiClient.GetAccounts()).ToList();

            GetAccountResp accountInCurrencyMain     = null;
            GetAccountResp accounInCurrencySecondary = null;

            try
            {
                accountInCurrencyMain = accounts.FirstOrDefault(x => x.Currency == currency);
                if (accountInCurrencyMain == null)
                {
                    throw new Exception($"Account in currency is missing, you need to create a new one");
                }

                accounInCurrencySecondary =
                    accounts.FirstOrDefault(x => x.Currency == currency && x.Id != accountInCurrencyMain.Id);
                if (accounInCurrencySecondary == null)
                {
                    throw new Exception($"account Not InCurrency is missing, you need to create a new one");
                }

                await Task.Delay(200);
            }
            catch (InvalidOperationException ex)
            {
                throw new Exception($"Missing account with {currency} currency - {ex.Message}");
            }

            var req = new TransferReq
            {
                RequestId       = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString(),
                SourceAccountId = accountInCurrencyMain.Id,
                TargetAccountId = accounInCurrencySecondary.Id,
                Amount          = 100,
                Currency        = currency
            };

            var resp = await _paymentClient.CreateTransfer(req);

            Assert.NotNull(resp);
        }
Example #3
0
        public async void TestGetAccount_InalidId()
        {
            GetAccountResp resp = await _accountClient.GetAccount("000");

            Assert.Null(resp);
        }
Example #4
0
        public async void TestGetAccount_ValidId_Success()
        {
            GetAccountResp resp = await _accountClient.GetAccount(ACCOUNT_ID);

            Assert.NotNull(resp);
        }