예제 #1
0
        public void TestSingleDigit()
        {
            string test = "One";

            Assert.IsTrue(TextToNumber.IsValid(test));
            Assert.AreEqual(string.Empty, TextToNumber.Error);
            Assert.AreEqual(1, TextToNumber.DoConvert(test));
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
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);
        }
예제 #10
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);
        }