public CanAddPlayer ( int movesCount ) : bool | ||
movesCount | int | The amount of moves a player has. |
Résultat | bool |
public bool CanAddPlayer(int movesCount)
{
bool listAcceptsEntries = this.table.Count < HighscoreTable.MaxPlayers;
bool hasLowerMoves = this.table.Any(x => movesCount < x.Moves);
return listAcceptsEntries || hasLowerMoves;
}
public void HighscoreTableShouldAddPlayerWhenNotReachedMaxPlayers() { List<PlayerScore> playerScores = new List<PlayerScore>(); for (int i = 0; i < HighscoreTable.MaxPlayers - 1; i++) { playerScores.Add(new PlayerScore(i.ToString(), i, DateTime.Now)); } HighscoreTable table = new HighscoreTable(playerScores); bool canAddPlayer = table.CanAddPlayer(10); Assert.IsTrue(canAddPlayer); }