public void DevoRetornarFizParaNumerosMultiplosDe3()
        {
            var fb      = new FizBuz();
            var retorno = fb.Retorno(3);

            Assert.AreEqual("FIZ", retorno);
        }
        public void DevoRetornarBuzParaNumerosMultiplosDe5()
        {
            var fb      = new FizBuz();
            var retorno = fb.Retorno(5);

            Assert.AreEqual("BUZ", retorno);
        }
Example #3
0
 public void FizBuzShouldCallEventHandlerWhenSet()
 {
     bool called = false;
     var target = new FizBuz(1, 100);
     target.OnOutput += (sender, output, value) => called = true;
     target.Run();
     Assert.IsTrue(called);
 }
Example #4
0
 public void FizBuzShouldOutputForEachItemFromStartToEnd()
 {
     int start = 1;
     int stop = 100;
     int calls = 0;
     var target = new FizBuz(start, stop);
     target.OnOutput += (sender, output, value) => calls++;
     target.Run();
     Assert.AreEqual((start - 1) + stop, calls);
 }
Example #5
0
        public void FizBuzShouldMatchConfiguredValues()
        {
            var configs = new FizBuzConfig[]
            {
                new FizBuzConfig(3, "fiz"),
                new FizBuzConfig(5, "buz"),
                new FizBuzConfig(10, "baz"),

            };
            var target = new FizBuz(1, 100, configs);
            target.OnOutput += (sender, output, value) =>
                {
                    configs.Where(c => output.Contains(c.Message)).ToList()
                        .ForEach(c => Assert.IsTrue(value % c.Divisor == 0, "FizBuz should not have output {1} as {0} is not divisible by {2} ({3})", value, output, c.Divisor, c.Message));
                };
            target.Run();
        }
Example #6
0
 public void FizBuzShouldRunWithoutEventHandlerWhenSet()
 {
     var target = new FizBuz(1, 100);
     target.Run();
 }
Example #7
0
 public void FizBuzCtorShouldThrowExceptionWhenStartIsGreaterThanEndWhenConfigurationProvided()
 {
     var target = new FizBuz(5, 4, null);
 }
Example #8
0
 public void FizBuzCtorShouldThrowExceptionWhenStartIsGreaterThanEnd()
 {
     var target = new FizBuz(5, 4);
 }
Example #9
0
 public void FizBuzCtorShouldThrowExceptionWhenConfigurationsAreNull()
 {
     var target = new FizBuz(1, 10, null);
 }
Example #10
0
 public void FizBuzCtorShouldThrowExceptionWhenConfigurationsAreEmpty()
 {
     var target = new FizBuz(1, 10, new FizBuzConfig[] { });
 }