public void Should_Return_FizzBuzzLooper_After_Adding_Filter()
        {
            var classUnderTest = new FizzBuzzLooper(5);
            var looper         = classUnderTest.AddFilter(new TestNumberFilter());

            Assert.That(looper, Is.SameAs(classUnderTest));
        }
        public void Should_Call_Passed_Delegate_With_Result_On_Output()
        {
            var assertionList = new List <string>();

            var classUnderTest = new FizzBuzzLooper(5);

            classUnderTest.Output(result => assertionList.Add(result));

            Assert.That(assertionList.Count, Is.EqualTo(5));
        }
        public void Should_Call_Filter_On_Match_When_Outputting_Results()
        {
            var assertionList = new List <string>();

            var classUnderTest = new FizzBuzzLooper(5);

            classUnderTest.AddFilter(new TestNumberFilter());
            classUnderTest.Output(result => assertionList.Add(result));

            Assert.That(assertionList[4], Is.EqualTo("TestFilter"));
        }
Exemple #4
0
        static void WithInjectedRule()
        {
            //I'd usually let an IOC container do this.
            var rules = new IRule[]
            {
                new FizzRule(),
                new BuzzRule(),
                new ZoomRule()
            };
            var looper = new FizzBuzzLooper(new FizzBuzzRenderer(rules));

            looper.Loop(100, 200);
        }
        public void Should_Return_Current_Number_When_No_Filter_Is_Matched()
        {
            var assertionList = new List <string>();

            var classUnderTest = new FizzBuzzLooper(5);

            classUnderTest.AddFilter(new TestNumberFilter());
            classUnderTest.Output(result => assertionList.Add(result));

            Assert.That(assertionList[0], Is.EqualTo("1"));
            Assert.That(assertionList[1], Is.EqualTo("2"));
            Assert.That(assertionList[2], Is.EqualTo("3"));
            Assert.That(assertionList[3], Is.EqualTo("4"));
        }