public void HonorAnyCustomFizzBuzzRules()
        {
            var range = new FizzBuzzRange
            {
                Start = 1,
                End   = 6
            };

            var expectedResult = new List <string> {
                "1", "2", "Foo", "4", ""
            };
            var rules = new List <IFizzBuzzRule> {
                new FooFizzBuzzRule(), new DefaultFizzBuzzRule()
            };

            var fizzBuzz = new FizzBuzz(rules);

            IList <string> result = fizzBuzz.ProcessNumbers(range);

            Assert.AreEqual(expectedResult.Count, result.Count);
            for (int i = 0; i < expectedResult.Count; ++i)
            {
                Assert.AreEqual(expectedResult[i], result[i]);
            }
        }
        public void ThrowAnExceptionIfTheRangeIsInvalid()
        {
            var range = new FizzBuzzRange
            {
                Start = 12,
                End   = 5
            };

            Assert.Throws <ArgumentException>(() => _fizzBuzz.ProcessNumbers(range));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            FizzBuzz      fizzBuzz = new FizzBuzz();
            FizzBuzzRange range    = new FizzBuzzRange
            {
                Start = 1,
                End   = 101
            };

            IList <string> result = fizzBuzz.ProcessNumbers(range);

            Console.WriteLine(String.Join(Environment.NewLine, result));

            Console.Read();
        }
        public void ReturnTheExpectedList(int start, int end, IList <string> expectedResults)
        {
            var range = new FizzBuzzRange
            {
                Start = start,
                End   = end
            };

            IList <string> result = _fizzBuzz.ProcessNumbers(range);

            Assert.AreEqual(expectedResults.Count, result.Count);
            for (int i = 0; i < expectedResults.Count; ++i)
            {
                Assert.AreEqual(expectedResults[i], result[i]);
            }
        }