예제 #1
0
        public void Whole_Tens_WithDecimal_ReturnsCorrectly()
        {
            var expected = "fifty DOLLARS AND fifty three CENTS";
            var res      = ChequeWriterUtil.GetString(50.53m);

            Assert.Equal(expected, res);
        }
예제 #2
0
        public void Hundreds_ReturnsCorrectly()
        {
            var expected = "two hundred and fifty four DOLLARS";
            var res      = ChequeWriterUtil.GetString(254.00m);

            Assert.Equal(expected, res);
        }
예제 #3
0
        public void One_WithDecimal_ReturnsCorrectly()
        {
            var expected = "one DOLLAR AND fifty CENTS";
            var res      = ChequeWriterUtil.GetString(1.5m);

            Assert.Equal(expected, res);
        }
예제 #4
0
        public void Zero_ReturnsZero()
        {
            var expected = "zero";
            var res      = ChequeWriterUtil.GetString(0);

            Assert.Equal(expected, res);
        }
예제 #5
0
        public void Whole_TenBillions_WithDecimalReturnsCorrectly()
        {
            var expected = "ninety two billion DOLLARS AND fifty three CENTS";
            var res      = ChequeWriterUtil.GetString(92000000000.53m);

            Assert.Equal(expected, res);
        }
예제 #6
0
        public void TenBillions_WithDecimalReturnsCorrectly()
        {
            var expected = "ninety two billion, eight hundred and seventeen million, six hundred and twenty one thousand, two hundred and fifty four DOLLARS AND fifty three CENTS";
            var res      = ChequeWriterUtil.GetString(92817621254.53m);

            Assert.Equal(expected, res);
        }
예제 #7
0
        public void HundredThousands_ReturnsCorrectly()
        {
            var expected = "six hundred and twenty one thousand, two hundred and fifty four DOLLARS";
            var res      = ChequeWriterUtil.GetString(621254.00m);

            Assert.Equal(expected, res);
        }
예제 #8
0
        public void Above_TwoBillions_AreNotSupported()
        {
            var expected = "more than 2 billion are not supported";
            var res      = ChequeWriterUtil.GetString(2000000000.01m);

            Assert.Equal(expected, res);
        }
예제 #9
0
        public void Whole_HundredThousands_ReturnsCorrectly()
        {
            var expected = "six hundred thousand DOLLARS";
            var res      = ChequeWriterUtil.GetString(600000);

            Assert.Equal(expected, res);
        }
예제 #10
0
        public void Whole_HundredThousands_WithDecimal_ReturnsCorrectly()
        {
            var expected = "six hundred thousand DOLLARS AND fifty three CENTS";
            var res      = ChequeWriterUtil.GetString(600000.53m);

            Assert.Equal(expected, res);
        }
예제 #11
0
        public void Whole_TenThousands_ReturnsCorrectly()
        {
            var expected = "twenty thousand DOLLARS";
            var res      = ChequeWriterUtil.GetString(20000.00m);

            Assert.Equal(expected, res);
        }
예제 #12
0
        public void Thousands_WithDecimal_ReturnsCorrectly()
        {
            var expected = "one thousand, two hundred and fifty four DOLLARS AND fifty three CENTS";
            var res      = ChequeWriterUtil.GetString(1254.53m);

            Assert.Equal(expected, res);
        }
예제 #13
0
        public void Thousands_ReturnsCorrectly()
        {
            var expected = "eleven thousand DOLLARS";
            var res      = ChequeWriterUtil.GetString(11000.00m);

            Assert.Equal(expected, res);
        }
예제 #14
0
        public void WholeBillions_ReturnsCorrectly()
        {
            var expected = "one billion DOLLARS";
            var res      = ChequeWriterUtil.GetString(1000000000);

            Assert.Equal(expected, res);
        }
예제 #15
0
        public void MoreThan_2Decimals_Are_RoundedUp()
        {
            var expected = "two CENTS";
            var res      = ChequeWriterUtil.GetString(0.0150m);

            Assert.Equal(expected, res);
        }
예제 #16
0
        public void Billions_WithDecimal_ReturnsCorrectly()
        {
            var expected = "one billion, nine hundred and ninety nine million, nine hundred and ninety nine thousand, nine hundred and ninety nine DOLLARS AND ninety nine CENTS";
            var res      = ChequeWriterUtil.GetString(1999999999.99m);

            Assert.Equal(expected, res);
        }
예제 #17
0
        public void Millions_WithDecimal_ReturnsCorrectly()
        {
            var expected = "three million, six hundred and twenty one thousand, two hundred and fifty four DOLLARS AND fifty three CENTS";
            var res      = ChequeWriterUtil.GetString(3621254.53m);

            Assert.Equal(expected, res);
        }
예제 #18
0
        public void Whole_TenBillions_ReturnsCorrectly()
        {
            var expected = "ninety two billion DOLLARS";
            var res      = ChequeWriterUtil.GetString(92000000000);

            Assert.Equal(expected, res);
        }
예제 #19
0
        public void Whole_TenMillions_ReturnsCorrectly()
        {
            var expected = "seventeen million DOLLARS";
            var res      = ChequeWriterUtil.GetString(17000000);

            Assert.Equal(expected, res);
        }
예제 #20
0
        public void Decimals_ReturnsCorrectly()
        {
            var expected = "thirteen CENTS";
            var res      = ChequeWriterUtil.GetString(0.13m);

            Assert.Equal(expected, res);
        }
예제 #21
0
        public void Whole_HundredMillions_ReturnsCorrectly()
        {
            var expected = "eight hundred million DOLLARS";
            var res      = ChequeWriterUtil.GetString(800000000);

            Assert.Equal(expected, res);
        }
예제 #22
0
        public void One_ReturnsCorrectly()
        {
            var expected = "one DOLLAR";
            var res      = ChequeWriterUtil.GetString(1);

            Assert.Equal(expected, res);
        }
예제 #23
0
        public void Whole_HundredMillions_WithDecimal_ReturnsCorrectly()
        {
            var expected = "eight hundred million DOLLARS AND fifty three CENTS";
            var res      = ChequeWriterUtil.GetString(800000000.53m);

            Assert.Equal(expected, res);
        }
예제 #24
0
        public void Ones_ReturnsCorrectly()
        {
            var expected = "four DOLLARS";
            var res      = ChequeWriterUtil.GetString(4);

            Assert.Equal(expected, res);
        }
예제 #25
0
        public void OneCent_ReturnsCorrectly()
        {
            var expected = "one CENT";
            var res      = ChequeWriterUtil.GetString(0.01m);

            Assert.Equal(expected, res);
        }
예제 #26
0
        public void Whole_Tens_ReturnsCorrectly()
        {
            var expected = "fifty DOLLARS";
            var res      = ChequeWriterUtil.GetString(50m);

            Assert.Equal(expected, res);
        }
예제 #27
0
        public void HundredMillions_ReturnsCorrectly()
        {
            var expected = "eight hundred and seventeen million, six hundred and twenty one thousand, two hundred and fifty four DOLLARS";
            var res      = ChequeWriterUtil.GetString(817621254);

            Assert.Equal(expected, res);
        }
예제 #28
0
        public void Whole_Hundreds_ReturnsCorrectly()
        {
            var expected = "two hundred DOLLARS";
            var res      = ChequeWriterUtil.GetString(200.00m);

            Assert.Equal(expected, res);
        }
예제 #29
0
        static void Main(string[] args)
        {
            Console.WriteLine("--- Cheque Writer Utility ---");
            Console.WriteLine("- Enter a number up to 2 billion, with or without decimal parts");
            Console.WriteLine("- Enter 'quit' to exit");

            string input = Console.ReadLine();

            while (string.IsNullOrEmpty(input) || !input.ToLower().Equals("quit"))
            {
                decimal number = 0;
                if (!decimal.TryParse(input, out number))
                {
                    Console.WriteLine("Please enter a valid number");
                }
                else
                {
                    Console.WriteLine(ChequeWriterUtil.GetString(number));
                }

                input = Console.ReadLine();
            }
        }