Exemple #1
0
        public void Test159000AndAtEndNoDigit()
        {
            string test = "one Hundred and fifty nine thousand and";

            Assert.IsFalse(TextToNumber.IsValid(test), TextToNumber.Error);
            Assert.AreEqual("The last word can not be 'and' most be followed by a number word\r\n", TextToNumber.Error);
        }
Exemple #2
0
        public void Test159000DoubleAndDigit()
        {
            string test = "one Hundred and and fifty nine thousand";

            Assert.IsFalse(TextToNumber.IsValid(test), TextToNumber.Error);
            Assert.AreEqual("Can not repeat and\r\nExpecting a number word rather than : and\r\n", TextToNumber.Error);
        }
Exemple #3
0
        public void TestSingleDigit()
        {
            string test = "One";

            Assert.IsTrue(TextToNumber.IsValid(test));
            Assert.AreEqual(string.Empty, TextToNumber.Error);
            Assert.AreEqual(1, TextToNumber.DoConvert(test));
        }
Exemple #4
0
        public void Test57Digit()
        {
            string test = "Fifty seven";

            Assert.IsTrue(TextToNumber.IsValid(test), TextToNumber.Error);
            Assert.AreEqual(string.Empty, TextToNumber.Error);
            Assert.AreEqual(57, TextToNumber.DoConvert(test));
            Assert.AreEqual(string.Empty, TextToNumber.Error);
        }
Exemple #5
0
        public void TestTenDigit()
        {
            string test = "forty";

            Assert.IsTrue(TextToNumber.IsValid(test));
            Assert.AreEqual(string.Empty, TextToNumber.Error);
            Assert.AreEqual(40, TextToNumber.DoConvert(test));
            Assert.AreEqual(string.Empty, TextToNumber.Error);
        }
Exemple #6
0
        public void TestMultipleTeens()
        {
            string test = "Fourteen twelve";

            Assert.IsFalse(TextToNumber.IsValid(test));
            Assert.AreEqual("Did not expect the word type of teens or tens in the position of second digit for twelve\r\n", TextToNumber.Error);
            Assert.AreEqual(0, TextToNumber.DoConvert(test));
            Assert.AreEqual("Did not expect the word type of teens or tens in the position of second digit for twelve\r\n", TextToNumber.Error);
        }
Exemple #7
0
        public void TestMultipleDigit()
        {
            string test = "One two";

            Assert.IsFalse(TextToNumber.IsValid(test));
            Assert.AreEqual("Second digit is not valid two\r\n", TextToNumber.Error);
            Assert.AreEqual(0, TextToNumber.DoConvert(test));
            Assert.AreEqual("Second digit is not valid two\r\n", TextToNumber.Error);
        }
Exemple #8
0
        public void Test159000Digit()
        {
            string test = "one Hundred and fifty nine thousand";

            Assert.IsTrue(TextToNumber.IsValid(test), TextToNumber.Error);
            Assert.AreEqual(string.Empty, TextToNumber.Error);
            Assert.AreEqual(159000, TextToNumber.DoConvert(test));
            Assert.AreEqual(string.Empty, TextToNumber.Error);
        }
Exemple #9
0
        public void TestHundredWithTeens()
        {
            string test = "seventeen Hundred thousand million";

            Assert.IsFalse(TextToNumber.IsValid(test));
            Assert.AreEqual("The Hundred can only follow a digit word\r\n", TextToNumber.Error);
            Assert.AreEqual(0, TextToNumber.DoConvert(test));
            Assert.AreEqual("The Hundred can only follow a digit word\r\n", TextToNumber.Error);
        }
Exemple #10
0
        public void Test10010001000000Digit()
        {
            string test = "one Hundred thousand million";

            Assert.IsTrue(TextToNumber.IsValid(test));
            Assert.AreEqual(string.Empty, TextToNumber.Error);
            Assert.AreEqual(100000000000, TextToNumber.DoConvert(test));
            Assert.AreEqual(string.Empty, TextToNumber.Error);
        }
Exemple #11
0
        public void Test157DigitWithNoFirstDigit()
        {
            string test = "Hundred and Fifty seven";

            Assert.IsFalse(TextToNumber.IsValid(test), TextToNumber.Error);
            Assert.AreEqual("Expecting a number word rather than : hundred\r\nExpecting a number word rather than : and\r\n", TextToNumber.Error);
            Assert.AreEqual(0, TextToNumber.DoConvert(test));
            Assert.AreEqual("Expecting a number word rather than : hundred\r\nExpecting a number word rather than : and\r\n", TextToNumber.Error);
        }
Exemple #12
0
        public void Test7_50Digit()
        {
            string test = "seven Fifty";

            Assert.IsFalse(TextToNumber.IsValid(test), TextToNumber.Error);
            Assert.AreEqual("Did not expect the word type of teens or tens in the position of second digit for fifty\r\n", TextToNumber.Error);
            Assert.AreEqual(0, TextToNumber.DoConvert(test));
            Assert.AreEqual("Did not expect the word type of teens or tens in the position of second digit for fifty\r\n", TextToNumber.Error);
        }
Exemple #13
0
 public void TestBlankTextInvalid()
 {
     Assert.IsFalse(TextToNumber.IsValid(string.Empty));
 }