예제 #1
0
        static void Main(string[] args)
        {
            var lucky       = new ContainsPipe(3, "lucky");
            var fizz        = new NumberSubstitutePipe(3, "fizz");
            var buzz        = new NumberSubstitutePipe(5, "buzz");
            var fizzbuzz    = new CompositePipe(fizz, buzz);
            var defaultPipe = new DefaultNumberPipe();

            List <IPipe> pipes = new List <IPipe>()
            {
                lucky,
                fizzbuzz,
                fizz,
                buzz,
                defaultPipe
            };

            var runner = new Runner(Enumerable.Range(1, 20), pipes);

            foreach (var item in runner.Run())
            {
                Console.WriteLine(item);
            }

            Console.ReadLine();
        }
예제 #2
0
        public void Number_substitute_check_passes_for_expected_numbers(int target, int input, bool expected)
        {
            IPipe pipe = new NumberSubstitutePipe(target, string.Empty);

            bool actual = pipe.Check(input);

            Assert.Equal(expected, actual);
        }