コード例 #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();
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }