Esempio n. 1
0
 public void TeamPlayerListCloneTest()
 {
     var players = new List<int>();
     foreach (var player in GetPlayers())
     {
         players.Add(player.Key);
     }
     var team = new Team("WildCats", "4545454", players);
     Assert.AreSame(team.GetPlayerIDs(), players);
     Assert.AreNotSame(team.ClonePlayerIDs(), players);
 }
Esempio n. 2
0
 public void SetTeamDetail(int teamID)
 {
     this.teamID = teamID;
     team = fileHandler.GetTeam(teamID);
     teamView.SetTeam(team);
     var playerIDs = team.GetPlayerIDs();
     players = new Dictionary<int, Player>();
     foreach(var ID in playerIDs)
     {
         players.Add(ID, fileHandler.GetPlayer(ID));
     }
     teamView.ShowPlayers(players);
 }
Esempio n. 3
0
        public void TeamTestAddPlayers()
        {
            var team = new Team("Wildcats", "47404049", new List<int>());
            var players = GetPlayers();
            foreach(var player in players)
            {
                team.AddPlayer(player.Value.GetP_ID());
            }
            var teamPlayers = team.GetPlayerIDs();

            foreach (var player in players)
            {
                Assert.IsTrue(teamPlayers.Contains(player.Value.GetP_ID()));
            }
        }
 public void UpdateTeam(Team team)
 {
     var teamID = team.GetTeamID();
     teams[teamID] = team;
     var queries = new List<string>();
     queries.Add(SqlQueries.DeleteTeamPlayers(teamID));
     foreach (var playerID in team.GetPlayerIDs())
     {
         queries.Add(SqlQueries.InsertPlayerTeam(teamID, playerID));
     }
     queries.Add(SqlQueries.UpdateTeam(teamID, team.GetTeamName(), team.GetTeamContact()));
     foreach (var query in queries)
     {
         var command = new SQLiteCommand(query, dbConnection);
         command.ExecuteNonQuery();
     }
 }
 public void InsertTeam(Team team)
 {
     var teamID = teamCounter++;
     team.SetTeamID(teamID);
     teams.Add(teamID, team.Clone());
     var queries = new List<string>();
     queries.Add(SqlQueries.InsertTeam(teamID, team.GetTeamName(), team.GetTeamContact()));
     foreach (var playerID in team.GetPlayerIDs())
     {
         queries.Add(SqlQueries.InsertPlayerTeam(teamID, playerID));
     }
     foreach (var query in queries)
     {
         var command = new SQLiteCommand(query, dbConnection);
         command.ExecuteNonQuery();
     }
 }