コード例 #1
0
        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;
                    }
                }
            }
        }
コード例 #2
0
        public void ItGetsTheGamesPlayedMetrics()
        {
            using (IDataContext dataContext = new NemeStatsDataContext())
            {
                IPlayerRepository    playerRepository    = new EntityFrameworkPlayerRepository(dataContext);
                IPlayedGameRetriever playedGameRetriever = new PlayedGameRetriever(dataContext);
                IPlayerRetriever     playerRetriever     = new PlayerRetriever(dataContext, playerRepository, playedGameRetriever);
                PlayerStatistics     playerStatistics    = playerRetriever.GetPlayerStatistics(testPlayer1.Id);

                int totalGamesForPlayer1 = testPlayedGames
                                           .Count(playedGame => playedGame.PlayerGameResults
                                                  .Any(playerGameResult => playerGameResult.PlayerId == testPlayer1.Id));
                Assert.That(playerStatistics.TotalGames, Is.EqualTo(totalGamesForPlayer1));

                int totalWinsForPlayer1 = testPlayedGames
                                          .Count(playedGame => playedGame.PlayerGameResults
                                                 .Any(playerGameResult => playerGameResult.PlayerId == testPlayer1.Id && playerGameResult.GameRank == 1));
                Assert.That(playerStatistics.TotalGamesWon, Is.EqualTo(totalWinsForPlayer1));

                int totalLossesForPlayer1 = testPlayedGames
                                            .Count(playedGame => playedGame.PlayerGameResults
                                                   .Any(playerGameResult => playerGameResult.PlayerId == testPlayer1.Id && playerGameResult.GameRank != 1));
                Assert.That(playerStatistics.TotalGamesLost, Is.EqualTo(totalLossesForPlayer1));

                int winPercentageForPlayer1 = (int)((decimal)totalWinsForPlayer1 / (totalGamesForPlayer1) * 100);

                Assert.That(playerStatistics.WinPercentage, Is.EqualTo(winPercentageForPlayer1));
            }
        }
コード例 #3
0
        public void ItGetsTheTotalPoints()
        {
            using (IDataContext dataContext = new NemeStatsDataContext())
            {
                IPlayerRepository    playerRepository    = new EntityFrameworkPlayerRepository(dataContext);
                IPlayedGameRetriever playedGameRetriever = new PlayedGameRetriever(dataContext);
                IPlayerRetriever     playerRetriever     = new PlayerRetriever(dataContext, playerRepository, playedGameRetriever);
                PlayerStatistics     playerStatistics    = playerRetriever.GetPlayerStatistics(testPlayer1.Id);

                int totalBasePoints         = 0;
                int totalGameDurationPoints = 0;
                int totalWeightBonusPoints  = 0;

                foreach (PlayedGame playedGame in testPlayedGames)
                {
                    if (playedGame.PlayerGameResults.Any(result => result.PlayerId == testPlayer1.Id))
                    {
                        var playerGameResult = playedGame.PlayerGameResults.First(result => result.PlayerId == testPlayer1.Id);
                        totalBasePoints         += playerGameResult.NemeStatsPointsAwarded;
                        totalGameDurationPoints += playerGameResult.GameDurationBonusPoints;
                        totalWeightBonusPoints  += playerGameResult.GameWeightBonusPoints;
                    }
                }

                Assert.AreEqual(totalBasePoints, playerStatistics.NemePointsSummary.BaseNemePoints);
                Assert.AreEqual(totalGameDurationPoints, playerStatistics.NemePointsSummary.GameDurationBonusNemePoints);
                Assert.AreEqual(totalWeightBonusPoints, playerStatistics.NemePointsSummary.WeightBonusNemePoints);
            }
        }
コード例 #4
0
 public void SetUp()
 {
     using (NemeStatsDataContext dataContext = new NemeStatsDataContext())
     {
         var playerRepository = new EntityFrameworkPlayerRepository(dataContext);
         retriever = new GameDefinitionRetriever(dataContext, playerRepository);
         this.actualGameDefinitionSummaries = retriever.GetAllGameDefinitions(testUserWithDefaultGamingGroup.CurrentGamingGroupId);
     }
 }
コード例 #5
0
        public void SetUp()
        {
            using (NemeStatsDataContext dataContext = new NemeStatsDataContext())
            {
                var playerRepository           = new EntityFrameworkPlayerRepository(dataContext);
                var cacheableGameDataRetriever = new BoardGameGeekGameDefinitionInfoRetriever(new DateUtilities(), new CacheService(), dataContext);

                retriever = new GameDefinitionRetriever(dataContext, playerRepository, cacheableGameDataRetriever);
                actualGameDefinitionSummaries = retriever.GetAllGameDefinitions(testUserWithDefaultGamingGroup.CurrentGamingGroupId);
            }
        }
コード例 #6
0
        public override void FixtureSetUp()
        {
            base.FixtureSetUp();

            dataContext = new NemeStatsDataContext();
            IPlayerRepository    playerRepository    = new EntityFrameworkPlayerRepository(dataContext);
            IPlayedGameRetriever playedGameRetriever = new PlayedGameRetriever(dataContext);

            playerRetriever = new PlayerRetriever(dataContext, playerRepository, playedGameRetriever);
            player1Details  = playerRetriever.GetPlayerDetails(testPlayer1.Id, 0);
            player5Details  = playerRetriever.GetPlayerDetails(testPlayer5.Id, 0);
        }
コード例 #7
0
        public EntityFrameworkPlayerSerializerTests()
        {
            var seedDbId = Guid.NewGuid().ToString();

            _fakeDbContextFactory = Substitute.For <IDbContextFactory <DatabaseContext <Player> > >();
            _fakeDbContextFactory.CreateDbContext().ReturnsForAnyArgs(x =>
                                                                      new DatabaseContext <Player>(
                                                                          new DbContextOptionsBuilder <DatabaseContext <Player> >().UseInMemoryDatabase(seedDbId).Options
                                                                          )
                                                                      );
            _entityFrameworkPlayerRepository = new EntityFrameworkPlayerRepository <Player>(_fakeDbContextFactory);
        }
コード例 #8
0
        public void ItGetsTheAveragePlayersPerGame()
        {
            using (IDataContext dataContext = new NemeStatsDataContext())
            {
                IPlayerRepository    playerRepository    = new EntityFrameworkPlayerRepository(dataContext);
                IPlayedGameRetriever playedGameRetriever = new PlayedGameRetriever(dataContext);
                IPlayerRetriever     playerRetriever     = new PlayerRetriever(dataContext, playerRepository, playedGameRetriever);
                PlayerStatistics     playerStatistics    = playerRetriever.GetPlayerStatistics(testPlayer1.Id);

                float averagePlayersPerGame = (float)testPlayedGames.Where(game => game.PlayerGameResults.Any(result => result.PlayerId == testPlayer1.Id))
                                              .Average(game => game.NumberOfPlayers);

                Assert.AreEqual(averagePlayersPerGame, playerStatistics.AveragePlayersPerGame);
            }
        }
コード例 #9
0
        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);
                }
            }
        }
コード例 #10
0
        public override void FixtureSetUp()
        {
            base.FixtureSetUp();

            using (this.dbContext = new NemeStatsDbContext())
            {
                using (this.dataContext = new NemeStatsDataContext(this.dbContext, this.securedEntityValidatorFactory))
                {
                    var playerRepository = new EntityFrameworkPlayerRepository(dataContext);

                    var gameDefinitionRetriever = new GameDefinitionRetriever(this.dataContext, playerRepository);
                    this.gameDefinitionSummary = gameDefinitionRetriever.GetGameDefinitionDetails(
                        this.testGameDefinition.Id,
                        this.numberOfGamesToRetrieve);
                }
            }
        }
コード例 #11
0
        public override void FixtureSetUp()
        {
            base.FixtureSetUp();

            using (dbContext = new NemeStatsDbContext())
            {
                using (dataContext = new NemeStatsDataContext(dbContext, securedEntityValidatorFactory))
                {
                    var playerRepository           = new EntityFrameworkPlayerRepository(dataContext);
                    var cacheableGameDataRetriever = new BoardGameGeekGameDefinitionInfoRetriever(new DateUtilities(), new CacheService(), dataContext);

                    var gameDefinitionRetriever = new GameDefinitionRetriever(dataContext, playerRepository, cacheableGameDataRetriever);
                    gameDefinitionSummary = gameDefinitionRetriever.GetGameDefinitionDetails(
                        testGameDefinition.Id,
                        numberOfGamesToRetrieve);
                }
            }
        }
コード例 #12
0
        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);
                }
            }
        }
コード例 #13
0
        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);
                }
            }
        }
コード例 #14
0
        public override void FixtureSetUp()
        {
            base.FixtureSetUp();

            dataContext = new NemeStatsDataContext();
            var playerRepository = new EntityFrameworkPlayerRepository(dataContext);

            gameDefinitionRetriever = new GameDefinitionRetriever(dataContext, playerRepository);

            gameDefinition = gameDefinitionRetriever.GetGameDefinitionDetails(testGameDefinitionWithOtherGamingGroupId.Id,
                                                                              0);
            championlessGameDefinition = gameDefinitionRetriever.GetGameDefinitionDetails(gameDefinitionWithNoChampion.Id, 0);

            // Player ID 1 has a winning percentage high enough to be considered the champion
            championPlayerIdForGameDefinition = testPlayer7WithOtherGamingGroupId.Id;

            // Player ID 9 has a higher winning percentage than player 7, but is not active
            otherChampionPlayerIdForGameDefinition = testPlayer9UndefeatedWith5Games.Id;
        }
コード例 #15
0
        public void TryGamingGroup1()
        {
            using (NemeStatsDataContext dataContext = new NemeStatsDataContext())
            {
                var playerRepository = new EntityFrameworkPlayerRepository(dataContext);

                retriever = new GameDefinitionRetriever(dataContext, playerRepository);
                IList <GameDefinitionSummary> gameDefinitionSummaries = retriever.GetAllGameDefinitions(1);

                foreach (GameDefinitionSummary summary in gameDefinitionSummaries)
                {
                    if (summary.ChampionId != null)
                    {
                        Assert.That(summary.Champion, Is.Not.Null);
                        Assert.That(summary.Champion.Player, Is.Not.Null);
                    }
                }
            }
        }
コード例 #16
0
        public void TryGamingGroup1()
        {
            using (NemeStatsDataContext dataContext = new NemeStatsDataContext())
            {
                var playerRepository           = new EntityFrameworkPlayerRepository(dataContext);
                var cacheableGameDataRetriever = new BoardGameGeekGameDefinitionInfoRetriever(new DateUtilities(), new CacheService(), dataContext);

                retriever = new GameDefinitionRetriever(dataContext, playerRepository, cacheableGameDataRetriever);
                IList <GameDefinitionSummary> gameDefinitionSummaries = retriever.GetAllGameDefinitions(1);

                foreach (GameDefinitionSummary summary in gameDefinitionSummaries)
                {
                    if (summary.ChampionId != null)
                    {
                        Assert.That(summary.Champion, Is.Not.Null);
                        Assert.That(summary.Champion.Player, Is.Not.Null);
                    }
                }
            }
        }
コード例 #17
0
        public void ItThrowsAnEntityDoesNotExistExceptionIfTheIdIsntValid()
        {
            using (dbContext = new NemeStatsDbContext())
            {
                using (dataContext = new NemeStatsDataContext(dbContext, securedEntityValidatorFactory))
                {
                    var playerRepository = new EntityFrameworkPlayerRepository(dataContext);

                    int invalidId                  = -1;
                    var expectedException          = new EntityDoesNotExistException(typeof(GameDefinition), invalidId);
                    var cacheableGameDataRetriever = new BoardGameGeekGameDefinitionInfoRetriever(new DateUtilities(), new CacheService(), dataContext);

                    var gameDefinitionRetriever = new GameDefinitionRetriever(dataContext, playerRepository, cacheableGameDataRetriever);

                    var actualException = Assert.Throws <EntityDoesNotExistException>(() =>
                                                                                      gameDefinitionRetriever.GetGameDefinitionDetails(invalidId, 0));

                    actualException.Message.ShouldBe(expectedException.Message);
                }
            }
        }
コード例 #18
0
        public void ItGetsTheTotalPoints()
        {
            using (IDataContext dataContext = new NemeStatsDataContext())
            {
                IPlayerRepository    playerRepository    = new EntityFrameworkPlayerRepository(dataContext);
                IPlayedGameRetriever playedGameRetriever = new PlayedGameRetriever(dataContext);
                IPlayerRetriever     playerRetriever     = new PlayerRetriever(dataContext, playerRepository, playedGameRetriever);
                PlayerStatistics     playerStatistics    = playerRetriever.GetPlayerStatistics(testPlayer1.Id);

                int totalPoints = 0;

                foreach (PlayedGame playedGame in testPlayedGames)
                {
                    if (playedGame.PlayerGameResults.Any(result => result.PlayerId == testPlayer1.Id))
                    {
                        totalPoints += playedGame.PlayerGameResults.First(result => result.PlayerId == testPlayer1.Id).NemeStatsPointsAwarded;
                    }
                }

                Assert.AreEqual(totalPoints, playerStatistics.TotalPoints);
            }
        }
コード例 #19
0
 public HotStreakAchievement(IDataContext dataContext, EntityFrameworkPlayerRepository entityFrameworkPlayerRepository) : base(dataContext)
 {
     _entityFrameworkPlayerRepository = entityFrameworkPlayerRepository;
 }
コード例 #20
0
        private void CreatePlayedGames(NemeStatsDataContext dataContext)
        {
            IPlayerRepository                        playerRepository                        = new EntityFrameworkPlayerRepository(dataContext);
            INemesisRecalculator                     nemesisRecalculator                     = new NemesisRecalculator(dataContext, playerRepository);
            IChampionRepository                      championRepository                      = new ChampionRepository(dataContext);
            IChampionRecalculator                    championRecalculator                    = new ChampionRecalculator(dataContext, championRepository);
            ISecuredEntityValidator <Player>         securedEntityValidatorForPlayers        = new SecuredEntityValidator <Player>();
            ISecuredEntityValidator <GameDefinition> securedEntityValidatorForGameDefinition = new SecuredEntityValidator <GameDefinition>();
            IPlayedGameCreator                       playedGameCreator                       = new PlayedGameCreator(
                dataContext,
                playedGameTracker,
                nemesisRecalculator,
                championRecalculator,
                securedEntityValidatorForPlayers,
                securedEntityValidatorForGameDefinition);

            List <Player> players = new List <Player>()
            {
                testPlayer1, testPlayer2
            };
            List <int> playerRanks = new List <int>()
            {
                1, 1
            };
            PlayedGame playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);

            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer1, testPlayer2, testPlayer3
            };
            playerRanks = new List <int>()
            {
                1, 2, 3
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer1, testPlayer3, testPlayer2
            };
            playerRanks = new List <int>()
            {
                1, 2, 3
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer3, testPlayer1
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            //make player4 beat player 1 three times
            players = new List <Player>()
            {
                testPlayer4, testPlayer1, testPlayer2, testPlayer3
            };
            playerRanks = new List <int>()
            {
                1, 2, 3, 4
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer4, testPlayer1
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer4, testPlayer1
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            //--make the inactive player5 beat player1 3 times
            players = new List <Player>()
            {
                testPlayer5, testPlayer1
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer5, testPlayer1
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer5, testPlayer1
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            //make player 2 be the only one who beat player 5
            players = new List <Player>()
            {
                testPlayer2, testPlayer5
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            //--create games that have a different GamingGroupId and testPlayer7 being the champion
            players = new List <Player>()
            {
                testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer7WithOtherGamingGroupId, testPlayer8WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer7WithOtherGamingGroupId, testPlayer8WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer7WithOtherGamingGroupId, testPlayer8WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer7WithOtherGamingGroupId, testPlayer8WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer8WithOtherGamingGroupId, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);

            players = new List <Player>()
            {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int>()
            {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameCreator);
            testPlayedGames.Add(playedGame);
        }
コード例 #21
0
        private void CreatePlayedGames(NemeStatsDataContext dataContext)
        {
            var playerRepository          = new EntityFrameworkPlayerRepository(dataContext);
            var nemesisRecalculator       = new NemesisRecalculator(dataContext, playerRepository);
            var championRepository        = new ChampionRepository(dataContext);
            var championRecalculator      = new ChampionRecalculator(dataContext, championRepository);
            var securedEntityValidator    = new SecuredEntityValidator(dataContext);
            var weightBonusCalculator     = new WeightBonusCalculator(new WeightTierCalculator());
            var pointsCalculator          = new PointsCalculator(weightBonusCalculator, new GameDurationBonusCalculator());
            var linkedPlayedGameValidator = new LinkedPlayedGameValidator(dataContext);
            var applicationLinker         = new ApplicationLinker(dataContext);

            IPlayedGameSaver playedGameSaver = new PlayedGameSaver(
                dataContext,
                playedGameTracker,
                nemesisRecalculator,
                championRecalculator,
                securedEntityValidator,
                pointsCalculator,
                new FakeEventBus(),
                linkedPlayedGameValidator,
                applicationLinker);

            List <Player> players = new List <Player> {
                testPlayer1, testPlayer2
            };
            List <int> playerRanks = new List <int> {
                1, 1
            };
            PlayedGame playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);

            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer1, testPlayer2, testPlayer3
            };
            playerRanks = new List <int> {
                1, 2, 3
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer1, testPlayer3, testPlayer2
            };
            playerRanks = new List <int> {
                1, 2, 3
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer3, testPlayer1
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            //make player4 beat player 1 three times
            players = new List <Player> {
                testPlayer4, testPlayer1, testPlayer2, testPlayer3
            };
            playerRanks = new List <int> {
                1, 2, 3, 4
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer4, testPlayer1
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer4, testPlayer1
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            //--make the inactive player5 beat player1 3 times
            players = new List <Player> {
                testPlayer5, testPlayer1
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer5, testPlayer1
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer5, testPlayer1
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            //make player 2 be the only one who beat player 5
            players = new List <Player> {
                testPlayer2, testPlayer5
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinition.Id, players, playerRanks, testUserWithDefaultGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            //--create games that have a different GamingGroupId and testPlayer7 being the champion
            players = new List <Player> {
                testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer7WithOtherGamingGroupId, testPlayer8WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer7WithOtherGamingGroupId, testPlayer8WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer7WithOtherGamingGroupId, testPlayer8WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer7WithOtherGamingGroupId, testPlayer8WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer8WithOtherGamingGroupId, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(testGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);

            players = new List <Player> {
                testPlayer9UndefeatedWith5Games, testPlayer7WithOtherGamingGroupId
            };
            playerRanks = new List <int> {
                1, 2
            };
            playedGame = CreateTestPlayedGame(anotherTestGameDefinitionWithOtherGamingGroupId.Id, players, playerRanks, testUserWithOtherGamingGroup, playedGameSaver);
            testPlayedGames.Add(playedGame);
        }