Beispiel #1
0
        public void Shoud_read_Distinct_Count_Nationality_From_File()
        {
            var cup   = new FIFACupStats();
            var count = cup.NationalityDistinctCount();

            Assert.Equal(164, count);
        }
Beispiel #2
0
        public void Shoud_read_Distinct_Count_Club_From_File()
        {
            var cup   = new FIFACupStats();
            var count = cup.ClubDistinctCount();

            Assert.Equal(647, count);
        }
Beispiel #3
0
        public void Shoud_Return_ClubDistinctCount()
        {
            var cup   = new FIFACupStats();
            var clubs = cup.ClubDistinctCount();

            Assert.Equal(647, clubs);
        }
Beispiel #4
0
        public void Shoud_Read_Objects_With_Fields_Selecteds()
        {
            var cup = new FIFACupStats();

            byte[] byteArray    = Encoding.ASCII.GetBytes("1,Max,Max Back,40\r\n2,Eric,Eric Back,15\r\n3,Thomas,Thomas Back,2\r\n");
            var    source       = new MemoryStream(byteArray);
            var    sourceReader = new StreamReader(source);

            string fields = "ID,name,full_name,age";

            cup.MapFields(fields);

            var regs = cup.ReadRegisters(sourceReader, fields.Split(','), FIFACupStats.ALL);

            Assert.Equal(3, regs.Count);
            Assert.Equal("1", regs[0].ID);
            Assert.Equal("Max Back", regs[0].full_name);
            Assert.Equal("40", regs[0].age);

            Assert.Equal("2", regs[1].ID);
            Assert.Equal("Eric Back", regs[1].full_name);
            Assert.Equal("15", regs[1].age);


            Assert.Equal("3", regs[2].ID);
            Assert.Equal("Thomas Back", regs[2].full_name);
            Assert.Equal("2", regs[2].age);
        }
Beispiel #5
0
        public void Shoud_Return_NationalityDistinctCount()
        {
            var cup           = new FIFACupStats();
            var nationalities = cup.NationalityDistinctCount();

            Assert.Equal(164, nationalities);
        }
        public void Should20FirstPlayersNames()
        {
            var cup   = new FIFACupStats();
            var names = new List <string>()
            {
                "C. Ronaldo dos Santos Aveiro",
                "Lionel Messi",
                "Neymar da Silva Santos Jr.",
                "Luis Suárez",
                "Manuel Neuer",
                "Robert Lewandowski",
                "David De Gea Quintana",
                "Eden Hazard",
                "Toni Kroos",
                "Gonzalo Higuaín",
                "Sergio Ramos García",
                "Kevin De Bruyne",
                "Thibaut Courtois",
                "Alexis Sánchez",
                "Luka Modrić",
                "Gareth Bale",
                "Sergio Agüero",
                "Giorgio Chiellini",
                "Gianluigi Buffon",
                "Paulo Dybala"
            };

            Assert.Equal(names, cup.First20Players());
        }
        public void Shoud_Be_16_The_Minimum_Age_In_Get_Age_Count_Map()
        {
            var cup    = new FIFACupStats();
            var ageMap = cup.AgeCountMap();

            Assert.NotNull(ageMap);
            Assert.Equal(16, ageMap.Keys.Min());
        }
        public void Shoud_Be_47_The_Maximum_Age_When_Get_Age_Count_Map()
        {
            var cup    = new FIFACupStats();
            var ageMap = cup.AgeCountMap();

            Assert.NotNull(ageMap);
            Assert.Equal(47, ageMap.Keys.Max());
        }
        public void Shoud_Return_20_Itens_When_Get_Top_Players()
        {
            var cup        = new FIFACupStats();
            var topPlayers = cup.First20Players();

            Assert.NotNull(topPlayers);
            Assert.Equal(20, topPlayers.Count);
        }
        public void Shoud_Return_10_Itens_When_Get_Top_Players_By_Age()
        {
            var cup        = new FIFACupStats();
            var topPlayers = cup.Top10PlayersByAge();

            Assert.NotNull(topPlayers);
            Assert.Equal(10, topPlayers.Count);
        }
Beispiel #11
0
        public void Shoud_Map_Fieds_From_First_Line()
        {
            int id, name, full_name, age;
            var cup = new FIFACupStats();

            cup.MapFields("ID,name,full_name,age");
            Assert.True(cup.FieldPositions.TryGetValue("ID", out id));                                      Assert.Equal(0, id);
            Assert.True(cup.FieldPositions.TryGetValue("name", out name));                          Assert.Equal(1, name);
            Assert.True(cup.FieldPositions.TryGetValue("full_name", out full_name));        Assert.Equal(2, full_name);
            Assert.True(cup.FieldPositions.TryGetValue("age", out age));                            Assert.Equal(3, age);
        }
Beispiel #12
0
        public void Shoud_read_Distinct_Count_Nationality_From_memory_Stream(string content, int expected)
        {
            var cup = new FIFACupStats();

            byte[] byteArray    = Encoding.ASCII.GetBytes(content);
            var    source       = new MemoryStream(byteArray);
            var    sourceReader = new StreamReader(source);

            var count = cup.NationalityDistinctCountFromStream(sourceReader);

            Assert.Equal(expected, count);
        }
Beispiel #13
0
        public void Shoud_Return_20_Itens_When_Get_Top_Players_From_String()
        {
            var    cup     = new FIFACupStats();
            string content = "full_name\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22";

            byte[] byteArray    = Encoding.ASCII.GetBytes(content);
            var    source       = new MemoryStream(byteArray);
            var    sourceReader = new StreamReader(source);

            var fullNames = cup.First20PlayersFromStream(sourceReader);

            Assert.Equal(20, fullNames.Count);
            for (int i = 1; i <= 20; i++)
            {
                Assert.Equal(i.ToString(), fullNames[i - 1]);
            }
        }
Beispiel #14
0
        public void Shoud_Return_10_Itens_When_Get_Top_Players_By_Age_From_memory_Stream(string content, int expected, string expectedNames)
        {
            var cup = new FIFACupStats();

            byte[] byteArray    = Encoding.ASCII.GetBytes(content);
            var    source       = new MemoryStream(byteArray);
            var    sourceReader = new StreamReader(source);

            var players = cup.Top10PlayersByAgeFromStream(sourceReader);

            Assert.Equal(expected, players.Count);

            var names = expectedNames.Split(',');

            for (int i = 0; i < expected; i++)
            {
                Assert.Equal(names[i], players[i]);
            }
        }
Beispiel #15
0
        public void Shoud_Return_Map_Of_Ages()
        {
            string expectedMap = "16,18|17,270|18,682|19,1088|20,1252|21,1275|22,1324|23,1395|24,1321|25,1515|26,1199|27,1153|28,1053|29,1127|30,807|31,666|32,506|33,610|34,271|35,188|36,137|37,69|38,38|39,18|40,4|41,3|43,2|44,2|47,1|";
            var    cup         = new FIFACupStats();

            var map = cup.AgeCountMap();

            string str_mapa = "";
            int    value;

            foreach (var key in map.Keys)
            {
                if (map.TryGetValue(key, out value))
                {
                    str_mapa += key.ToString() + ',' + value.ToString() + '|';
                }
            }

            Assert.Equal(expectedMap, str_mapa);
        }
        public void Shoud_Return_Right_Age_Count_Map()
        {
            var cup    = new FIFACupStats();
            var ageMap = cup.AgeCountMap();

            Assert.NotNull(ageMap);

            var expected = new Dictionary <int, int>();

            expected.Add(16, 18);
            expected.Add(17, 270);
            expected.Add(18, 682);
            expected.Add(19, 1088);
            expected.Add(20, 1252);
            expected.Add(21, 1275);
            expected.Add(22, 1324);
            expected.Add(23, 1395);
            expected.Add(24, 1321);
            expected.Add(25, 1515);
            expected.Add(26, 1199);
            expected.Add(27, 1153);
            expected.Add(28, 1053);
            expected.Add(29, 1127);
            expected.Add(30, 807);
            expected.Add(31, 666);
            expected.Add(32, 506);
            expected.Add(33, 610);
            expected.Add(34, 271);
            expected.Add(35, 188);
            expected.Add(36, 137);
            expected.Add(37, 69);
            expected.Add(39, 18);
            expected.Add(38, 38);
            expected.Add(40, 4);
            expected.Add(41, 3);
            expected.Add(43, 2);
            expected.Add(44, 2);
            expected.Add(47, 1);
            Assert.Equal(expected, ageMap);
        }
        public void Shoud_Return_Right_Top_10_Players_By_Release_Clause()
        {
            var cup        = new FIFACupStats();
            var topPlayers = cup.Top10PlayersByReleaseClause();

            Assert.NotNull(topPlayers);

            var expected = new List <string>()
            {
                "Neymar da Silva Santos Jr.",
                "Lionel Messi",
                "Luis Suárez",
                "C. Ronaldo dos Santos Aveiro",
                "Eden Hazard",
                "Toni Kroos",
                "Kevin De Bruyne",
                "Antoine Griezmann",
                "Robert Lewandowski",
                "Gareth Bale"
            };

            Assert.Equal(expected, topPlayers);
        }
        public void Shoud_Return_Right_Top_10_Players_By_Age()
        {
            var cup        = new FIFACupStats();
            var topPlayers = cup.Top10PlayersByAge();

            Assert.NotNull(topPlayers);

            var expected = new List <string>()
            {
                "Barry Richardson",
                "Essam El Hadary",
                "Óscar Pérez",
                "Jimmy Walker",
                "Danny Coyne",
                "Chris Day",
                "Joaquim Manuel Sampaio Silva",
                "Kjetil Wæhler",
                "Timmy Simons",
                "Benjamin Nivet"
            };

            Assert.Equal(expected, topPlayers);
        }
Beispiel #19
0
        public void Shoud_Return_20_Itens_When_Get_Top_Players()
        {
            var expected = new List <string>()
            {
                "C. Ronaldo dos Santos Aveiro",
                "Lionel Messi",
                "Neymar da Silva Santos Jr.",
                "Luis Suárez",
                "Manuel Neuer",
                "Robert Lewandowski",
                "David De Gea Quintana",
                "Eden Hazard",
                "Toni Kroos",
                "Gonzalo Higuaín",
                "Sergio Ramos García",
                "Kevin De Bruyne",
                "Thibaut Courtois",
                "Alexis Sánchez",
                "Luka Modrić",
                "Gareth Bale",
                "Sergio Agüero",
                "Giorgio Chiellini",
                "Gianluigi Buffon",
                "Paulo Dybala"
            };

            var cup        = new FIFACupStats();
            var topPlayers = cup.First20Players();

            Assert.NotNull(topPlayers);
            Assert.Equal(20, topPlayers.Count);

            for (int i = 0; i < 20; i++)
            {
                Assert.Equal(expected[i], topPlayers[i]);
            }
        }
Beispiel #20
0
        public void Shoud_Return_AgeCountMap()
        {
            var cup = new FIFACupStats();
            var age = cup.AgeCountMap();

            Assert.True(age.ContainsKey(16));
            Assert.Equal(18, age[16]);
            Assert.Equal(270, age[17]);
            Assert.Equal(682, age[18]);
            Assert.Equal(1088, age[19]);
            Assert.Equal(1252, age[20]);
            Assert.Equal(1275, age[21]);
            Assert.Equal(1324, age[22]);
            Assert.Equal(1395, age[23]);
            Assert.Equal(1321, age[24]);
            Assert.Equal(1515, age[25]);
            Assert.Equal(1199, age[26]);
            Assert.Equal(1153, age[27]);
            Assert.Equal(1053, age[28]);
            Assert.Equal(1127, age[29]);
            Assert.Equal(807, age[30]);
            Assert.Equal(666, age[31]);
            Assert.Equal(506, age[32]);
            Assert.Equal(610, age[33]);
            Assert.Equal(271, age[34]);
            Assert.Equal(188, age[35]);
            Assert.Equal(137, age[36]);
            Assert.Equal(69, age[37]);
            Assert.Equal(38, age[38]);
            Assert.Equal(18, age[39]);
            Assert.Equal(4, age[40]);
            Assert.Equal(3, age[41]);
            Assert.Equal(2, age[43]);
            Assert.Equal(2, age[44]);
            Assert.Equal(1, age[47]);
        }
Beispiel #21
0
        public void Shoud_Return_Map_Of_Ages_From_memory_Stream(string content, int expected, string expectedMap)
        {
            var cup = new FIFACupStats();

            byte[] byteArray    = Encoding.ASCII.GetBytes(content);
            var    source       = new MemoryStream(byteArray);
            var    sourceReader = new StreamReader(source);

            var map = cup.AgeCountMapFromStream(sourceReader);

            Assert.Equal(expected, map.Count);

            var map_items = expectedMap.Split('|');

            for (int i = 0; i < expected; i++)
            {
                string[] map_item = map_items[i].Split(',');
                int      value;
                //test Key (age)
                Assert.True(map.TryGetValue(int.Parse(map_item[0]), out value));
                //test Value (count)
                Assert.Equal(map_item[1], value.ToString());
            }
        }
        public void ShouldNotGetEmptyList()
        {
            var cup = new FIFACupStats();

            Assert.NotEmpty(cup.ReadData());
        }
        public void Should_Return_Right_Club_Distinct_Count()
        {
            var cup = new FIFACupStats();

            Assert.Equal(647, cup.ClubDistinctCount());
        }
        public void Should_Return_Right_Nationality_Distinct_Count()
        {
            var cup = new FIFACupStats();

            Assert.Equal(164, cup.NationalityDistinctCount());
        }