protected override void Execute(CodeActivityContext context) { string numberString = string.Empty; if (IntNumber.Expression != null) { numberString = IntNumber.Get(context).ToString(); } else if (LongNumber.Expression != null) { numberString = LongNumber.Get(context).ToString(); } else if (StringNumber.Expression != null) { numberString = StringNumber.Get(context).ToString(); } else { throw new ArgumentException("No input argument was filled."); } string converted = NumberConversor.Convert(numberString); SpelledInNumber.Set(context, converted); }
static void Main(string[] args) { bool exit = false; while (!exit) { Console.Write("Type a number: "); try { string numberStr = Console.ReadLine(); if (string.IsNullOrWhiteSpace(numberStr)) { exit = true; break; } Console.WriteLine(NumberConversor.Convert(numberStr.ToCharArray())); } catch (ArgumentException) { } } }
public void NumberConversor_Millions(long number, string expected) { Assert.AreEqual(expected, NumberConversor.Convert(number)); }
public void NumberConversor_Thousands(int number, string expected) { Assert.AreEqual(expected, NumberConversor.Convert(number)); }
public void NumberConversor_EarlyTens(int number, string expected) { Assert.AreEqual(expected, NumberConversor.Convert(number)); }