Example #1
0
        public void TestFuzzBuzzWithLargeNumbersList()
        {
            MapList mapList = new MapList();

            mapList.Add(3, "Fuzz");
            mapList.Add(5, "Buzz");

            string[] actualList   = NumberList.GetNameNumberList(1000020, mapList).Skip(1000000).ToArray();
            string[] expectedList =
            {
                "1000001",
                "Fuzz",
                "1000003",
                "1000004",
                "FuzzBuzz",
                "1000006",
                "1000007",
                "Fuzz",
                "1000009",
                "Buzz",
                "Fuzz",
                "1000012",
                "1000013",
                "Fuzz",
                "Buzz",
                "1000016",
                "Fuzz",
                "1000018",
                "1000019",
                "FuzzBuzz",
            };

            Assert.That(expectedList, Is.EquivalentTo(actualList));
        }
Example #2
0
        public void TestFuzzBuzzList()
        {
            MapList mapList = new MapList();

            mapList.Add(3, "Fuzz");
            mapList.Add(5, "Buzz");

            string[] actualList   = NumberList.GetNameNumberList(20, mapList).ToArray();
            string[] expectedList =
            {
                "1",
                "2",
                "Fuzz",
                "4",
                "Buzz",
                "Fuzz",
                "7",
                "8",
                "Fuzz",
                "Buzz",
                "11",
                "Fuzz",
                "13",
                "14",
                "FuzzBuzz",
                "16",
                "17",
                "Fuzz",
                "19",
                "Buzz",
            };

            Assert.That(expectedList, Is.EquivalentTo(actualList));
        }
Example #3
0
        public void TestComplexMappingList()
        {
            MapList mapList = new MapList();

            mapList.Add(2, "Two");
            mapList.Add(3, "Three");
            mapList.Add(4, "Four");
            mapList.Add(5, "Five");
            mapList.Add(6, "Six");
            mapList.Add(7, "Seven");
            mapList.Add(8, "Eight");
            mapList.Add(9, "Nine");
            mapList.Add(10, "Ten");
            mapList.Add(11, "Eleven");

            string[] actualList   = NumberList.GetNameNumberList(35, mapList).ToArray();
            string[] expectedList =
            {
                "1",
                "Two",
                "Three",
                "TwoFour",
                "Five",
                "TwoThreeSix",
                "Seven",
                "TwoFourEight",
                "ThreeNine",
                "TwoFiveTen",
                "Eleven",
                "TwoThreeFourSix",
                "13",
                "TwoSeven",
                "ThreeFive",
                "TwoFourEight",
                "17",
                "TwoThreeSixNine",
                "19",
                "TwoFourFiveTen",
                "ThreeSeven",
                "TwoEleven",
                "23",
                "TwoThreeFourSixEight",
                "Five",
                "Two",
                "ThreeNine",
                "TwoFourSeven",
                "29",
                "TwoThreeFiveSixTen",
                "31",
                "TwoFourEight",
                "ThreeEleven",
                "Two",
                "FiveSeven",
            };

            Assert.That(expectedList, Is.EquivalentTo(actualList));
        }
Example #4
0
        public void TestMap1List()
        {
            MapList mapList = new MapList();

            mapList.Add(1, "Foo");
            const int Count = 20;

            string[] actualList = NumberList.GetNameNumberList(20, mapList).ToArray();

            List <string> expectedList = new List <string>(Count);

            for (int i = 0; i < Count; ++i)
            {
                expectedList.Add("Foo");
            }

            Assert.That(expectedList, Is.EquivalentTo(actualList));
        }
Example #5
0
        public static IEnumerable <string> GetNameNumberList(int upper, MapList mapList)
        {
            for (int i = 1; i <= upper; ++i)
            {
                string next = "";

                foreach (Tuple <int, string> map in mapList)
                {
                    if ((i % map.Item1) == 0)
                    {
                        next += map.Item2;
                    }
                }

                if (next.Length == 0)
                {
                    next = i.ToString();
                }

                yield return(next);
            }
        }