public void Should_return_isFizz()
        {
            var result = _sut.Analize(33);

            Assert.IsTrue(result.IsFizz);
            Assert.IsFalse(result.IsBuzz);
        }
        public FizzBuzzResult Analize(int number)
        {
            var result = _simpleAnalizer.Analize(number);

            var stringNumber = number.ToString();

            for (int i = 0; i < stringNumber.Length; i++)
            {
                if (result.IsFizz && result.IsBuzz)
                {
                    break;
                }

                if (!result.IsFizz && stringNumber[i] == '3')
                {
                    result.IsFizz = true;
                }
                if (!result.IsBuzz && stringNumber[i] == '5')
                {
                    result.IsBuzz = true;
                }
            }

            return(result);
        }
Exemple #3
0
        public void Run()
        {
            for (int i = 0; i <= 100; i++)
            {
                var result = _analizer.Analize(i);

                if (result.IsFizz && result.IsBuzz)
                {
                    Console.WriteLine("FizzBuzz!");
                }
                else if (result.IsFizz)
                {
                    Console.WriteLine("Fizz!");
                }
                else if (result.IsBuzz)
                {
                    Console.WriteLine("Buzz!");
                }
                else
                {
                    Console.WriteLine($"{i}!");
                }
            }
        }
Exemple #4
0
 internal void Analize(IAnalizer analizer)
 {
     if (analizer != null)
         analizer.Analize(_Numbers);
 }