예제 #1
0
        public static void ConvertCurrenciesFromGivenFile(IFileParser fileParser, CurrencyConverter currencyConverter, string fileName)
        {
            List <RequestedCurrencies> requestedCurrencies     = fileParser.ParseFile(fileName);
            List <List <double> >      sumsInRequestedCurrency = currencyConverter.ConvertCurrencies(requestedCurrencies);

            PrintListsVals <double>(sumsInRequestedCurrency);
        }
예제 #2
0
 public void ConvertZeroCurrencyTest()
 {
     try
     {
         CurrencyConverter   currencyConverter = new CurrencyConverter(_dsConfig);
         RequestedCurrencies requested         = _requestedCurrencies;
         requested._sums[0] = 0;
         List <double> convertedCurrencies = currencyConverter.ConvertCurrencies(requested);
         Assert.IsTrue(convertedCurrencies[0] == 0);
     }
     catch (Exception e)
     {
         Assert.Fail("Failed to convert currencies, exception message: {0}", e.Message);
     }
 }
예제 #3
0
        public void ConvertUnknownCurrencyTest()
        {
            bool exceptionCaught = false;

            try
            {
                CurrencyConverter   currencyConverter = new CurrencyConverter(_dsConfig);
                RequestedCurrencies requested         = _requestedCurrencies;
                requested._expectedCurrency = "TXT";
                List <double> convertedCurrencies = currencyConverter.ConvertCurrencies(requested);
            }
            catch (KeyNotFoundException)
            {
                exceptionCaught = true;
            }
            Assert.IsTrue(exceptionCaught);
        }
예제 #4
0
 public void ConvertCurrenciesTest()
 {
     try
     {
         CurrencyConverter currencyConverter   = new CurrencyConverter(_dsConfig);
         List <double>     convertedCurrencies = currencyConverter.ConvertCurrencies(_requestedCurrencies);
         double            rate = convertedCurrencies[0];
         bool res = true;
         for (int i = 0; res && i < convertedCurrencies.Count; ++i)
         {
             res &= ((convertedCurrencies[i] < _requestedCurrencies._sums[i]) &&
                     (Math.Round(convertedCurrencies[i], 2) == Math.Round(_requestedCurrencies._sums[i] * rate, 2)));
         }
         Assert.IsTrue(res);
     }
     catch (Exception e)
     {
         Assert.Fail("Failed to convert currencies, exception message: {0}", e.Message);
     }
 }