Exemplo n.º 1
0
        public void DoesFizzBuzzShowNumberWhenNotOneOfTheCombinations()
        {
            //Arrange
            const int    UpperBound   = 15;
            const string FirstWord    = "Cersei";
            const string SecondWord   = "Jamie";
            const string ThirdWord    = "Lannister";
            var          actionValues = new Dictionary <int, string>()
            {
                { 3, FirstWord },
                { 5, SecondWord },
                { 15, ThirdWord }
            };

            //Act
            var output = SuperFizzBuzzer.FizzBuzz(UpperBound, actionValues);

            //Assert
            Assert.AreEqual("1", output.First());
            Assert.AreEqual("2", output.Skip(1).First());
            Assert.AreEqual("4", output.Skip(3).First());
            Assert.AreEqual("7", output.Skip(6).First());
            Assert.AreEqual("8", output.Skip(7).First());
            Assert.AreEqual("11", output.Skip(10).First());
            Assert.AreEqual("13", output.Skip(12).First());
            Assert.AreEqual("14", output.Skip(13).First());
        }
Exemplo n.º 2
0
        public void DoesFizzBuzzReturnNumberOfItemsMatchingUpperBound()
        {
            //Arrange
            const int UpperBound   = 101;
            var       actionValues = new Dictionary <int, string>();

            //Act
            var output = SuperFizzBuzzer.FizzBuzz(UpperBound, actionValues);

            //Assert
            Assert.AreEqual(UpperBound, output.Count());
        }
Exemplo n.º 3
0
        private static void RunSuperFizzBuzzer()
        {
            const int UpperBound   = 100;
            var       actionValues = new Dictionary <int, string>
            {
                { 3, "Clear" },
                { 9, "Measure" },
                { 11, "Rocks" }
            };

            foreach (var item in SuperFizzBuzzer.FizzBuzz(UpperBound, actionValues))
            {
                Console.WriteLine(item);
            }
        }
Exemplo n.º 4
0
        public void DoesFizzBuzzShowAnExpectedSingleItemAtExpectedInterval()
        {
            //Arrange
            const int    UpperBound   = 12;
            const string FirstWord    = "Tyrion";
            var          actionValues = new Dictionary <int, string>()
            {
                { 3, FirstWord }
            };

            //Act
            var output = SuperFizzBuzzer.FizzBuzz(UpperBound, actionValues);

            //Assert
            Assert.AreEqual(FirstWord, output.Skip(2).First());
            Assert.AreEqual(FirstWord, output.Skip(5).First());
            Assert.AreEqual(FirstWord, output.Skip(8).First());
            Assert.AreEqual(FirstWord, output.Skip(11).First());
        }
Exemplo n.º 5
0
        public void DoesFizzBuzzReturnFizzBuzzKablamWhenCounterIs15()
        {
            //Arrange
            const int UpperBound   = 15;
            var       actionValues = new Dictionary <int, string>
            {
                { 3, "Hound" },
                { 5, "Or" },
                { 15, "Mountain?" }
            };

            //Act
            var output = SuperFizzBuzzer.FizzBuzz(UpperBound, actionValues);

            //Assert
            var lastItem = output.Last();

            Assert.AreEqual("HoundOrMountain?", lastItem);
        }
Exemplo n.º 6
0
        public void DoesFizzBuzzShowCombinationOfTwoWords()
        {
            //Arrange
            const int    UpperBound    = 30;
            const string FirstWord     = "Jon";
            const string SecondWord    = "Snow";
            var          CombinedWords = $"{FirstWord}{SecondWord}";
            var          actionValues  = new Dictionary <int, string>()
            {
                { 3, FirstWord },
                { 5, SecondWord }
            };

            //Act
            var output = SuperFizzBuzzer.FizzBuzz(UpperBound, actionValues);

            //Assert
            Assert.AreEqual(CombinedWords, output.Skip(14).First());
            Assert.AreEqual(CombinedWords, output.Skip(29).First());
        }
Exemplo n.º 7
0
        public void DoesFizzBuzzShowAnExpectedSecondWordAtTheExpectedInterval()
        {
            //Arrange
            const int    UpperBound   = 25;
            const string SecondWord   = "Lannister";
            var          actionValues = new Dictionary <int, string>()
            {
                { 4, "Tyrion" },
                { 5, SecondWord }
            };


            //Act
            var output = SuperFizzBuzzer.FizzBuzz(UpperBound, actionValues);

            //Assert
            Assert.AreEqual(SecondWord, output.Skip(4).First());
            Assert.AreEqual(SecondWord, output.Skip(9).First());
            Assert.AreEqual(SecondWord, output.Skip(14).First());
            Assert.AreEqual(SecondWord, output.Skip(24).First());
        }