예제 #1
0
        public void can_throw_exception_on_bad_multiple()
        {
            var fizzer = new FizzBuzzOmatic();

            Assert.Throws <ArgumentException>(() => fizzer.Add(0, "Zero"));
            Assert.Throws <ArgumentException>(() => fizzer.Add(-1, "Less than One"));
        }
예제 #2
0
        public void can_solve_classic_fizzbuzz_backwards()
        {
            var fizzer = new FizzBuzzOmatic();

            fizzer.Add(3, "Fizz");
            fizzer.Add(5, "Buzz");

            var result = fizzer.ProduceRange(100, 1);

            var expected = FizzBuzzCsvFile.Read <FizzBuzzCsvFile.FizzBuzzDataRecord>(Path.Combine("Data", "FizzBuzzData.csv")).Reverse();

            Assert.Equal(expected, result);
        }
예제 #3
0
        public void can_solve_classic_fizzbuzz()
        {
            var fizzer = new FizzBuzzOmatic();

            fizzer.Add(3, "Fizz");
            fizzer.Add(5, "Buzz");

            var result = fizzer.ProduceRange(1, 100);

            var expected = FizzBuzzCsvFile.Read <FizzBuzzCsvFile.FizzBuzzDataRecord>(Path.Combine("Data", "FizzBuzzData.csv"));

            Assert.Equal(expected.ToArray(), result.ToArray());
        }
예제 #4
0
        public void can_solve_super_fizzbuzz()
        {
            var fizzer = new FizzBuzzOmatic();

            fizzer.Add(3, "Fizz");
            fizzer.Add(7, "Buzz");
            fizzer.Add(38, "Bazz");

            var result = fizzer.ProduceRange(-12, 145);

            var expected = FizzBuzzCsvFile.Read <FizzBuzzCsvFile.SuperFizzBizzDataRecord>(Path.Combine("Data", "SuperFizzBuzzData.csv"));

            Assert.Equal(expected.ToArray(), result.ToArray());
        }
예제 #5
0
        static void Main(string[] args)
        {
            var fizz = new FizzBuzzOmatic();

            fizz.Add(3, "Fizz")
            .Add(5, "Buzz");

            var results = fizz.ProduceRange(1, 100);

            Console.WriteLine("ClassicFizzBuzz: from 1 to 100");
            foreach (var item in results)
            {
                Console.WriteLine(item);
            }
        }
예제 #6
0
        public void can_handle_enumerable_sequence()
        {
            var fizzer = new FizzBuzzOmatic();

            fizzer.Add(3, "Fizz")
            .Add(5, "Buzz");

            var results = fizzer.ProduceSequence(Enumerable.Range(1, 5));

            var expected = new[]
            {
                "1", "2", "Fizz", "4", "Buzz"
            };

            Assert.Equal(expected, results);
        }
예제 #7
0
        public void can_handle_arbitrary_indices()
        {
            var fizzer = new FizzBuzzOmatic();

            fizzer.Add(3, "Fizz")
            .Add(5, "Buzz");

            var results = fizzer.ProduceSequence(3, 5, 15, 1, 2);

            var expected = new[]
            {
                "Fizz", "Buzz", "FizzBuzz", "1", "2"
            };

            Assert.Equal(expected, results);
        }
예제 #8
0
        static void Main(string[] args)
        {
            var fizz = new FizzBuzzOmatic();

            fizz.Add(3, "Fizz")
            .Add(7, "Buzz")
            .Add(38, "Bazz");

            var results = fizz.ProduceRange(-12, 145);

            Console.WriteLine("SuperFizzBuzz: from -12 to 145");
            foreach (var item in results)
            {
                Console.WriteLine(item);
            }
        }
예제 #9
0
        public void can_handle_unsorted_messages()
        {
            var fizzer = new FizzBuzzOmatic();

            fizzer.Add(4, "Frog");
            fizzer.Add(13, "Duck");
            fizzer.Add(9, "Chicken");

            var resultFrogDuckChicken = fizzer.ProduceRange(468, 468);
            var resultFrogDuck        = fizzer.ProduceRange(52, 52);
            var resultFrogChicken     = fizzer.ProduceRange(36, 36);
            var resultDuckChicken     = fizzer.ProduceRange(13 * 9, 13 * 9);

            Assert.Equal("FrogDuckChicken", resultFrogDuckChicken.FirstOrDefault());
            Assert.Equal("FrogDuck", resultFrogDuck.FirstOrDefault());
            Assert.Equal("FrogChicken", resultFrogChicken.FirstOrDefault());
            Assert.Equal("DuckChicken", resultDuckChicken.FirstOrDefault());
        }
예제 #10
0
        public void can_throw_exception_on_bad_message()
        {
            var fizzer = new FizzBuzzOmatic();

            Assert.Throws <ArgumentNullException>(() => fizzer.Add(10, null));
        }
예제 #11
0
        public void can_create()
        {
            var fizzer = new FizzBuzzOmatic();

            Assert.NotNull(fizzer);
        }