public void TestIsHightScore_StoredRecordIs10MaxRecords1_15IsNotNewHighScore() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(1); scoreboard.AddScore("Record Name Higher", 10); bool isHighScore = scoreboard.IsHightScore(15); Assert.IsFalse(isHighScore); }
public void TestIsHightScore_StoredRecordIs20MaxRecords1_15IsNewHighScore() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(1); scoreboard.AddScore("Record Name Lower", 20); bool isHighScore = scoreboard.IsHightScore(15); Assert.IsTrue(isHighScore); }
public void TestAddScore_1Record_NumberOfStoredREcordsIs1() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(5); scoreboard.AddScore("Record Name", 10); int expected = 1; int actual = scoreboard.scoreRecordsList.Count; Assert.AreEqual(expected, actual); }
public void TestAddScore_StoreRecords10and5and15_LowestRecordIs15() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(5); scoreboard.AddScore("Record Name Lower", 10); scoreboard.AddScore("Record Name Hightr", 5); scoreboard.AddScore("Record Name Lowest", 15); int expected = 15; int actual = scoreboard.GetLowestScore(scoreboard.scoreRecordsList); Assert.AreEqual(expected, actual); }
public void TestAddScore_Store3Rrecords_RecordsSortedAscending() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(5); scoreboard.AddScore("Record Name Lower", 15); scoreboard.AddScore("Record Name Hightr", 10); ScoreRecord highScore = (ScoreRecord)scoreboard.scoreRecordsList[0]; string expected = "Record Name Hightr"; string actual = highScore.PlayerName; Assert.AreEqual(expected, actual); }
public void TestAddScore_3Record_NumberOfStoredREcordsIs3() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(2); scoreboard.AddScore("Record Name 1", 10); scoreboard.AddScore("Record Name 2", 15); scoreboard.AddScore("Record Name 3", 20); int expected = 2; int actual = scoreboard.scoreRecordsList.Count; Assert.AreEqual(expected, actual); }
public void TestAddNewResult() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(); PlayerInfo newPlayer = new PlayerInfo("Gosho",15); scoreboard.AddNewResult(newPlayer); int expectedLenght = 1; int actualLenght = scoreboard.scoreboard.Count; Assert.AreEqual<int>(expectedLenght, actualLenght, "There was a problem in adding a new result to the scoreboard!"); }
public void TestToStringSortingDifferentPlayerNamesEqualGuessesCounts() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(); string[] names = { "Zoltan", "Yohan", "Kalin", "Barni", "Anton" }; for (int i = 0; i < 5; i++) { PlayerInfo newPlayer = new PlayerInfo(names[i], 2); scoreboard.AddNewResult(newPlayer); } string expected = "Scoreboard:" + Environment.NewLine + "1. Anton --> 2 guesses" + Environment.NewLine + "2. Barni --> 2 guesses" + Environment.NewLine + "3. Kalin --> 2 guesses" + Environment.NewLine + "4. Yohan --> 2 guesses" + Environment.NewLine + "5. Zoltan --> 2 guesses" + Environment.NewLine; string actual = scoreboard.ToString(); Assert.AreEqual<string>(expected, actual, INCORRECT_STRING_MSG); }
public void TestToStringSortingDifferentGuessesCounts() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(); for (int i = 1; i < 10; i++) { PlayerInfo newPlayer = new PlayerInfo("Gosho", i); scoreboard.AddNewResult(newPlayer); } string expected = "Scoreboard:" + Environment.NewLine + "1. Gosho --> 1 guess" + Environment.NewLine + "2. Gosho --> 2 guesses" + Environment.NewLine + "3. Gosho --> 3 guesses" + Environment.NewLine + "4. Gosho --> 4 guesses" + Environment.NewLine + "5. Gosho --> 5 guesses" + Environment.NewLine; string actual = scoreboard.ToString(); Assert.AreEqual<string>(expected, actual, INCORRECT_STRING_MSG); }
public void TestPrintScoreboard_EmptyList_EmptyScoreboardPrinted() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(5); string consoleInput = string.Empty; StringWriter consoleWriter; TestUtilities.RedirectConsoleStram(consoleInput, out consoleWriter); scoreboard.PrintScoreboard(); string actual = TestUtilities.GetConsoleOutput(consoleWriter); string expected = "The scoreboard is empty.\r\n"; Assert.AreEqual(expected, actual); }
public void TestScoreboardConstructor_SetMaximumRecords5_ScoreRecordsCountIs5() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(5); int expected = 5; int actual = scoreboard.maximumScoreboeardSize; Assert.AreEqual(expected, actual); }
public void TestPrintScoreboard_Store1Record_1LinePrinted() { Scoreboard_Accessor scoreboard = new Scoreboard_Accessor(5); scoreboard.AddScore("Record Name Lower", 10); string consoleInput = string.Empty; StringWriter consoleWriter; TestUtilities.RedirectConsoleStram(consoleInput, out consoleWriter); scoreboard.PrintScoreboard(); string actual = TestUtilities.GetConsoleOutput(consoleWriter); string expected = "Scoreboard:\r\n" + "1. Record Name Lower --> 10 moves.\r\n"; Assert.AreEqual(expected, actual); }