public void CONVERT_1_ONE() { ConvertToWords convertToWords = new ConvertToWords(); // Input int number = 2110; string experatedValue = "Two thousand one hundred ten".ToUpper(); // Test string result = convertToWords.Convert(number).ToUpper(); // Assert Assert.AreEqual(experatedValue, result); }
//[TestMethod] public void TestMethod1() { ConvertToWords convertToWords = new ConvertToWords(); // Input int number = 745; string experatedValue = "seven hundred and fourty five"; // Test string result = convertToWords.Convert(number); // Assert Assert.AreEqual(experatedValue, result); }
public string Get(string name, string currency) { var model = new NameCurrencyModel(); if (string.IsNullOrWhiteSpace(name)) { model.ErrorMessage = Constants.RequiredName; return(GetJsonModel(model)); } if (!IsValidName(name)) { model.ErrorMessage = Constants.InvalidName; return(GetJsonModel(model)); } string isNegative = ""; double number; if (!double.TryParse(currency, out number)) { model.ErrorMessage = Constants.InvalidCurrency; return(GetJsonModel(model)); } if (currency.Contains("-")) { isNegative = "MINUS "; currency = currency.Substring(1, currency.Length - 1); } if (currency == "0") { model.Currency = "ZERO DOLLAR"; } else { var wordFormat = ConvertToWords.ConvertNumber(currency); if (wordFormat == Constants.ErrorNotSupported || wordFormat == Constants.InvalidCurrency) { model.ErrorMessage = wordFormat; return(GetJsonModel(model)); } else { model.Currency = isNegative + wordFormat; } } model.Name = name.ToUpper().Trim(); return(GetJsonModel(model)); }