public void FullThreeDigitTests(int num, string expected) { NumbersToWords n2w = new NumbersToWords(); string result = n2w.FullThreeDigitsToWord(num); Assert.Equal(expected, result); }
public void Under100Tests(int num, string expected) { NumbersToWords n2w = new NumbersToWords(); string result = n2w.ConvertToString(num); Assert.Equal(expected, result); }
public void DigitToWordsTests() { NumbersToWords n2w = new NumbersToWords(); string result = n2w.DigitToWord(3); Assert.Equal("three", result); }
public void TwoDigitWordsTests(int num, string expected) { NumbersToWords n2w = new NumbersToWords(); string result = n2w.TwoDigitToWord(num); Assert.Equal(expected, result); }
public void NumbersToWords_HundredThousands_NineHundredNinetythousandnineHundreNinetyNine() { int userInput = 999999; string output = NumbersToWords.Numbers2Words(userInput); Assert.AreEqual(output, "nine hundred ninety nine thousand nine hundred ninety nine"); }
private void textBox_amountNumeric_TextChanged(object sender, TextChangedEventArgs e) { try { textBox_amountText.Text = "*** " + NumbersToWords.decimalNumberToWords(textBox_amountNumeric.Text) + " ***"; } catch (Exception) { } }
public void ConvertOneDigit() { NumbersToWords numbersToWords = new NumbersToWords(); String result = numbersToWords.Convert(5); Assert.AreEqual("five", result); }
public void SetGetUserNumber_SetsGetsUserNumber_Int() { NumbersToWords newObject = new NumbersToWords(); newObject.SetUserNumber("1"); Assert.AreEqual("1", newObject.GetUserNumber()); }
public void Convert_Extra_Words_To_Numbers(string expected, int num, string message) { NumbersToWords ntw = new NumbersToWords(); string actual = ntw.Convert(num); Assert.AreEqual(expected, actual, message); }
public void NumbersToWords_Teens_Ten() { int userInput = 19; string output = NumbersToWords.Numbers2Words(userInput); Assert.AreEqual(output, "nineteen"); }
public void NumbersToWords_Tens_NinetyNine() { int userInput = 99; string output = NumbersToWords.Numbers2Words(userInput); Assert.AreEqual(output, "ninety nine"); }
static void Main(string[] args) { var cultureInfo = new CultureInfo("en-US"); CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; var numbersToWords = new NumbersToWords(); decimal dec_number; string input = ""; string result = ""; Console.WriteLine("Input the Number:"); input = Convert.ToString(Console.ReadLine()); if (decimal.TryParse(input, out dec_number)) { numbersToWords.NumberTobeConverted = dec_number; result = numbersToWords.ConvertToWord(); Console.WriteLine($"The result is : {result}"); } else { Console.WriteLine("Please input the valid number."); } Console.ReadKey(); }
public void Convert_Triple_Digit_Numbers_To_Words(int num, string expected, string message) { NumbersToWords ntw = new NumbersToWords(); string actual = ntw.Convert(num); Assert.AreEqual(expected, actual, message); }
public void GetIncrementNumberCounter_GetsIncrementsNumberCounter_Int() { NumbersToWords newObject = new NumbersToWords(); newObject.IncrementNumberCounter(); Assert.AreEqual(1, newObject.GetNumberCounter()); }
public void InputToChars_CreateCharsFromUserInput_Char() { NumbersToWords newObject = new NumbersToWords(); newObject.SetUserNumber("123"); char[] numbersSplit = { '1', '2', '3' }; CollectionAssert.AreEqual(numbersSplit, newObject.InputToChars()); }
public void Convert_1_Digit_Number_0_To_Zero() { //Arrange NumbersToWords numsToWords = new NumbersToWords(); //Act string word = numsToWords.Convert(0); //Assert Assert.AreEqual("zero", word, "0 returns zero"); }
public void CreateDictionaries_CreatesAllDictionaries_String() { NumbersToWords newObject = new NumbersToWords(); newObject.CreateOnesDictionary(); newObject.CreateTensDictionary(); newObject.CreateTeensDictionary(); newObject.CreateModifierDictionary(); Assert.AreEqual("one", newObject.GetOnesValue(1)); Assert.AreEqual("thirteen", newObject.GetTeensValue(3)); Assert.AreEqual("forty", newObject.GetTensValue(4)); Assert.AreEqual("million", newObject.GetModifierValue(7)); }
static void Main(string[] args) { double a = 22, b = 203962000.1, c = 1; var ntw = new NumbersToWords(new NTW_AM()); var ntwr = new NumbersToWords(new NTW_RU()); var ntwen = new NumbersToWords(new NTW_EN()); MessageBox.Show(string.Format("{0}\n{1}\n{2}\n", ntw.Transform(a, NTW_AM.Dollars), ntw.Transform(b, NTW_AM.Dollars), ntw.Transform(c, NTW_AM.Dollars))); MessageBox.Show(string.Format("{0}\n{1}\n{2}\n", ntwr.Transform(a, NTW_RU.Dollars), ntwr.Transform(b, NTW_RU.Dollars), ntwr.Transform(c, NTW_RU.Dollars))); MessageBox.Show(string.Format("{0}\n{1}\n{2}\n", ntwen.Transform(a, NTW_EN.Dollars), ntwen.Transform(b, NTW_EN.Dollars), ntwen.Transform(c, NTW_EN.Dollars))); Console.ReadLine(); }
public void SetGetChunksOfThreeNumbers_SetsAndGetsChunksOfThreeNumbers_List() { NumbersToWords newObject = new NumbersToWords(); List <char> numbers = new List <char>() { '1', '2', '3' }; List <List <char> > listOfNumbers = new List <List <char> >() { numbers }; newObject.AddChunksOfNumbers(numbers); CollectionAssert.AreEqual(listOfNumbers, newObject.GetChunksOfThreeNumbers()); }
public void ConvertToString() { //Tests for 0 through 99 NumbersToWords test = new NumbersToWords(); Assert.AreEqual("twenty", test.ConvertToWords(20)); Assert.AreEqual("thirty seven", test.ConvertToWords(37)); Assert.AreEqual("eighty four", test.ConvertToWords(84)); Assert.AreEqual("thirty seven", test.ConvertToWords(37)); Assert.AreEqual("five", test.ConvertToWords(5)); Assert.AreEqual("zero", test.ConvertToWords(0)); //Tests 100 through 999 Assert.AreEqual("one hundred and twenty five", test.ConvertToWords(125)); Assert.AreEqual("one hundred", test.ConvertToWords(100)); Assert.AreEqual("nine hundred and ninety nine", test.ConvertToWords(999)); //Tests 1000 through 9999)); Assert.AreEqual("one thousand two hundred and twenty five", test.ConvertToWords(1225)); Assert.AreEqual("nine thousand nine hundred and ninety five", test.ConvertToWords(9995)); //Tests 10,000 through 99,999 Assert.AreEqual("ten thousand", test.ConvertToWords(10000)); Assert.AreEqual("twelve thousand", test.ConvertToWords(12000)); Assert.AreEqual("fifteen thousand", test.ConvertToWords(15000)); Assert.AreEqual("ninety nine thousand", test.ConvertToWords(99000)); Assert.AreEqual("forty seven thousand one hundred and twenty five", test.ConvertToWords(47125)); //***These numbers from the instructions are not grammatically correct*** //eight hundred and three thousand and three hundred and eight //nine hundred and ninetynine thousand and nine-hundred and ninety-nine //Tests 100,000 through 999,999 Assert.AreEqual("four hundred and fifty three thousand six hundred and seventy two", test.ConvertToWords(453672)); Assert.AreEqual("nine hundred and sixty seven thousand four hundred and fifty eight", test.ConvertToWords(967458)); Assert.AreEqual("five hundred thousand", test.ConvertToWords(500000)); Assert.AreEqual("eight hundred and three thousand", test.ConvertToWords(803000)); Assert.AreEqual("three hundred and eight", test.ConvertToWords(308)); Assert.AreEqual("nine hundred and ninety nine thousand nine hundred and ninety nine", test.ConvertToWords(999999)); }
public void NumbersWordsTest() { NumbersToWords thisNumbersToWords = new NumbersToWords(); Assert.AreEqual("zero", thisNumbersToWords.OutputWords(0)); Assert.AreEqual("nine", thisNumbersToWords.OutputWords(9)); Assert.AreEqual("fifteen", thisNumbersToWords.OutputWords(15)); Assert.AreEqual("twenty", thisNumbersToWords.OutputWords(20)); Assert.AreEqual("thirty-three", thisNumbersToWords.OutputWords(33)); Assert.AreEqual("one hundred", thisNumbersToWords.OutputWords(100)); Assert.AreEqual("one hundred and one", thisNumbersToWords.OutputWords(101)); Assert.AreEqual("one hundred and twenty-one", thisNumbersToWords.OutputWords(121)); Assert.AreEqual("nine hundred", thisNumbersToWords.OutputWords(900)); Assert.AreEqual("two thousand", thisNumbersToWords.OutputWords(2000)); Assert.AreEqual("five thousand, two hundred and forty-seven", thisNumbersToWords.OutputWords(5247)); Assert.AreEqual("eleven thousand", thisNumbersToWords.OutputWords(11000)); Assert.AreEqual("thirty-three thousand", thisNumbersToWords.OutputWords(33000)); Assert.AreEqual("sixty-nine thousand, nine hundred and ten", thisNumbersToWords.OutputWords(69910)); Assert.AreEqual("one hundred thousand", thisNumbersToWords.OutputWords(100000)); Assert.AreEqual("two hundred thirty-four thousand, six hundred and fifty-four", thisNumbersToWords.OutputWords(234654)); }
private void testparam(string parInput, string parExpectedResult) { NumbersToWords numbersToWords = new NumbersToWords(); decimal dec_number; //try //{ // d = decimal.Parse(parInput, CultureInfo.InvariantCulture); // x.NumberTobeConverted = d; // Assert.AreEqual(parExpectedResult, x.ConvertToWord(), "Result is not matched."); //} //catch (System.Exception) //{ // throw; //} if (decimal.TryParse(parInput, NumberStyles.Any, new CultureInfo("en-US"), out dec_number)) { numbersToWords.NumberTobeConverted = dec_number; Assert.AreEqual(parExpectedResult, numbersToWords.ConvertToWord(), "Result is not matched."); } }
/// <summary> /// Extension Method used to Convert Int into world /// </summary> /// <param name="number"></param> /// <returns></returns> public static string ToWords(this Int64 number) { var numbertoWords = new NumbersToWords(); return(numbertoWords.IntToWords(number)); }
public void NumbersToWordsTest() { NumbersToWords numberInputTest = new NumbersToWords(); string[] numberWordArray = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; for (int i = 0; i < 20; i++) { Assert.AreEqual(numberWordArray[i], numberInputTest.ConvertToWords(i)); } Assert.AreEqual("twenty", numberInputTest.ConvertToWords(20)); Assert.AreEqual("twenty-one", numberInputTest.ConvertToWords(21)); Assert.AreEqual("thirty", numberInputTest.ConvertToWords(30)); Assert.AreEqual("forty", numberInputTest.ConvertToWords(40)); Assert.AreEqual("fifty", numberInputTest.ConvertToWords(50)); Assert.AreEqual("sixty", numberInputTest.ConvertToWords(60)); Assert.AreEqual("seventy", numberInputTest.ConvertToWords(70)); Assert.AreEqual("eighty", numberInputTest.ConvertToWords(80)); Assert.AreEqual("ninety-nine", numberInputTest.ConvertToWords(99)); Assert.AreEqual("three hundred", numberInputTest.ConvertToWords(300)); Assert.AreEqual("three hundred and one", numberInputTest.ConvertToWords(301)); Assert.AreEqual("four hundred and thirteen", numberInputTest.ConvertToWords(413)); Assert.AreEqual("three hundred and twenty-one", numberInputTest.ConvertToWords(321)); Assert.AreEqual("four thousand", numberInputTest.ConvertToWords(4000)); Assert.AreEqual("four thousand and six", numberInputTest.ConvertToWords(4006)); Assert.AreEqual("four thousand and sixteen", numberInputTest.ConvertToWords(4016)); Assert.AreEqual("four thousand and twenty-six", numberInputTest.ConvertToWords(4026)); Assert.AreEqual("four thousand and three hundred", numberInputTest.ConvertToWords(4300)); Assert.AreEqual("four thousand and three hundred and six", numberInputTest.ConvertToWords(4306)); Assert.AreEqual("four thousand and three hundred and sixteen", numberInputTest.ConvertToWords(4316)); Assert.AreEqual("four thousand and two hundred and sixty-six", numberInputTest.ConvertToWords(4266)); Assert.AreEqual("ten thousand", numberInputTest.ConvertToWords(10000)); Assert.AreEqual("eighteen thousand and six", numberInputTest.ConvertToWords(18006)); Assert.AreEqual("thirty-three thousand", numberInputTest.ConvertToWords(33000)); Assert.AreEqual("thirty-three thousand and one", numberInputTest.ConvertToWords(33001)); Assert.AreEqual("thirty-three thousand and eighteen", numberInputTest.ConvertToWords(33018)); Assert.AreEqual("thirty-three thousand and twenty-eight", numberInputTest.ConvertToWords(33028)); Assert.AreEqual("thirty-three thousand and one hundred", numberInputTest.ConvertToWords(33100)); Assert.AreEqual("thirty-three thousand and one hundred and one", numberInputTest.ConvertToWords(33101)); Assert.AreEqual("thirty-three thousand and one hundred and thirteen", numberInputTest.ConvertToWords(33113)); Assert.AreEqual("thirty-three thousand and one hundred and forty-five", numberInputTest.ConvertToWords(33145)); Assert.AreEqual("one hundred thousand", numberInputTest.ConvertToWords(100000)); Assert.AreEqual("one hundred and one thousand", numberInputTest.ConvertToWords(101000)); Assert.AreEqual("one hundred and eleven thousand", numberInputTest.ConvertToWords(111000)); Assert.AreEqual("three hundred and thirteen thousand", numberInputTest.ConvertToWords(313000)); Assert.AreEqual("three hundred and twenty-three thousand", numberInputTest.ConvertToWords(323000)); Assert.AreEqual("one hundred thousand and one", numberInputTest.ConvertToWords(100001)); Assert.AreEqual("one hundred thousand and eighteen", numberInputTest.ConvertToWords(100018)); Assert.AreEqual("one hundred thousand and twenty-one", numberInputTest.ConvertToWords(100021)); Assert.AreEqual("three hundred and twenty-three thousand and one hundred", numberInputTest.ConvertToWords(323100)); Assert.AreEqual("three hundred and twenty-three thousand and one hundred and one", numberInputTest.ConvertToWords(323101)); Assert.AreEqual("three hundred and twenty-three thousand and one hundred and eighteen", numberInputTest.ConvertToWords(323118)); Assert.AreEqual("three hundred and twenty-three thousand and six hundred and forty-five", numberInputTest.ConvertToWords(323645)); }
public void Initialize() { newObject = new NumbersToWords(); }
public void From_1000_To_99999_Test(string expected, int number) { string words = new NumbersToWords().From1000To999999(number); Assert.AreEqual(expected, words); }
public void SetUp() { _numbersToWords = new NumbersToWords(); }