Ejemplo n.º 1
0
        public void TestFirstFifteenLines()
        {
            var firstFifteenLines = new[]
            {
                "1",
                "2",
                "Fizz",
                "4",
                "Buzz",
                "Fizz",
                "7",
                "8",
                "Fizz",
                "Buzz",
                "11",
                "Fizz",
                "13",
                "14",
                "FizzBuzz"
            };

            var actualLines = FizzBuzzSolver.Solve(15);

            var counter = 0;

            foreach (var line in firstFifteenLines)
            {
                Assert.AreEqual(line, actualLines[counter]);
                counter++;
            }

            Assert.AreEqual(15, actualLines.Count);
        }
Ejemplo n.º 2
0
        public void TestLastLine(int solveFor, string expectedLastLine)
        {
            var lines = FizzBuzzSolver.Solve(solveFor);

            Assert.AreEqual(expectedLastLine, lines.Last());
            Assert.AreEqual(lines.Count, solveFor);
        }
    static void Main()
    {
        int            fizz       = 3;   // int.Parse(Console.ReadLine());
        int            buzz       = 5;   // int.Parse(Console.ReadLine());
        int            iterations = 100; //int.Parse(Console.ReadLine());
        int            fizzbuzz   = fizz * buzz;
        int            quotient   = Math.DivRem(iterations, fizzbuzz, out var remainder);
        FizzBuzzSolver fb         = new FizzBuzzSolver(fizz, buzz, iterations, fizzbuzz, quotient, remainder);

        switch (quotient)
        {
        case 0: fb.Solve(RemainderFizzBuzz); break;

        case 1: fb.Solve(NormalFizzBuzz);  break;

        default: fb.Solve(CachedFizzBuzz); break;
        }
        ;

        Console.Read();
    }