Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter a number to spell!");
            Console.Write("> ");

            string input;

            do
            {
                input = Console.ReadLine();

                long number;
                while (!long.TryParse(input, out number))
                {
                    Console.WriteLine("Invalid number! Try again!");
                    Console.Write("> ");
                    input = Console.ReadLine();
                }

                INumberSpeller speller = new BgNumberSpeller();

                string numberInWords = speller.Spell(number, Gender.Female);

                Console.WriteLine(numberInWords);
                Console.Write("> ");
            }while (input.ToUpper() != "EXIT");

            Console.ReadLine();
        }
        private void SetTottalSlovom(DocumentView documentView)
        {
            var TottalString = documentView.Tottal.ToString("F2").Split('.');
            var words        = new BgNumberSpeller().Spell(long.Parse(TottalString[0]));
            var result       = $"{words} лева и {TottalString[1]} ст.";

            documentView.TottalSlovom = result;
        }
Example #3
0
        public void Spell_ThreeDigitNumbers_Correctly(long number, string expected)
        {
            // Arrange
            var sut = new BgNumberSpeller();

            // Act
            string inWords = sut.Spell(number);

            // Assert
            Assert.AreEqual(expected, inWords);
        }
Example #4
0
        public void Spell_Negative_Numbers_Correctly(long number, string result)
        {
            // Arrange
            var sut = new BgNumberSpeller();

            // Act
            string inWords = sut.Spell(number);

            // Assert
            Assert.AreEqual(result, inWords);
        }
Example #5
0
        public void Spell_Positive_Numbers_Using_FemaleGender_Correctly(long number, string result)
        {
            // Arrange
            var sut = new BgNumberSpeller();

            // Act
            string inWords = sut.Spell(number, Gender.Female);

            // Assert
            Assert.AreEqual(result, inWords);
        }
Example #6
0
        public void Spell_MaxAndMinLongNumber(long number, string expected)
        {
            // Arrange
            var sut = new BgNumberSpeller();

            // Act
            string inWords = sut.Spell(number);

            // Assert
            Assert.AreEqual(expected, inWords);
        }
Example #7
0
        public void Spell_Positive_Numbers_From_100_UpTo_999_Correctly(long number, Gender gender, string result)
        {
            // Arrange
            var sut = new BgNumberSpeller();

            // Act
            string inWords = sut.SpellOrdinal(number, gender);

            // Assert
            Assert.AreEqual(result, inWords);
        }