Ejemplo n.º 1
0
        public void Pass1GetString1()
        {
            var fizzBuzz = new FizzBuzzer();
            var result = fizzBuzz.ToString(1);

            Assert.AreEqual("1", result);
        }
Ejemplo n.º 2
0
        public void Pass2GetString2()
        {
            var fizzBuzz = new FizzBuzzer();
            var result = fizzBuzz.ToString(2);

            Assert.AreEqual("2", result);
        }
Ejemplo n.º 3
0
        public FizzBuzzFile(IFizzBuzzFileRepository fizzBuzzFileRepository, IAppSettingsRepository appSettingsRepository)
        {
            int limit = appSettingsRepository.GetLimitValue();

            this.fizzBuzzFileRepository = fizzBuzzFileRepository;
            this.fizzBuzz = new FizzBuzzer(limit);
        }
Ejemplo n.º 4
0
        public void PassDivisibleBy3GetFizz()
        {
            var fizzBuzz = new FizzBuzzer();
            var result = fizzBuzz.ToString(3);

            Assert.AreEqual("Fizz", result);
        }
Ejemplo n.º 5
0
        public void PassChangeSettingGet2Settings()
        {
            var fizzBuzz = new FizzBuzzer();
            fizzBuzz.AddSetting(3, "coconut");

            Assert.AreEqual(fizzBuzz.Settings.Count, 2);
        }
Ejemplo n.º 6
0
        public void Request_DivisibleBy5_Buzz()
        {
            var sut = new FizzBuzzer();

            string result = sut.Request(5);

            result.ShouldBe("buzz");
        }
Ejemplo n.º 7
0
        public void Request_NotDivisible_NullString()
        {
            var sut = new FizzBuzzer();

            string result = sut.Request(7);

            result.ShouldBe(string.Empty);
        }
Ejemplo n.º 8
0
        public void PassDivisibleBy3And5And2GetFizzBuzzCoconut()
        {
            var fizzBuzz = new FizzBuzzer();
            fizzBuzz.AddSetting(2, "Coconut");
            var result = fizzBuzz.ToString(30);

            Assert.AreEqual("Fizz Buzz Coconut", result);
        }
Ejemplo n.º 9
0
        public void Request_DivisibleBy3And5_FizzBuzz()
        {
            var sut = new FizzBuzzer();

            string result = sut.Request(15);

            result.ShouldBe("fizzbuzz");
        }
Ejemplo n.º 10
0
 public void SayNextTest(int count, string expected)
 {
     FizzBuzzer obj = new FizzBuzzer();
     string result = null;
     for (int i=0; i < count; i++)
     {
         result = obj.SayNext();
     }
     Assert.AreEqual(expected, result);
 }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            // List<string> results = new List<string>;
            Console.WriteLine("Hello World!");
            List <int> numbers = new List <int> {
                1, 4532, 51, 31, 11531, 22354
            };

            var results = FizzBuzzer.MillNumbers(numbers);

            results.ForEach(Console.WriteLine);
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            // The code provided will print ‘Hello World’ to the console.
            // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
            for (int i = 0; i <= 100; i++)
            {
                Console.WriteLine(FizzBuzzer.GetValue(i));
            }
            Console.ReadKey();

            // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app!
        }
Ejemplo n.º 13
0
 static void FizzBuzzDemo()
 {
     // Print numbers 1 through 100
     // but print Fizz if a multiple of 3
     //     print Buzz if a multiple of 5
     //     print FizzBuzz if a multiple of both
     for (int n = 1; n < 100; n++)
     {
         var fizzBuzzed = FizzBuzzer.Convert(n);
         Console.WriteLine($"{n}: {fizzBuzzed}");
     }
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            Func <int, bool> div3 = i => (i % 3 == 0);
            Func <int, bool> div5 = i => (i % 5 == 0);
            Func <int, bool> div7 = i => (i % 7 == 0);

            var fizzBuzzer = new FizzBuzzer(Console.Out,
                                            new Rule(div3, "fizz"),
                                            new Rule(div5, "buzz"),
                                            new Rule(div7, "hello"));

            fizzBuzzer.Print(1, 100);
            Console.ReadLine();
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            List <int> numbers = new List <int>()
            {
                7, 15
            };
            List <string> results = FizzBuzzer.MillNumbers(numbers);

            foreach (var array in results)
            {
                Console.WriteLine(string.Join(" ", array));
            }
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            foreach (var item in FizzBuzzer.FizzBuzzRange(1, 100))
            {
                Console.WriteLine(item);
            }

            Console.ReadKey();

            foreach (var item in FizzBuzzer.FizzBuzzRange(1, 100, true))
            {
                Console.WriteLine(item);
            }

            Console.ReadKey();
        }
Ejemplo n.º 17
0
        public void PassNewSettingGet3Settings()
        {
            var fizzBuzz = new FizzBuzzer();
            fizzBuzz.AddSetting(2, "coconut");

            Assert.AreEqual(fizzBuzz.Settings.Count, 3);
        }
Ejemplo n.º 18
0
        private void ActAndAssert()
        {
            var fizzBuzzer = new FizzBuzzer();
            IEnumerable<string> actual = fizzBuzzer.FizzBuzzIt(count);

            Assert.That(actual, Is.EquivalentTo(expectedOutput));
        }
Ejemplo n.º 19
0
 public FizzBuzzTests(ITestOutputHelper output)
 {
     _output     = output;
     _fizzBuzzer = new FizzBuzzer();
 }
Ejemplo n.º 20
0
 public void Initialize()
 {
     _fizzBuzzer = new FizzBuzzer();
 }
Ejemplo n.º 21
0
 public FizzBuzzerTests()
 {
     fizzBuzzer = new FizzBuzz.FizzBuzzer();
 }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            var output = new FizzBuzzer().Run();

            Console.WriteLine(output);
        }
Ejemplo n.º 23
0
        public void Defult2Settings()
        {
            var fizzBuzz = new FizzBuzzer();

            Assert.AreEqual(fizzBuzz.Settings.Count, 2);
        }
Ejemplo n.º 24
0
 public void SetUp()
 {
     fizzBuzzer = new FizzBuzzer();
 }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome!");
            FizzBuzzer fb = new FizzBuzzer();

            Console.WriteLine("Which number rules would you like to be valid?");
            string[]   str          = Console.ReadLine().Split(' ');
            List <int> validNumbers = new List <int>();

            for (int i = 0; i <= str.Length - 1; i++)
            {
                validNumbers.Add(Convert.ToInt32(str[i]));
            }

            void askRule()
            {
                Console.WriteLine("Would you like to add a new rule? (Y/N)");
                string ruleName;
                int    d;
                bool   removeRest, addEnd, reverseRule;
                char   beforeLetter;

                if (Convert.ToChar(Console.ReadLine().ToUpper()) == 'Y')
                {
                    Console.WriteLine("Great! What's the rule name?");
                    ruleName = Console.ReadLine();

                    Console.WriteLine("And what's the factor your number should be divisible by?");
                    d = Convert.ToInt32(Console.ReadLine());

                    // Clear words rule
                    Console.WriteLine("Should this rule clear the other words applied up until now? (Y/N)");
                    if (Convert.ToChar(Console.ReadLine().ToUpper()) == 'Y')
                    {
                        removeRest = true;
                    }
                    else
                    {
                        removeRest = false;
                    }

                    // Append word rule
                    Console.WriteLine("Should this rule append the word? (Y/N)");
                    if (Convert.ToChar(Console.ReadLine().ToUpper()) == 'Y')
                    {
                        addEnd = true;
                    }
                    else
                    {
                        addEnd = false;
                    }

                    // Add word before first word starting with a letter rule
                    Console.WriteLine(
                        "Should this rule add the word before the first word starting with a certain letter? (Y/N)");
                    if (Convert.ToChar(Console.ReadLine().ToUpper()) == 'Y')
                    {
                        Console.WriteLine("Which letter should that be?");
                        beforeLetter = Convert.ToChar(Console.ReadLine().ToUpper());
                    }
                    else
                    {
                        beforeLetter = '0';
                    }

                    // Reverse words rule
                    Console.WriteLine("Should this rule reverse the order of all the words? (Y/N)");
                    if (Convert.ToChar(Console.ReadLine().ToUpper()) == 'Y')
                    {
                        reverseRule = true;
                    }
                    else
                    {
                        reverseRule = false;
                    }

                    fb.addRule(d, ruleName, removeRest, addEnd, beforeLetter, reverseRule, validNumbers);
                    Console.WriteLine("Alright! Added the rule!");
                    askRule();
                }
            }

            askRule();

            fb.addRule(3, "Fizz", false, true, '0', false, validNumbers);
            fb.addRule(5, "Buzz", false, true, '0', false, validNumbers);
            fb.addRule(7, "Bang", false, true, '0', false, validNumbers);
            fb.addRule(11, "Bong", true, true, '0', false, validNumbers);
            fb.addRule(13, "Fezz", false, false, 'B', false, validNumbers);
            fb.addRule(17, "", false, false, '0', true, validNumbers);

            Console.WriteLine("How many numbers should we count?");
            int max = Convert.ToInt32(Console.ReadLine());

            for (int i = 1; i <= max; i++)
            {
                fb.applyRules(i);
                fb.printResult(i);
            }
        }
Ejemplo n.º 26
0
 public void Initialize()
 {
     _fizzBuzzer = new FizzBuzzer();
 }