public void AddingPlayerToHighscoreTableShouldWorkCorrectly() { HighscoreTable table = new HighscoreTable(); PlayerScore somePlayer = new PlayerScore("Pesho", 10, DateTime.Now); table.AddPlayer(somePlayer); Assert.AreEqual(1, table.Table.Count); }
public void TestIfToStringListsCorrectlyReturnsAHighscoreTableAsStringLists() { var table = new HighscoreTable(); var sampleStringTable = new List<List<string>>() { new List<string>() { "tosho", "8" }, new List<string>() { "gosho", "28" }, new List<string>() { "pesho", "30" } }; foreach (var record in sampleStringTable) { var score = new PlayerScore(record[0], int.Parse(record[1]), DateTime.Now); } var asStringLists = table.ToStringLists(); for (int i = 0, length = asStringLists.Count; i < length; i++) { for (int j = 0, length2 = asStringLists[i].Count; j < length2; j++) { Assert.AreEqual(sampleStringTable[i][j], asStringLists[i][j]); } } }
public void HighscoreTableShouldWorkWithPredefinedListOfPlayers() { List<PlayerScore> playerScores = new List<PlayerScore> { new PlayerScore("Pesho", 10, DateTime.Now), new PlayerScore("Pesho", 10, DateTime.Now), new PlayerScore("Pesho", 10, DateTime.Now), new PlayerScore("Pesho", 10, DateTime.Now) }; HighscoreTable table = new HighscoreTable(playerScores); Assert.AreEqual(4, table.Table.Count); }
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); }
public void HighscoreTableShouldAddPlayerWhenHisScoreIsLowerThanOthers() { List<PlayerScore> playerScores = new List<PlayerScore>(); for (int i = 0; i < HighscoreTable.MaxPlayers; i++) { playerScores.Add(new PlayerScore(i.ToString(), i + 1, DateTime.Now)); } HighscoreTable table = new HighscoreTable(playerScores); bool canAddPlayer = table.CanAddPlayer(0); Assert.IsTrue(canAddPlayer); }
public void TestIfPrintHighscorePrintTheTableInCorrectFormat() { var now = DateTime.Now; var bivanScore = new PlayerScore("bay ivan", 10, now); var goshoScore = new PlayerScore("goshoto", 9, now); var mariaScore = new PlayerScore("mariya", 11, now); var tableToPrint = new HighscoreTable(new List<PlayerScore>() { bivanScore, goshoScore, mariaScore }); this.controller.PrintHighscore(tableToPrint); var highscoreChildren = this.view.Rankings.Children.Cast<Border>().Select(x => { return (x.Child as TextBlock).Text; }).ToList(); }
public void HighscoreTableSizeShouldNotChangeWhenAddingMoreThanMaxPlayers() { List<PlayerScore> playerScores = new List<PlayerScore>(); for (int i = 0; i < HighscoreTable.MaxPlayers; i++) { playerScores.Add(new PlayerScore(i.ToString(), i, DateTime.Now)); } HighscoreTable table = new HighscoreTable(playerScores); PlayerScore somePlayer = new PlayerScore("Pesho", 10, DateTime.Now); table.AddPlayer(somePlayer); Assert.AreEqual(HighscoreTable.MaxPlayers, table.Table.Count); }
public void HighscoreTableShouldInitiallyHaveZeroPlayers() { HighscoreTable table = new HighscoreTable(); Assert.AreEqual(0, table.Table.Count); }