public void TeamPlayerService_AddTeamPlayer_Success() { TeamPlayer tp = new TeamPlayer { }; // Create user User u = new User { ForeName = "Test", SurName = "Test", Password = "******", Role = Role.User, UserName = "******" }; u.Id = userSvc.RegisterUser(u); // Create team matching user Id Team t = new Team { Forename = "Test", Surname = "Test", TeamName = "TestTeamName", UserId = u.Id }; t = teamSvc.AddTeam(t); // Add TP to team matching team id tp = svc.AddTeamPlayer(t.Id, 1); IList <Player> actualTeamPlayers = svc.GetPlayersByTeamId(t.Id); Player expectedP = playerSvc.GetPlayerById(1); Assert.Equal(expectedP.Id, actualTeamPlayers[0].Id); }
public ActionResult <IList <TeamPlayer> > Get(int id) { IList <Player> teamPlayer = _service.GetPlayersByTeamId(id); if (teamPlayer == null) { return(NotFound()); } return(Ok(teamPlayer)); }