示例#1
0
 public void Setup()
 {
     _output = new StringWriter();
     _fizzBuzzWriter = new FizzBuzzWriter(_output, new DefaultNumberRule());
     _fizzBuzzWriter.Configure(new DivisibleByRule(3, "Fizz"));
     _fizzBuzzWriter.Configure(new DivisibleByRule(4, "Bazz"));
     _fizzBuzzWriter.Configure(new DivisibleByRule(5, "Buzz"));
 }
示例#2
0
        static void Main(string[] args)
        {
            var write = new FizzBuzzWriter(Console.Out, new DefaultNumberRule());

            write.Configure(new DivisibleByRule(3, "Fizz"));
            write.Configure(new DivisibleByRule(5, "Buzz"));

            var numberSource = new ConsoleBasedNumberSource();

            foreach (var number in numberSource)
            {
                write.WriteLine(number);
                Console.WriteLine();
            }

            Console.WriteLine("Finished...");
            Console.ReadLine();
        }