public static int Run(decimal number, IConsole console) { try { // Execute var words = NumberToWords.Run(number); // Display result, capitalize first letter console.Out.WriteLine($"Result: { char.ToUpper(words[0]) }{ words.Substring(1) }"); return(0); } catch (OverflowException) { console.Out.WriteLine($"Error: { nameof(number) } is either too large or too small"); return(1); } catch (ArgumentOutOfRangeException) { console.Out.WriteLine($"Error: { nameof(number) } is too large"); return(1); } }
public void Run_WhenCalledWithNumberOutOfRange_ThrowsArgumentOutOfRangeException(decimal number) { Action actual = () => NumberToWords.Run(number); Assert.Throws <ArgumentOutOfRangeException>(actual); }
public void Run_WhenCalledWithNumberNotOutOfRange_ReturnsValidResult(decimal number, string expected) { var actual = NumberToWords.Run(number); Assert.Equal(expected, actual); }
private static void IntegerToEnglishWords() { var c = new NumberToWords(); c.Run(); }