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); }
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); } }
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); }
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); } }