Ejemplo n.º 1
0
        private static async Task <bool> Calculate(AnnualFeeCalculator calculator, string input)
        {
            var isValid = ProcessUserInput(input, out bool toExit, out int consumption);

            if (!toExit && isValid)
            {
                try
                {
                    var fees = await calculator.CalculateAnnualFee(consumption);

                    PrintResult(fees, calculator.CurrencySymbol);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Console.WriteLine("Problem happened: {0}", ex.Message);
                }
            }

            return(toExit);
        }
 public void ShouldThrowExceptionForIncorrectParameter()
 {
     Assert.Throws <ArgumentOutOfRangeException>(async() => await calculator.CalculateAnnualFee(-1));
 }