Пример #1
0
        public void AddOneRecord()
        {
            HighScore highScore = new HighScore();
            highScore.AddResult("Pesho", 25);

            CollectionAssert.Contains(highScore.TopPlayers, new KeyValuePair<string, int>("Pesho", 25));
        }
Пример #2
0
 public GameEngine()
 {
     this.gameField = new GameField();
     this.playerMoveCount = 0;
     this.highScore = new HighScore();
     this.userInput = string.Empty;
     this.menuCommands = new string[] { "top", "restart", "exit" };
 }
Пример #3
0
        public void AddDuplicatedRecordTest()
        {
            HighScore highScore = new HighScore();
            highScore.AddResult("Pesho", 25);
            highScore.AddResult("Pesho", 25);

            Assert.IsTrue(highScore.TopPlayers.Count == 2);
        }
Пример #4
0
        public void AreRecordsSorted()
        {
            HighScore highScore = new HighScore();
            highScore.AddResult("Pesho", 25);
            highScore.AddResult("Pesho", 20);
            highScore.AddResult("Gosho", 15);
            highScore.AddResult("Petkan", 26);
            highScore.AddResult("Jorkan", 18);

            Assert.IsTrue(AreSortedDescending(highScore.TopPlayers));
        }
Пример #5
0
        public void AddFiveRecords()
        {
            HighScore highScore = new HighScore();
            highScore.AddResult("Pesho", 25);
            highScore.AddResult("Pesho", 20);
            highScore.AddResult("Gosho", 15);
            highScore.AddResult("Petkan", 26);
            highScore.AddResult("Jorkan", 18);

            Assert.IsTrue(highScore.TopPlayers.Count == 5);
        }
Пример #6
0
        public void AddSixRecords()
        {
            HighScore highScore = new HighScore();
            highScore.AddResult("Pesho", 25);
            highScore.AddResult("Pesho", 20);
            highScore.AddResult("Gosho", 15);
            highScore.AddResult("Petkan", 26);
            highScore.AddResult("Jorkan", 18);
            highScore.AddResult("Jorkan", 18);

            Assert.AreEqual(5, highScore.TopPlayers.Count);
        }
Пример #7
0
        public void AddingNotTopResult()
        {
            HighScore highScore = new HighScore();
            highScore.AddResult("Pesho", 25);
            highScore.AddResult("Pesho", 20);
            highScore.AddResult("Gosho", 15);
            highScore.AddResult("Petkan", 26);
            highScore.AddResult("Jorkan", 18);
            highScore.AddResult("NotTopResult", 50);

            CollectionAssert.Contains(highScore.TopPlayers, new KeyValuePair<string, int>("NotTopResult", 50));
        }
Пример #8
0
        public void IsTopResult()
        {
            HighScore highScore = new HighScore();
            highScore.AddResult("Pesho", 25);
            highScore.AddResult("Pesho", 20);
            highScore.AddResult("Gosho", 15);
            highScore.AddResult("Petkan", 26);
            highScore.AddResult("Jorkan", 18);

            Assert.IsTrue(highScore.IsTopResult(5));
        }
Пример #9
0
        public void PrintHighScoreTest()
        {
            HighScore highScore = new HighScore();
            highScore.AddResult("Pesho", 25);
            highScore.AddResult("Pesho", 20);
            highScore.AddResult("Gosho", 15);
            highScore.AddResult("Petkan", 26);
            highScore.AddResult("Jorkan", 18);
            highScore.AddResult("NotTopResult", 50);

            StringBuilder result = new StringBuilder();
            int printLimit = highScore.TopPlayers.Count;

            for (int index = 0; index < printLimit; index++)
            {
                string playerName = highScore.TopPlayers[index].Key;
                string playerResult = highScore.TopPlayers[index].Value.ToString();

                result.Append(playerName).Append("->").AppendLine(playerResult);
            }

            result.Append(Environment.NewLine);
            string actual =  result.ToString();

            string expected = highScore.ToString();
            Assert.AreEqual(expected, actual);
        }