Пример #1
0
        public void AddAndDeletePlayerTest()
        {
            var player = new Player();
            player.FirstName = "TestFirstName";
            player.LastName = "TestLastName";
            player.JerseyNumber = 99;
            player.TeamID = 1;
            player.LastYearBA = 0;
            player.YearsPlayed = 3;
            player.PrimaryPositionID = 1;
            player.SecondaryPositionID = 2;

            //Add new player to Team 1
            var repo = new Create();
            repo.AddPlayer(player);

            //Get team roster and verify new player was added
            var readRepo = new Read();
            var players = readRepo.GetTeamRoster(1);
            var playerCount = players.Count;
            var newPlayer = players.FirstOrDefault(p => p.JerseyNumber == player.JerseyNumber);

            //Assert player added is on the roster
            Assert.AreEqual(newPlayer.JerseyNumber, player.JerseyNumber);

            //Delete Player from database
            var deleteRepo = new Delete();
            deleteRepo.DeletePlayer(newPlayer.PlayerID.Value);

            //Get count of players on roster after delete
            var playerCountAfterDelete = readRepo.GetTeamRoster(1).Count;

            //Assert player count reduced after player deleted
            Assert.AreEqual(playerCount - 1, playerCountAfterDelete);
        }
Пример #2
0
        public void TestFreeAgentList()
        {
            var repo = new Read();
            var players = repo.GetFreeAgents();

            //Check for players assigned to teams
            var nonFreeAgents = players.Where(p => p.TeamID != 1).ToList();

            Assert.AreEqual(0, nonFreeAgents.Count);
        }
Пример #3
0
        public void ReleasePlayerTest(int playerID)
        {
            //Release Player to Free Agency
            var repo = new Update();
            repo.ReleasePlayer(playerID);

            //Get Free Agency players and check for released player
            var readRepo = new Read();
            var players = readRepo.GetFreeAgents();
            var player = players.FirstOrDefault(p => p.PlayerID == playerID);
            Assert.AreEqual(player.PlayerID, playerID);
        }
Пример #4
0
        // Retrieves a list of all teams
        public List<Team> GetTeams()
        {
            var read = new Read();

            return read.GetTeams();
        }
Пример #5
0
        // Retrieves a list of all players of a specific team
        public List<Player> GetTeamRoster(int TeamID)
        {
            var read = new Read();

            return read.GetTeamRoster(TeamID);
        }
Пример #6
0
        // Retrieves a list of all players that DO NOT belong to a team
        public List<Player> GetFreeAgents()
        {
            var read = new Read();

            return read.GetFreeAgents();
        }
Пример #7
0
        // Retrieves a list of all players that belong to a team
        public List<Player> GetAllPlayers()
        {
            var read = new Read();

            return read.GetAllPlayers();
        }
Пример #8
0
        public void TradePlayerTest(int playerID, int tradeTeamId)
        {
            var repo = new Update();
            repo.TradePlayer(playerID, tradeTeamId);

            var readRepo = new Read();
            var players = readRepo.GetTeamRoster(tradeTeamId);
            var player = players.FirstOrDefault(p => p.PlayerID == playerID);
            Assert.AreEqual(player.PlayerID, playerID);
        }
Пример #9
0
 public void TestGetAllPlayers()
 {
     var repo = new Read();
     var playersCount = repo.GetAllPlayers().Count;
     Assert.AreNotEqual(0, playersCount);
 }