public void ParseClosedValid()
        {
            string xml = File.ReadAllText("achievements.xml");

            AchievementXmlParser      parser       = new AchievementXmlParser();
            IEnumerable <Achievement> achievements = parser.ParseClosed(xml);

            Assert.That(achievements.Any());
            Assert.That(achievements.Any(a => a.Name == "Fried Piper" && a.Closed));
            Assert.That(!achievements.Any(a => !a.Closed));
        }
        public void ParseClosedValid()
        {
            string xml = File.ReadAllText("achievements.xml");

            AchievementXmlParser          parser       = new AchievementXmlParser();
            IEnumerable <UserAchievement> achievements = parser.ParseClosed(xml);

            Assert.That(achievements.Any());
            Assert.That(achievements.All(a => a.SteamUserId == "nullreference"));
            Assert.That(achievements.Any(a => a.Name == "Fried Piper" && a.Closed));
            Assert.That(!achievements.Any(a => !a.Closed));
            Assert.That(achievements.Any(a => a.Name == "Midnight Rider" && a.Closed && a.Date.Ticks == 1261871228));
        }
        public void ParseClosedValid()
        {
            string xml = File.ReadAllText("achievements.xml");

            AchievementXmlParser          parser       = new AchievementXmlParser();
            IEnumerable <UserAchievement> achievements = parser.ParseClosed(xml);

            DateTime expectedUnlockDate = new DateTime(1970, 1, 1).AddSeconds(1261871228);

            Assert.That(achievements.Any());
            Assert.That(achievements.All(a => a.SteamUserId == "nullreference"));
            Assert.That(achievements.Any(a => a.Achievement.Name == "Fried Piper" && a.Closed));
            Assert.That(!achievements.Any(a => !a.Closed));
            Assert.That(
                achievements.Any(a => a.Achievement.Name == "Midnight Rider" && a.Closed && a.Date.Ticks == expectedUnlockDate.Ticks));
        }
        public void UpdateNewUserAchievements()
        {
            Mock <IAchievementManager>    achievementManagerMock = new Mock <IAchievementManager>();
            Mock <ISteamCommunityManager> communityManagerMock   = new Mock <ISteamCommunityManager>();

            // expect
            User user = new User {
                FacebookUserId = 1234, SteamUserId = "user1"
            };

            Data.User dataUser = new Data.User {
                FacebookUserId = 1234, SteamUserId = "user1"
            };
            achievementManagerMock.Setup(rep => rep.GetUser(user.FacebookUserId))
            .Returns(dataUser).Verifiable();

            AchievementXmlParser   achievementXmlParser = new AchievementXmlParser();
            List <UserAchievement> userAchievements     =
                achievementXmlParser.ParseClosed(File.ReadAllText("cssAchievements.xml")).ToList();

            userAchievements.ForEach(
                userAchievement =>
                userAchievement.Game =
                    new Game
            {
                Id       = 240,
                ImageUrl =
                    "http://media.steampowered.com/steamcommunity/public/images/apps/10/af890f848dd606ac2fd4415de3c3f5e7a66fcb9f.jpg",
                Name           = "Counter-Strike: Source",
                PlayedRecently = true,
                StatsUrl       =
                    String.Format("http://steamcommunity.com/id/{0}/games/?xml=1", user.SteamUserId),
                StoreUrl = "http://store.steampowered.com/app/10"
            });

            communityManagerMock.Setup(rep => rep.GetAchievements(user.SteamUserId))
            .Returns(new List <UserAchievement>()).Verifiable();

            achievementManagerMock.Setup(rep => rep.GetUser(user.SteamUserId))
            .Returns(dataUser).Verifiable();
            achievementManagerMock.Setup(rep => rep.UpdateAchievements(It.IsAny <IEnumerable <Data.UserAchievement> >()))
            .Returns(5).Verifiable();

            ICollection <Game> games = new GameXmlParser().Parse(File.ReadAllText("games.xml"));

            communityManagerMock.Setup(rep => rep.GetGames(user.SteamUserId))
            .Returns(games).Verifiable();

            Achievement[] dataAchievements = new[] { new Achievement {
                                                         Description = "x", GameId = 1, Id = 1,
                                                     } };
            achievementManagerMock.Setup(
                rep => rep.GetUnpublishedAchievements(user.SteamUserId, DateTime.UtcNow.Date.AddDays(-2)))
            .Returns(dataAchievements).Verifiable();
            achievementManagerMock.Setup(
                rep =>
                rep.UpdateHidden(user.SteamUserId, It.IsAny <IEnumerable <int> >()))
            .Verifiable();

            // execute
            IAchievementService service =
                new AchievementService(achievementManagerMock.Object, communityManagerMock.Object);

            service.UpdateNewUserAchievements(user);

            // verify
            achievementManagerMock.Verify();
            communityManagerMock.Verify();
        }