public void expect_exception_when_there_is_no_lender_offer() { QuoteFinder quoteFinder = new QuoteFinder(36); var emptyMarketData = new List <MarketData>(); var externalArgument = new ArgumentModel() { RequestedAmount = 1000 }; Exception exception = null; try { quoteFinder.GetQuote(externalArgument, emptyMarketData); } catch (Exception e) { exception = e; } var isTrue = CheckException(exception, ErrorMessage.ThereIsNoAvailableOffer); Assert.IsTrue(isTrue); }
public void expect_exception_when_requested_amount_is_out_of_range() { QuoteFinder quoteFinder = new QuoteFinder(36); var emptyMarketData = new List <MarketData>(); var externalArgument = new ArgumentModel() { RequestedAmount = 500 }; Exception exception = null; try { quoteFinder.GetQuote(externalArgument, emptyMarketData); } catch (Exception e) { exception = e; } var isTrue = CheckException(exception, ErrorMessage.RequestedAmountOutOfRange); Assert.IsTrue(isTrue); }
public void expect_exception_when_requested_amount_is_not_multiple_of_100() { QuoteFinder quoteFinder = new QuoteFinder(36); var emptyMarketData = new List <MarketData>(); var externalArgument = new ArgumentModel() { RequestedAmount = 1010 }; Exception exception = null; try { quoteFinder.GetQuote(externalArgument, emptyMarketData); } catch (Exception e) { exception = e; } var isTrue = CheckException(exception, ErrorMessage.RequestedAmountIsNotMultipleOf100); Assert.IsTrue(isTrue); }
private static void Main(string[] args) { try { if (args.Length != 2) { throw new ArgumentException(ErrorMessage.MissingArgument); } // change current culture with en-GB ChangeCurrentCulture(); // parse arguments var argumentModel = ParseArguments(args); // load market data var fetchMarketData = FileHelper.GetLenderMarketData(argumentModel.MarketDataFilePath); // order lender offer with rate ascending and available descending fetchMarketData = fetchMarketData.OrderBy(m => m.Rate).ThenByDescending(m => m.Available).ToList(); var paymentCalculation = new QuoteFinder(Terms); // find result var result = paymentCalculation.GetQuote(argumentModel, fetchMarketData); // print result PrintResult(result); Console.Read(); } catch (Exception e) { // print error message Console.WriteLine(e.Message); } }