Can't seem to find what's wrong here, I'm using this method :
public void AddPlayerToTeam(Player player, Team team)
{
Team t = new Team();
if(team.PlayersList.Count>=20)
return;
if (!(team.PlayersList.Contains(player)))
team.PlayersList.Add(player);
}
and later in this test:
[TestMethod]
public void CheckTeamOfPlayer9()
{
Assert.AreEqual(wcm.GetPlayerById(9).PlayerTeam.CountryName, "Japan");
}
I get the following error: Object reference not set to an instance of an object.
with the null reference exception.
This is the method the test runs:
public Player GetPlayerById(int playerId)
{
var result = from b in Players
where b.PersonId.Equals(playerId)
select b;
return result.FirstOrDefault();
}
Any one has an idea?