public void TestGetAchievementsCompletionState() { IGame se = new Game(_appid, "Space Engineers", "", TimeSpan.Zero); se.Achievements = _sut.GetAchievements(_appid); _sut.GetAchievementCompletionStates(_steamId, se); Assert.False(se.Achievements.First(a => a.Name == "Master Engineer").Completed); Assert.True(se.Achievements.Where(a => a.Name != "Master Engineer").All(a => a.Completed)); }
public void LoadFromApi() { ulong numericValue = Convert.ToUInt64(SteamId); if (numericValue > 0) { BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (sender, args) => { Status = "Loading user..."; Tuple <string, string> userInfo = _facade.GetUserInfo(numericValue); Status = Status + "\r\nLoading games..."; List <IGame> games = _facade.GetGamesOfUser(numericValue).ToList(); Status = Status + string.Format("\r\n\t-> Loaded {0} games", games.Count); List <IGame> gamesWithAchievements = new List <IGame>(games.Count); int i = 0; int gameCount = games.Count; foreach (IGame g in games) { Status = Status + string.Format("\r\nLoading achievements for '{0}' ({1})... ({2}/{3})", g.Name, g.AppId, i, gameCount); // Gets names, icons and global completion try { g.Achievements = _facade.GetAchievements(g.AppId); Status = Status + string.Format("\r\n\t-> Found {0} achievements", g.Achievements.Count()); if (g.Achievements.Any()) { gamesWithAchievements.Add(g); // Sets unlock state for current user Status = Status + string.Format("\r\nLoading achievement completion for '{0}' ({1})...", g.Name, g.AppId); _facade.GetAchievementCompletionStates(numericValue, g); } } catch (Exception ex) { Status = Status + "\r\nERROR: Could not load achievements: " + ex.Message; } i++; } User = new User(numericValue, userInfo.Item1, userInfo.Item2) { OwnedGames = games }; File.WriteAllText("E:\\data\\dev\\net\\achievement_planner_import.log", Status); }; bw.RunWorkerAsync(); } }