예제 #1
0
        private void IsNewHighscoreTest(TestHighscoreListType type, int time, int points, bool isNew)
        {
            Highscore highscore = new Highscore()
            {
                Points     = (uint)points,
                GameTime   = TimeSpan.FromSeconds(time),
                PlayerName = "player"
            };
            var list  = ProvideList((int)type);
            var clone = new List <Highscore>(list);
            ISettingsProvider provider = new TestSettingsProvider();

            provider.Highscores = list;
            provider.Save();
            HighscoreList highscoreList = new HighscoreList(provider);
            bool          b             = highscoreList.IsNewHighscore(highscore);

            Assert.Equal(isNew, b);
            if (isNew)
            {
                highscoreList.AddHighscore(highscore);
            }
            Assert.True(highscoreList.Highscores.Count <= 10);
            if (isNew)
            {
                clone.Add(highscore);
            }
            clone.Sort(new HighscoreComparer());
            clone = clone.Take(10).ToList();
            Assert.Equal(clone.Count, highscoreList.Highscores.Count);
            for (int i = 0; i < list.Count; i++)
            {
                Assert.Equal(clone[i], highscoreList.Highscores[i]);
            }
        }
예제 #2
0
 /// <summary>
 /// Overrides OnViewAppeared method and checking information about the highscore before the view appears.
 /// </summary>
 protected override void OnViewAppeared()
 {
     _highscores.RefreshList();
     IsHighscore = _highscores.IsNewHighscore(CreateHighscore());
     PlayerName  = null;
 }