public void ItFetchesGameDefinitions() { var playedGames = _retriever.GetRecentGames(1, testUserWithDefaultGamingGroup.CurrentGamingGroupId.Value); var gameDefinition = playedGames[0].GameDefinition; Assert.NotNull(gameDefinition); }
public void ItReturnsOnlyOneGameIfOneGameIsSpecified() { using (NemeStatsDataContext dataContext = new NemeStatsDataContext()) { PlayedGameRetriever retriever = new PlayedGameRetriever(dataContext); int one = 1; List <PlayedGame> playedGames = retriever.GetRecentGames(one, testUserWithDefaultGamingGroup.CurrentGamingGroupId); Assert.AreEqual(one, playedGames.Count()); } }
public void ItOnlyReturnsGamesForTheCurrentUsersGamingGroup() { using (NemeStatsDataContext dataContext = new NemeStatsDataContext()) { PlayedGameRetriever retriever = new PlayedGameRetriever(dataContext); List <PlayedGame> playedGames = retriever.GetRecentGames(20, testUserWithOtherGamingGroup.CurrentGamingGroupId); Assert.True(playedGames.All(game => game.GamingGroupId == testUserWithOtherGamingGroup.CurrentGamingGroupId)); } }
public void ItReturnsOnlyTwoGamesIfTwoGamesAreSpecified() { using (NemeStatsDataContext dataContext = new NemeStatsDataContext()) { PlayedGameRetriever retriever = new PlayedGameRetriever(dataContext); int two = 2; List <PlayedGame> playedGames = retriever.GetRecentGames(two, testUserWithDefaultGamingGroup.CurrentGamingGroupId); Assert.AreEqual(two, playedGames.Count()); } }
public void ItEagerlyFetchesPlayerGameResults() { using (NemeStatsDbContext dbContext = new NemeStatsDbContext()) { dbContext.Configuration.LazyLoadingEnabled = false; dbContext.Configuration.ProxyCreationEnabled = false; using (NemeStatsDataContext dataContext = new NemeStatsDataContext(dbContext, securedEntityValidatorFactory)) { PlayedGameRetriever retriever = new PlayedGameRetriever(dataContext); List <PlayedGame> playedGames = retriever.GetRecentGames(1, testUserWithDefaultGamingGroup.CurrentGamingGroupId); ICollection <PlayerGameResult> playerGameResults = playedGames[0].PlayerGameResults; Assert.NotNull(playerGameResults); } } }
public void ItReturnsGamesInDescendingOrderByDatePlayed() { using (NemeStatsDataContext dataContext = new NemeStatsDataContext()) { PlayedGameRetriever retriever = new PlayedGameRetriever(dataContext); int five = 5; List <PlayedGame> playedGames = retriever.GetRecentGames(five, testUserWithDefaultGamingGroup.CurrentGamingGroupId); List <PlayedGame> allPlayedGames = dataContext.GetQueryable <PlayedGame>() .Where(game => game.GamingGroupId == testUserWithDefaultGamingGroup.CurrentGamingGroupId) .ToList() .OrderByDescending(playedGame => playedGame.DatePlayed) .ToList(); for (int i = 0; i < five; i++) { Assert.AreEqual(allPlayedGames[i].Id, playedGames[i].Id); } } }
public void ItReturnsOrderedPlayerRankDescendingWithinAGivenGame() { using (NemeStatsDataContext dataContext = new NemeStatsDataContext()) { PlayedGameRetriever retriever = new PlayedGameRetriever(dataContext); int five = 5; List <PlayedGame> playedGames = retriever.GetRecentGames(five, testUserWithDefaultGamingGroup.CurrentGamingGroupId); int lastRank = -1; foreach (PlayedGame playedGame in playedGames) { foreach (PlayerGameResult playerGameResult in playedGame.PlayerGameResults) { Assert.True(lastRank <= playerGameResult.GameRank); lastRank = playerGameResult.GameRank; } lastRank = -1; } } }