public void TestCompareTwoPersonFirstOneWithTheSmallerScore()
        {
            Person firstPerson  = new Person("Pesho", 5);
            Person secondPerson = new Person("Vanya", 15);
            PersonScoreComparer personScoreComparer = new PersonScoreComparer();

            int result = personScoreComparer.Compare(firstPerson, secondPerson);

            Assert.AreEqual(-1, result);
        }
        public void TestCompareTwoPersonWithDifferentScore()
        {
            Person firstPerson  = new Person("Pesho", 15);
            Person secondPerson = new Person("Vanya", 10);
            PersonScoreComparer personScoreComparer = new PersonScoreComparer();

            int result = personScoreComparer.Compare(firstPerson, secondPerson);

            Assert.AreEqual(1, result);
        }
示例#3
0
 public void AddToTopScoreList(Person person)
 {
     topScoreList.Add(person);
     PersonScoreComparer comparer = new PersonScoreComparer();
     topScoreList.Sort(comparer);
     while (topScoreList.Count > 5)
     {
         topScoreList.RemoveAt(5);
     }
 }
示例#4
0
 public bool IsTopScore(Person person)
 {
     if (topScoreList.Count >= MAX_TOP_SCORE_COUNT)
     {
         PersonScoreComparer comparer = new PersonScoreComparer();
         topScoreList.Sort(comparer);
         if (topScoreList[MAX_TOP_SCORE_COUNT - 1] > person)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     return true;
 }