public void TestPersonalScoreConstructorEmptyName()
        {
            string testName  = string.Empty;
            int    testscore = 12;

            PersonalScore testEntry = new PersonalScore(testName, testscore);

            Assert.AreEqual("Anonymous", testEntry.UserName, "User name should be Anonymous!");
        }
        public void TestPersonalScoreConstructor()
        {
            string testName  = "Pesho";
            int    testScore = 12;

            PersonalScore testEntry = new PersonalScore(testName, testScore);

            Assert.AreEqual(testName, testEntry.UserName, "They should be equal!");
            Assert.AreEqual(testScore, testEntry.UserScore, "They should be equal!");
        }
        public PersonalScore GetCurrentScorePreviousScoreAndRank(int userId, DateTime startDate, DateTime endDate)
        {
            PersonalScore personalScore = new PersonalScore();
            List <GetHighScoresForAllPlayersResultItem> dbResult = _gameRepository.GetHighScoresForAllPlayers(ROUNDS_PER_GAME, startDate, endDate).Results.OrderBy(x => x.AmountOfCorrectAnswers).ThenBy(x => x.Duration).ToList();

            // Set the rank
            for (int i = 0; i < dbResult.Count(); i++)
            {
                if (userId == dbResult[i].UserId)
                {
                    personalScore.Rank = i + 1; // 0 indexed but our ranks start at 1
                    break;
                }
            }

            GetHighScoresForIndividualPlayerResult highScoresIndividualResult = _gameRepository.GetHighScoresForIndividualPlayer(ROUNDS_PER_GAME, startDate, endDate, userId);

            personalScore.PersonalScoreItems = highScoresIndividualResult.Results.Select(PersonalScoreItemFactory.Create);

            return(personalScore);
        }