Exemplo n.º 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);
        }
Exemplo n.º 2
0
        // Hard deletes a player from Player Table
        public void DeletePlayer(int PlayerID)
        {
            var delete = new Delete();

            delete.DeletePlayer(PlayerID);
        }