public void Should_Get_Empty_Teams_List()
        {
            var manager = new SoccerTeamsManager();
            var teams   = manager.GetTeams();

            Assert.Empty(teams);
        }
Esempio n. 2
0
        public void Should_Include_Team(long id, string name, string mainShirtColor, string secondaryShirtColor)
        {
            var manager = new SoccerTeamsManager();

            manager.AddTeam(id, name, DateTime.Today, mainShirtColor, secondaryShirtColor);

            Assert.Contains(id, manager.GetTeams());
        }
Esempio n. 3
0
        public void Should_Return_Ordered_Teams()
        {
            var manager = new SoccerTeamsManager();

            Assert.Empty(manager.GetTeams());

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

            for (int i = 0; i < teamsIds.Count(); i++)
            {
                manager.AddTeam(teamsIds[i], $"Team {i}", DateTime.Today, "", "");
            }

            teamsIds.Sort();
            Assert.Equal(teamsIds, manager.GetTeams());
        }
        public void GetTeams_Ordem_IDs()
        {
            var manager  = new SoccerTeamsManager();
            var teamsIds = new List <long>()
            {
                15, 2, 33, 4, 13
            };

            for (int i = 0; i < teamsIds.Count(); i++)
            {
                manager.AddTeam(teamsIds[i], "Time 1", DateTime.Now, "cor 1", "cor 2");
            }

            teamsIds.Sort();
            Assert.Equal(teamsIds, manager.GetTeams());
        }
Esempio n. 5
0
        public void Should_Ensure_Sort_Order_When_Get_Teams()
        {
            var manager = new SoccerTeamsManager();

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

            for (int i = 0; i < teamIds.Count(); i++)
            {
                manager.AddTeam(teamIds[i], $"Time {i}", DateTime.Today, "cor 1", "cor 2");
            }

            teamIds.Sort();
            Assert.Equal(teamIds, manager.GetTeams());
        }
        public void My_Tests()
        {
            var manager = new SoccerTeamsManager();

            // search all Teams
            Assert.Equal(new List <long> {
            }, manager.GetTeams());
            // search top players
            Assert.Equal(new List <long> {
            }, manager.GetTopPlayers(2));
            // insert Teams
            manager.AddTeam(1, "Time 1", DateTime.Now, "cor 1", "cor 2");
            manager.AddTeam(2, "Time 2", DateTime.Now, "cor 1", "cor 2");
            manager.AddTeam(3, "Time 3", DateTime.Now, "cor 3", "cor 4");
            Assert.Throws <UniqueIdentifierException>(() =>
                                                      manager.AddTeam(1, "Time 1", DateTime.Now, "cor 1", "cor 2"));
            // insert Players
            manager.AddPlayer(1, 1, "Jogador 1", new DateTime(1983, 03, 01), 10, 10);
            manager.AddPlayer(2, 1, "Jogador 2", new DateTime(1985, 02, 01), 69, 100);
            manager.AddPlayer(3, 1, "Jogador 3", new DateTime(1987, 12, 01), 65, 100);
            manager.AddPlayer(9, 1, "Jogador 9", new DateTime(1989, 07, 01), 31, 10);
            manager.AddPlayer(6, 1, "Jogador 6", new DateTime(1990, 05, 01), 72, 100);
            manager.AddPlayer(4, 1, "Jogador 4", new DateTime(1992, 09, 01), 86, 100);
            manager.AddPlayer(8, 1, "Jogador 8", new DateTime(1984, 04, 01), 10, 10);
            manager.AddPlayer(5, 1, "Jogador 5", new DateTime(1983, 03, 01), 90, 100);
            manager.AddPlayer(7, 1, "Jogador 7", new DateTime(1999, 03, 01), 100, 100);
            manager.AddPlayer(11, 2, "Jogador 1", new DateTime(1995, 03, 01), 10, 10);
            manager.AddPlayer(12, 2, "Jogador 2", new DateTime(1997, 03, 01), 19, 100);
            manager.AddPlayer(13, 2, "Jogador 3", new DateTime(1983, 03, 01), 52, 100);
            Assert.Throws <UniqueIdentifierException>(() =>
                                                      manager.AddPlayer(1, 1, "Jogador 1", DateTime.Today, 0, 0));
            Assert.Throws <TeamNotFoundException>(() =>
                                                  manager.AddPlayer(99, 99, "Jogador 1", DateTime.Today, 0, 0));
            // search player
            Assert.Equal("Jogador 1", manager.GetPlayerName(1));
            Assert.Throws <PlayerNotFoundException>(() =>
                                                    manager.GetPlayerName(99));
            // search team
            Assert.Equal("Time 1", manager.GetTeamName(1));
            Assert.Throws <TeamNotFoundException>(() =>
                                                  manager.GetTeamName(99));
            // search players by team
            Assert.Equal(new List <long> {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            }, manager.GetTeamPlayers(1));
            Assert.Throws <TeamNotFoundException>(() =>
                                                  manager.GetTeamPlayers(99));
            // search best player on team
            Assert.Equal(7, manager.GetBestTeamPlayer(1));
            Assert.Throws <TeamNotFoundException>(() =>
                                                  manager.GetBestTeamPlayer(99));
            // search oldest player on team
            Assert.Equal(1, manager.GetOlderTeamPlayer(1));
            Assert.Throws <TeamNotFoundException>(() =>
                                                  manager.GetOlderTeamPlayer(99));
            // search all Teams
            Assert.Equal(new List <long> {
                1, 2, 3
            }, manager.GetTeams());
            // search higher salary by team
            Assert.Equal(2, manager.GetHigherSalaryPlayer(1));
            Assert.Throws <TeamNotFoundException>(() =>
                                                  manager.GetHigherSalaryPlayer(99));
            // search salary from player
            Assert.Equal(10, manager.GetPlayerSalary(1));
            Assert.Throws <PlayerNotFoundException>(() =>
                                                    manager.GetPlayerSalary(99));
            // search top players
            Assert.Equal(new List <long> {
                7, 5
            }, manager.GetTopPlayers(2));
            // search shirt color from visitor
            Assert.Equal("cor 2", manager.GetVisitorShirtColor(1, 2));
            Assert.Equal("cor 3", manager.GetVisitorShirtColor(1, 3));
            Assert.Throws <TeamNotFoundException>(() =>
                                                  manager.GetVisitorShirtColor(99, 1));
            Assert.Throws <TeamNotFoundException>(() =>
                                                  manager.GetVisitorShirtColor(1, 99));
            Assert.Throws <TeamNotFoundException>(() =>
                                                  manager.GetVisitorShirtColor(99, 99));
        }