Beispiel #1
0
        private async void DisplayRates()
        {
            Overlay.Visibility = Visibility.Visible;
            var itemsCount  = exchangeRate.BanksInfo.Count;
            var currentItem = 0;

            foreach (var bankID in exchangeRate.BanksInfo.Keys)
            {
                try
                {
                    lblItemsLoading.Content = $"{currentItem} out of {itemsCount}";

                    var rateBuySell = await exchangeRate.GetBuySellRate(bankID);       //get buy and sell exchange rate

                    var rateItem = InitializeNewExchangeRateItem(bankID, rateBuySell); //create new item for dgExchangeRate

                    exchangeRateItems.Add(rateItem);                                   //add item to the dgExchangeRate

                    currentItem++;
                }
                catch (Exception e) //if bankID is not exist catch Exception and show error
                {
                    MessageBox.Show(e.Message, "Error", MessageBoxButton.OK);
                }
            }

            Overlay.Visibility = Visibility.Collapsed;
        }
        public void GetBuySellRate()
        {
            var expected = new Tuple <string, string>("2685.00", "2740.00"); //check on web-site buy and sell exchange rate (USD)

            var neededBankID = BankID.Create(1);
            var actual       = exchangeRate.GetBuySellRate(neededBankID).Result; //get buy and sell rate from web-site

            Assert.AreEqual(expected, actual);
        }