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);
        }
Esempio n. 2
0
 // Add player to database. Player object is assigned a PlayerID
 public void AddPlayer(Player player)
 {
     var create = new Create();
     create.AddPlayer(player);
 }