示例#1
0
 public MyProfileViewModel(LocalUser localuser)
 {
     this.User                  = localuser;
     this.KarmaPoints           = localuser.KarmaPoints;
     Badge                      = KarmaBadgeFetcher.CurrentBadge(localuser.KarmaPoints);
     NextBadge                  = KarmaBadgeFetcher.NextBadge(localuser.KarmaPoints);
     localuser.OnUpdateHandler += (user) =>
     {
         OnPropertyChanged("User");
         OnPropertyChanged("FirstName");
         OnPropertyChanged("LastName");
         OnPropertyChanged("FullName");
         OnPropertyChanged("ImageLocation");
         Badge     = KarmaBadgeFetcher.CurrentBadge(user.KarmaPoints);
         NextBadge = KarmaBadgeFetcher.NextBadge(user.KarmaPoints);
     };
 }
示例#2
0
        public void KarmaBadgeFetcherTest()
        {
            LocalUser         user   = UnitTestAuth.Login();
            var               status = KarmaBadgeListGetStatus.UnknownError;
            List <KarmaBadge> badges = null;
            bool              done   = false;


            var getter = KarmaBadgeSystemManager.NewKarmaBadgeListGetter();

            getter.Result += (_status, _badges) => {
                status = _status;
                badges = _badges;
                done   = true;
            };

            getter.Get();
            while (!done)
            {
            }
            if (badges != null)
            {
                badges.ForEach(badge =>
                {
                    Console.WriteLine(badge.Image + ", " + badge.Title + ", " + badge.StartValue);
                });
            }
            else
            {
                Console.WriteLine("Badges is null");
            }
            Assert.AreEqual(status, KarmaBadgeListGetStatus.Success);
            Assert.AreNotEqual(badges, null);
            KarmaBadgeFetcher.KarmaBadges = badges;
            badges.ForEach(badge =>
            {
                Assert.AreEqual(KarmaBadgeFetcher.CurrentBadge(badge.StartValue), badge);
            });
        }