Ejemplo n.º 1
0
        public void FizzBuzz_Returns_Number_When_Value_Is_Not_Divisible_By_3()
        {
            var fizzBuzz = new FizzBuzz();
            fizzBuzz.AddPair(3, "Fizz");
            fizzBuzz.AddPair(5, "Buzz");

            Assert.AreEqual("1", fizzBuzz.Execute(1, 1).First());
            Assert.AreEqual("13", fizzBuzz.Execute(13, 13).First());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WindowWidth = 120;

            var fizzBuzz = new FizzBuzz();

            Console.WriteLine("Enter a number/word pair.  Separate the number and word by a comma.  Then press enter.  i.e. 3,Fizz");
            Console.WriteLine("When you are done entering values, simply press enter without entering any value.");

            while (true)
            {
                string value = Console.ReadLine();
                if (string.IsNullOrEmpty(value))
                {
                    break;
                }

                var pair = ParseValue(value);

                if (pair.HasValue)
                {
                    fizzBuzz.Pairs.Add(pair.Value.Key, pair.Value.Value);
                }
            }

            foreach (string value in fizzBuzz.Execute(1, 100))
            {
                Console.WriteLine(value);
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
Ejemplo n.º 3
0
        public void FizzBuzz_Returns_Fizz_When_Value_Is_Divisible_By_3()
        {
            var fizzBuzz = new FizzBuzz();
            fizzBuzz.AddPair(3, "Fizz");

            Assert.AreEqual("Fizz", fizzBuzz.Execute(3, 3).First());
        }
Ejemplo n.º 4
0
        public void Exception_Thrown_When_Upper_Is_Less_Than_Lower()
        {
            var fizzBuzz = new FizzBuzz();
            fizzBuzz.AddPair(3, "Fizz");

            Assert.AreEqual("Buzz", fizzBuzz.Execute(5, 4).First());
        }