public void TestCmdExecutorFiveScores() { HighScores scores = new HighScores(5); scores.ProcessScore("pesho", 100); scores.ProcessScore("ivan", 80); scores.ProcessScore("gosho", 70); scores.ProcessScore("stamat", 60); scores.ProcessScore("petkan", 50); DefaultGameCommandExecutor cmdExecutor = new DefaultGameCommandExecutor(mockRenderer, mockInputMethod, scores); cmdExecutor.DisplayTopScores(); string scoreMessage = mockRenderer.GetMessage(); StringBuilder expectedScoreMessage = new StringBuilder(); expectedScoreMessage.Append("Scoreboard"); expectedScoreMessage.AppendLine("1. pesho --> 100"); expectedScoreMessage.AppendLine("2. ivan --> 80"); expectedScoreMessage.AppendLine("3. gosho --> 70"); expectedScoreMessage.AppendLine("4. stamat --> 60"); expectedScoreMessage.AppendLine("5. petkan --> 50"); Assert.AreEqual(expectedScoreMessage.ToString(), scoreMessage, "The message when the input is invalid is incorrect!"); }
public void TestProcessScore() { HighScores higScoresList = new HighScores(2); higScoresList.AddTopScore(new Player("a", 10)); higScoresList.AddTopScore(new Player("b", 2)); higScoresList.ProcessScore("mimi", 15); StringBuilder result = new StringBuilder(); result.Append("1. mimi --> 15\r\n"); result.Append("2. a --> 10\r\n"); string expected = result.ToString(); string actual = higScoresList.GetTopScores(); Assert.AreEqual(expected, actual); }
public void TestProcessScoreWithNegativeScore() { HighScores higScoresList = new HighScores(2); higScoresList.AddTopScore(new Player("a", 10)); higScoresList.AddTopScore(new Player("b", 2)); higScoresList.ProcessScore("mimi", -15); }