public void ExchangeFromUsdToEur()
        {
            string USD = "USD";
            string EUR = "EUR";
            float ammount = 2.45F;

            CurrencyExchanger ce = new CurrencyExchanger();

            Assert.AreEqual(ce.ExchangeValue(USD, EUR, ammount), (ce.GetRate(USD) / ce.GetRate(EUR)) * ammount);
        }
        public void ExchangeToInvalidCurrency()
        {
            string NonValidCurrency = "ABC";
            string EUR = "EUR";
            float ammount = 2.45F;
            float result;
            Exception ex = null;

            CurrencyExchanger ce = new CurrencyExchanger();

            try
            {
                result = ce.ExchangeValue(EUR, NonValidCurrency, ammount);
            }
            catch (Exception e)
            {
                ex = e;
            }

            Assert.IsInstanceOfType(ex, typeof(CurrencyNotFoundException));
        }
        public List<ProfitDay> calculateProfits(CurrencyExchanger ce, Investment i, string data)
        {
            float stockProfit = 0;

            List<ProfitDay> thisCompanyProfits = new List<ProfitDay>();
            DateTime calculateDate = i.BuyTime;

            QueryResult qr = new QueryResult(data, i.Stock.StockName);
            foreach (StockDay sd in qr.StockDays)
            {
                if (sd.Date >= i.BuyTime)
                {
                    stockProfit = (float)(sd.ClosingValue - i.UnitStockValue) * i.Quantity;

                    if (i.Stock.Currency != preferedCurrency)
                    {

                        stockProfit = ce.ExchangeValue(i.Stock.Currency, preferedCurrency, stockProfit);
                    }

                    thisCompanyProfits.Add(new ProfitDay(new DateTime(calculateDate.Year, calculateDate.Month, calculateDate.Day), stockProfit));
                }
            }

            return thisCompanyProfits;
        }
        public List<ProfitDay> calculateProfit(CurrencyExchanger ce, Dictionary<Investment, string> invData)
        {
            List<ProfitDay> points = new List<ProfitDay>();
            float profit = 0;

            List<Dictionary<string, float>> ld = new List<Dictionary<string, float>>();

            DateTime calculateDate = getOldestInvestmentDate();

            foreach (KeyValuePair<Investment, string> inv in invData)
            {
                float stockProfit = 0;

                Dictionary<string, float> thisCompanyProfits = new Dictionary<string, float>();

                QueryResult qr = new QueryResult(inv.Value, inv.Key.Stock.StockName);
                foreach (StockDay sd in qr.StockDays)
                {
                    if (sd.Date >= inv.Key.BuyTime)
                    {
                        stockProfit = (float)(sd.ClosingValue - inv.Key.UnitStockValue) * inv.Key.Quantity;

                        if (inv.Key.Stock.Currency != preferedCurrency)
                        {

                            stockProfit = ce.ExchangeValue(inv.Key.Stock.Currency, preferedCurrency, stockProfit);
                        }

                        thisCompanyProfits.Add(sd.Date.ToString("dd-MM-yyyy"), stockProfit);
                    }
                }
                ld.Add(thisCompanyProfits);
            }

            while (calculateDate < DateTime.Today)
            {
                profit = 0;

                foreach (Dictionary<string, float> dic in ld)
                {
                    if(dic.ContainsKey(calculateDate.ToString("dd-MM-yyyy")))
                    {
                        profit += dic[calculateDate.ToString("dd-MM-yyyy")];
                    }
                }

                points.Add(new ProfitDay(new DateTime(calculateDate.Year, calculateDate.Month, calculateDate.Day), profit));
                calculateDate = calculateDate.AddDays(1);
            }

            points.Sort();
            return points;
        }