Esempio n. 1
0
        public void Should_Be_Valid_Player_When_Set_Captain()
        {
            var manager = new 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));
        }
Esempio n. 2
0
        public static void Should_Be_Valid_Player_When_Set_Captain()
        {
            var manager = new 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);
            long captainId = manager.GetTeamCaptain(1); //1

            manager.SetCaptain(2);                      //PlayerNotFoundException
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            SoccerTeamsManager TeamManager = new SoccerTeamsManager();

            TeamManager.AddTeam(1, "Flamengo", DateTime.Now, "Vermelho", "Preto");
            TeamManager.AddTeam(2, "Inter", DateTime.Now, "Vermelho", "Branco");
            TeamManager.AddTeam(3, "Vasco", DateTime.Now, "Branco", "Preto");
            //TeamManager.AddTeam(4, "Gremio", DateTime.Now, "Azul", "Branco");
            //TeamManager.AddTeam(5, "Palmeiras", DateTime.Now, "Verde", "Branco");
            //TeamManager.AddTeam(6, "Atletico Parananense", DateTime.Now, "Preto", "Vermelho");


            TeamManager.AddPlayer(7, 1, "Edmundo", DateTime.Now, 19, 1000);
            TeamManager.AddPlayer(10, 1, "Romario", DateTime.Now, 9, 1000);

            TeamManager.AddPlayer(3, 2, "Dida", DateTime.Now, 11, 10000);
            TeamManager.AddPlayer(4, 2, "Dunga", DateTime.Now, 3, 8000);

            TeamManager.AddPlayer(5, 3, "Tafarel", DateTime.Now, 19, 20000);
            TeamManager.AddPlayer(6, 3, "Felipao", DateTime.Now, 4, 100000);

            TeamManager.SetCaptain(3);
            TeamManager.SetCaptain(2);
        }
Esempio n. 4
0
        public void Should_Choose_Best_Team_Player(string skills, int bestPlayerId)
        {
            var manager = new 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));
        }
Esempio n. 5
0
        public void Should_Ensure_Sort_Order_When_Get_Team_Players()
        {
            var manager = new 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));
        }
Esempio n. 6
0
        public static void Should_Choose_Best_Team_Player()
        {
            var testes = new Dictionary <string, int>()
            {
                { "10,20,300,40,50", 2 },
                { "50,240,3,1,50", 1 },
                { "10,22,24,3,24", 2 }
            };

            foreach (var teste in testes)
            {
                var manager = new SoccerTeamsManager();
                manager.AddTeam(1, "Time 1", DateTime.Now, "cor 1", "cor 2");

                var skillsLevelList = teste.Key.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);
                }

                Console.WriteLine(teste.Value == manager.GetBestTeamPlayer(1));
            }
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            SoccerTeamsManager Stm = new SoccerTeamsManager();

            Stm.AddTeam(1, "galo", new DateTime(2020, 05, 01), "preto e branco", "branco");
            Stm.AddPlayer(2, 1, "Tardelli", new DateTime(2000, 5, 2), 90, 10000m);
            Stm.AddPlayer(0, 1, "Victor", new DateTime(1990, 5, 2), 80, 100m);
            Stm.AddPlayer(1, 1, "Ronaldo", new DateTime(1984, 5, 2), 100, 1000m);
            Stm.SetCaptain(2);
            Console.WriteLine("O capitão é:{0}", Tabelas.Jogadores.Where(x => x.teamId == 1 && x.Capitao).Select(x => x.name).Single());
            Stm.SetCaptain(1);
            Console.WriteLine("O capitão é:{0}", Tabelas.Jogadores.Where(x => x.teamId == 1 && x.Capitao).Select(x => x.name).Single());
            Console.WriteLine(Stm.GetTeamCaptain(1));
            Console.WriteLine(Stm.GetPlayerName(0));
            Console.WriteLine(Stm.GetTeamName(1));
            var jog = Stm.GetTeamPlayers(1);

            jog.ForEach(x => Console.WriteLine(x));
            Console.WriteLine(Stm.GetBestTeamPlayer(1));
            Console.WriteLine(Stm.GetOlderTeamPlayer(1));
            Console.WriteLine(Stm.GetTeams());
            Console.WriteLine(Stm.GetHigherSalaryPlayer(1));
        }