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(); }