public void TestCompareTo_Compare10to9_SecondIsHigher() { ScoreRecord testedHighScore1 = new ScoreRecord("TestName1", 10); ScoreRecord testedHighScore2 = new ScoreRecord("TestName1", 9); int actual = testedHighScore1.CompareTo(testedHighScore2); int expected = 1; Assert.AreEqual(expected, actual); }
public void TestCompareTo_Compare9to10_AreEqual() { ScoreRecord testedHighScore1 = new ScoreRecord("TestName1", 10); ScoreRecord testedHighScore2 = new ScoreRecord("TestName1", 10); int actual = testedHighScore1.CompareTo(testedHighScore2); int expected = 0; Assert.AreEqual(expected, actual); }
/// <summary> /// Adds new score in the list only in case it is better that the already scored ones /// or there is free slot /// </summary> /// <param name="name">Player's name</param> /// <param name="score">Achieved result</param> public void AddScore(string name, int score) { ScoreRecord scoreRecord = new ScoreRecord(name, score); this.scoreRecordsList.Add(scoreRecord); this.scoreRecordsList.Sort(); if (this.scoreRecordsList.Count > this.maximumScoreboeardSize) { this.scoreRecordsList = this.scoreRecordsList.GetRange(0, this.maximumScoreboeardSize); } }
public void TestCompareTo_CompareWrongObject_ExpectedExcetion() { ScoreRecord testedHighScore = new ScoreRecord("TestName1", 10); Scoreboard comparableObject = new Scoreboard(1); testedHighScore.CompareTo(comparableObject); }
public void TestCompareTo_CompareNullObject_ExpectedExcetion() { ScoreRecord testedHighScore = new ScoreRecord("TestName1", 10); testedHighScore.CompareTo(null); }