Beispiel #1
0
        public void GetAchievementCountByTier_ShouldReturnTierCount(Fixture fixture, AchievementList achievements)
        {
            new List <AchievementTier>
            {
                AchievementTier.Bronze,
                AchievementTier.Gold,
                AchievementTier.Silver,
                AchievementTier.Silver,
                AchievementTier.Silver,
                AchievementTier.Gold
            }.ForEach(tier => achievements.Add(new Achievement {
                Tier = tier
            }));

            var groups = achievements.GetAchievementCountByTier();

            groups.Keys.Should().HaveCount(3);
            groups[AchievementTier.Gold].Should().Be(2);
            groups[AchievementTier.Silver].Should().Be(3);
            groups[AchievementTier.Bronze].Should().Be(1);
        }
Beispiel #2
0
        /// <summary>
        /// A basic overview of a set of Achievements
        /// </summary>
        /// <param name="achievements">A set of Achievements to be desplyed</param>
        /// <param name="achievementManager">The AchievementManager to get all the infos from</param>
        public AchievementOverviewControl(IEnumerable <Achievement> achievements, AchievementManager achievementManager)
        {
            this.achievementManager = achievementManager;
            InitializeComponent();

            // initialize the achievementList
            achievementList = new ObservableCollection <Achievement>();

            if (achievements == null)
            {
                // If the Control is invoked without a list of Achivements to display it will register
                // to AchievementManager.Instance.AchievementsChanged and will load all registered Achievements
                achievementManager.AchievementRegistered += AchievementRegisteredHandler;

                // Get all already registered Achievements and add them to the list
                achievements = achievementManager.AchievementList;
            }

            // Add all Achievements to our List
            foreach (Achievement achievement in achievements)
            {
                AchievementList.Add(achievement);
            }
        }
Beispiel #3
0
 /// <summary>
 /// When the AchievementManager class fires the AchievementRegistered event the newly registered Achievement will be added to our AchievementList
 /// </summary>
 private void AchievementRegisteredHandler(Achievement a)
 {
     AchievementList.Add(a);
 }