Inheritance: INemesisHistoryRetriever
        public void SetUp()
        {
            dataContextMock = MockRepository.GenerateMock<IDataContext>();
            nemesisHistoryRetriever = new NemesisHistoryRetriever(dataContextMock);

            List<Nemesis> nemeses = new List<Nemesis>
            {
                BuildNemesisItem(nemesisPlayerId1, nemesisPlayerName1, repeatedMinionPlayerId, repeatedMinionPlayerName1, lossPercentage, 0),
                BuildNemesisItem(35, "another nemesis player name", repeatedMinionPlayerId, repeatedMinionPlayerName1, 59, 1),
                BuildNemesisItem(36, "nemesis3", 515, "minion3", 59, 3),
                BuildNemesisItem(37, "nemesis4", 516, "minion4", 100, 2),
                BuildNemesisItem(39, "nemesis5", 515116, "minion4", 70, 5)

            };

            dataContextMock.Expect(mock => mock.GetQueryable<Nemesis>())
                           .Return(nemeses.AsQueryable());
        }
        public void ItEagerlyFetchesGameDefinitions()
        {
            using (NemeStatsDbContext dbContext = new NemeStatsDbContext())
            {
                using (IDataContext dataContext = new NemeStatsDataContext(dbContext, securedEntityValidatorFactory))
                {
                    dbContext.Configuration.LazyLoadingEnabled = false;
                    dbContext.Configuration.ProxyCreationEnabled = false;
                    INemesisHistoryRetriever nemesisHistoryRetriever = new NemesisHistoryRetriever(dataContext);
                    IPlayerRepository playerRepository = new EntityFrameworkPlayerRepository(dataContext);
                    IPlayedGameRetriever playedGameRetriever = new PlayedGameRetriever(dataContext);
                    IPlayerRetriever playerRetriever = new PlayerRetriever(dataContext, playerRepository, playedGameRetriever);
                    PlayerDetails testPlayerDetails = playerRetriever.GetPlayerDetails(testPlayer1.Id, 1);

                    Assert.NotNull(testPlayerDetails.PlayerGameResults.First().PlayedGame.GameDefinition);
                }
            }
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            dataContextMock = MockRepository.GenerateMock<IDataContext>();
            nemesisHistoryRetriever = new NemesisHistoryRetriever(dataContextMock);

            List<Nemesis> nemeses = new List<Nemesis>();
            nemeses.Add(new Nemesis
            {
                Id = 4567,
                MinionPlayerId = playerIdWithOneNemesisOnly,
                MinionPlayer = new Player{ NemesisId = 4567 },
                NemesisPlayer = new Player(),
                DateCreated = new DateTime(2010, 1, 1)

            });
            nemeses.Add(new Nemesis
            {
                MinionPlayerId = playerIdUnderTest,
                MinionPlayer = new Player(),
                NemesisPlayer = new Player(),
                DateCreated = new DateTime(2011, 1, 1)
            });
            nemeses.Add(new Nemesis
            {
                MinionPlayerId = playerIdUnderTest,
                MinionPlayer = new Player{ Id = playerIdOfPreviousNemesis },
                NemesisPlayer = new Player(),
                DateCreated = new DateTime(2012, 1, 1)
            });
            nemeses.Add(new Nemesis
            {
                Id = 1234,
                MinionPlayerId = playerIdUnderTest,
                MinionPlayer = new Player { Id = playerIdOfCurrentNemesis, NemesisId = 1234 },
                NemesisPlayer = new Player(),
                DateCreated = new DateTime(2013, 1, 1)
            });

            dataContextMock.Expect(mock => mock.GetQueryable<Nemesis>())
                           .Return(nemeses.AsQueryable());
        }
        public void ItSetsPlayerStatistics()
        {
            using (NemeStatsDbContext dbContext = new NemeStatsDbContext())
            {
                using (IDataContext dataContext = new NemeStatsDataContext(dbContext, securedEntityValidatorFactory))
                {
                    INemesisHistoryRetriever nemesisHistoryRetriever = new NemesisHistoryRetriever(dataContext);
                    IPlayerRepository playerRepository = new EntityFrameworkPlayerRepository(dataContext);
                    IPlayedGameRetriever playedGameRetriever = new PlayedGameRetriever(dataContext);
                    IPlayerRetriever playerRetriever = new PlayerRetriever(dataContext,  playerRepository, playedGameRetriever);
                    PlayerDetails playerDetails = playerRetriever.GetPlayerDetails(testPlayer1.Id, 1);

                    Assert.NotNull(playerDetails.PlayerStats);
                }
            }
        }
        public void ItOrdersPlayerGameResultsByTheDatePlayedDescending()
        {
            using (NemeStatsDbContext dbContext = new NemeStatsDbContext())
            {
                using (IDataContext dataContext = new NemeStatsDataContext(dbContext, securedEntityValidatorFactory))
                {
                    int numberOfGamesToRetrieve = 3;

                    INemesisHistoryRetriever nemesisHistoryRetriever = new NemesisHistoryRetriever(dataContext);
                    IPlayerRepository playerRepository = new EntityFrameworkPlayerRepository(dataContext);
                    IPlayedGameRetriever playedGameRetriever = new PlayedGameRetriever(dataContext);
                    IPlayerRetriever playerRetriever = new PlayerRetriever(dataContext, playerRepository, playedGameRetriever);
                    PlayerDetails playerDetails = playerRetriever.GetPlayerDetails(testPlayer1.Id, numberOfGamesToRetrieve);

                    long lastTicks = long.MaxValue; ;
                    Assert.IsTrue(playerDetails.PlayerGameResults.Count == numberOfGamesToRetrieve);
                    foreach (PlayerGameResult result in playerDetails.PlayerGameResults)
                    {
                        Assert.GreaterOrEqual(lastTicks, result.PlayedGame.DatePlayed.Ticks);

                        lastTicks = result.PlayedGame.DatePlayed.Ticks;
                    }
                }
            }
        }
        public void ItOnlyGetsTheSpecifiedNumberOfRecentGames()
        {
            using (NemeStatsDbContext dbContext = new NemeStatsDbContext())
            {
                using (IDataContext dataContext = new NemeStatsDataContext(dbContext, securedEntityValidatorFactory))
                {
                    int numberOfGamesToRetrieve = 1;

                    INemesisHistoryRetriever nemesisHistoryRetriever = new NemesisHistoryRetriever(dataContext);
                    IPlayerRepository playerRepository = new EntityFrameworkPlayerRepository(dataContext);
                    IPlayedGameRetriever playedGameRetriever = new PlayedGameRetriever(dataContext);
                    IPlayerRetriever playerRetriever = new PlayerRetriever(dataContext, playerRepository, playedGameRetriever);
                    PlayerDetails playerDetails = playerRetriever.GetPlayerDetails(testPlayer1.Id, numberOfGamesToRetrieve);

                    Assert.AreEqual(numberOfGamesToRetrieve, playerDetails.PlayerGameResults.Count);
                }
            }
        }