public void TestEnterTopScoreEmptyName() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); scores = new TopScores(); scores.EnterTopScore("", 0); scores.ShowTopScores(); string expected = "1 - 0\r\n"; string output = sw.ToString(); Assert.AreEqual<string>(expected, output); } }
public void TestShowTopScoresEmpty() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); scores = new TopScores(); scores.ShowTopScores(); string expected = "The scoreboard is empty.\r\n"; string output = sw.ToString(); Assert.AreEqual<string>(expected, output); } }
public void TestShowTopScoresCorrect() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); scores = new TopScores(); scores.EnterTopScore("ninja", 6); scores.EnterTopScore("ganio", 4); scores.EnterTopScore("ganio", 4); scores.EnterTopScore("sando", 5); scores.EnterTopScore("ninja", 5); scores.EnterTopScore("sando", 3); scores.ShowTopScores(); StringBuilder sBuild = new StringBuilder(); sBuild.Append("1 - sando 3\r\n"); sBuild.Append("2 - ganio 4\r\n"); sBuild.Append("3 - ganio 4\r\n"); sBuild.Append("4 - sando 5\r\n"); sBuild.Append("5 - ninja 5\r\n"); string expected = sBuild.ToString(); string output = sw.ToString(); Assert.AreEqual<string>(expected, output); } }