Exemplo n.º 1
0
        public void Should_Player_Name_Equal_Player1()
        {
            SoccerTeamsManager.SoccerTeamsManager manager = new SoccerTeamsManager.SoccerTeamsManager();
            _mockTeam.ForEach(team => manager.AddTeam(team.Id, team.Name, team.Created, team.MainShirtColor, team.SecondaryShirtColor));
            _mockPlayer.ForEach(player => manager.AddPlayer(player.Id, player.TeamId, player.Name, player.BirthDate, player.SkillLevel, player.Salary));

            string name = manager.GetPlayerName(1);

            Assert.Equal("Player 1", name);
        }
Exemplo n.º 2
0
        public void Should_List_Player_Team_Two()
        {
            SoccerTeamsManager.SoccerTeamsManager manager = new SoccerTeamsManager.SoccerTeamsManager();
            _mockTeam.ForEach(team => manager.AddTeam(team.Id, team.Name, team.Created, team.MainShirtColor, team.SecondaryShirtColor));
            _mockPlayer.ForEach(player => manager.AddPlayer(player.Id, player.TeamId, player.Name, player.BirthDate, player.SkillLevel, player.Salary));

            List <long> ids = manager.GetTeamPlayers(2);

            Assert.Equal(2, ids.Count());
        }
Exemplo n.º 3
0
        public void Should_Be_Older_Team_Player()
        {
            SoccerTeamsManager.SoccerTeamsManager manager = new SoccerTeamsManager.SoccerTeamsManager();
            _mockTeam.ForEach(team => manager.AddTeam(team.Id, team.Name, team.Created, team.MainShirtColor, team.SecondaryShirtColor));
            _mockPlayer.ForEach(player => manager.AddPlayer(player.Id, player.TeamId, player.Name, player.BirthDate, player.SkillLevel, player.Salary));

            long id = manager.GetOlderTeamPlayer(1);

            Assert.Equal(1, id);
        }
Exemplo n.º 4
0
        public void Should_Be_Valid_Player_When_Set_Captain()
        {
            var manager = new SoccerTeamsManager.SoccerTeamsManager();

            manager.AddTeam(1, "Time 1", DateTime.Now, "cor 1", "cor 2");
            manager.AddPlayer(1, 1, "Jogador 1", DateTime.Today, 0, 0);
            manager.SetCaptain(1);
            Assert.Equal(1, manager.GetTeamCaptain(1));
            Assert.Throws <PlayerNotFoundException>(() =>
                                                    manager.SetCaptain(2));
        }
Exemplo n.º 5
0
        public void Should_Choose_Best_Team_Player(string skills, int bestPlayerId)
        {
            var manager = new SoccerTeamsManager.SoccerTeamsManager();

            manager.AddTeam(1, "Time 1", DateTime.Now, "cor 1", "cor 2");

            var skillsLevelList = skills.Split(',').Select(x => int.Parse(x)).ToList();

            for (int i = 0; i < skillsLevelList.Count(); i++)
            {
                manager.AddPlayer(i, 1, $"Jogador {i}", DateTime.Today, skillsLevelList[i], 0);
            }

            Assert.Equal(bestPlayerId, manager.GetBestTeamPlayer(1));
        }
Exemplo n.º 6
0
        public void Should_Player_Highest_Salary()
        {
            var manager = new SoccerTeamsManager.SoccerTeamsManager();

            manager.AddTeam(1, "Time 1", DateTime.Now, "cor 1", "cor 2");
            var playersIds = new List <long>()
            {
                15, 2, 33
            };

            for (int i = 0; i < playersIds.Count(); i++)
            {
                manager.AddPlayer(playersIds[i], 1, $"Jogador {i}", DateTime.Today, i + 10, 100 * (i + 1));
            }

            Assert.Equal(300, manager.GetPlayerSalary(33));
        }
Exemplo n.º 7
0
        public void Should_Sort_All_Players_By_Skill_When_Get_Top_Players()
        {
            SoccerTeamsManager.SoccerTeamsManager manager = new SoccerTeamsManager.SoccerTeamsManager();
            _mockTeam.ForEach(team => manager.AddTeam(team.Id, team.Name, team.Created, team.MainShirtColor, team.SecondaryShirtColor));
            //_mockPlayer.ForEach(player => manager.AddPlayer(player.Id, player.TeamId, player.Name, player.BirthDate, player.SkillLevel, player.Salary));

            var playersIds = new List <long>()
            {
                7, 33, 2, 70, 10, 240, 73, 1, 50, 17, 220, 14, 5
            };

            for (int i = 0; i < playersIds.Count(); i++)
            {
                manager.AddPlayer(playersIds[i], 1, $"Jogador {i}", DateTime.Today, (i + 1) + 10, 0);
            }

            Assert.Equal(playersIds.Take(10).Count(), manager.GetTopPlayers(10).Count());
        }
Exemplo n.º 8
0
        public void Top_Jogadores()
        {
            var manager = new SoccerTeamsManager.SoccerTeamsManager();

            manager.AddTeam(1, "Time 1", DateTime.Now, "cor 1", "cor 2");

            var playersIds = new List <long>()
            {
                15, 2, 33, 4, 13, 22, 23, 26, 70
            };

            for (int i = 0; i < playersIds.Count(); i++)
            {
                manager.AddPlayer(playersIds[i], 1, $"Jogador {i}", DateTime.Today, i + 10, 0);
            }

            Assert.Equal(playersIds.Take(3).Count(), manager.GetTopPlayers(3).Count());
        }
Exemplo n.º 9
0
        public void Should_Ensure_Sort_Order_When_Get_Team_Players()
        {
            var manager = new SoccerTeamsManager.SoccerTeamsManager();

            manager.AddTeam(1, "Time 1", DateTime.Now, "cor 1", "cor 2");

            var playersIds = new List <long>()
            {
                15, 2, 33, 4, 13
            };

            for (int i = 0; i < playersIds.Count(); i++)
            {
                manager.AddPlayer(playersIds[i], 1, $"Jogador {i}", DateTime.Today, 0, 0);
            }

            playersIds.Sort();
            Assert.Equal(playersIds, manager.GetTeamPlayers(1));
        }