public void ItFetchesGameDefinitions()
        {
            var playedGames    = _retriever.GetRecentGames(1, testUserWithDefaultGamingGroup.CurrentGamingGroupId.Value);
            var gameDefinition = playedGames[0].GameDefinition;

            Assert.NotNull(gameDefinition);
        }
예제 #2
0
        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());
            }
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
        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());
            }
        }
예제 #5
0
        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);
                }
            }
        }
예제 #6
0
 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);
         }
     }
 }
예제 #7
0
        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;
                }
            }
        }