static void Main(string[] args) { var data = new List <int>(); do { Console.WriteLine("Please, type values, separated by comma..."); var input = Console.ReadLine(); data = Helper.NormalizeInput(input); } while (data.Count == 0); int[] dataAsArray = data.ToArray(); var profitCalculator = new ProfitCalculator(); if (!profitCalculator.Process(dataAsArray)) { Console.WriteLine("No profit possible or unexpected error occured during the profit calculation"); Environment.Exit(-1); } Console.WriteLine("Buy at {0} and sell at {1} for a maximum profit of {2}.", profitCalculator.GetBuyPrice(), profitCalculator.GetSellPrice(), profitCalculator.GetMaxProfit() ); }
public void TestResultFitsTaskConditions( int[] source, int buyPrice, int sellPrice, int maxProfit ) { ProfitCalculator calculator = new ProfitCalculator(); bool result = calculator.Process(source); Assert.Equal(calculator.GetBuyPrice(), buyPrice); Assert.Equal(calculator.GetSellPrice(), sellPrice); Assert.Equal(calculator.GetMaxProfit(), maxProfit); Assert.True(result); }