public void ItReturnsTheTotalGamesWonAndTotalGamesPlayed()
        {
            autoMocker.Get<IDataContext>().Expect(mock => mock.GetQueryable<Player>()).Return(new List<Player>
            {
                expectedPlayer
            }.AsQueryable());

            var gameDefinitionTotals = new GameDefinitionTotals();
            autoMocker.ClassUnderTest.Expect(mock => mock.GetGameDefinitionTotals(expectedPlayer.Id))
                .Return(gameDefinitionTotals);
            var topLevelTotals = new PlayerRetriever.TopLevelTotals
            {
                TotalGames = 10,
                TotalGamesWon = 3
            };
            autoMocker.ClassUnderTest.Expect(mock => mock.GetTopLevelTotals(gameDefinitionTotals))
                .Return(topLevelTotals);
            autoMocker.Get<IPlayedGameRetriever>().Expect(mock => mock.GetRecentGames(
                Arg<int>.Is.Anything, 
                Arg<int>.Is.Anything,
                Arg<IDateRangeFilter>.Is.Anything)).Return(new List<PlayedGame>());

            var result = autoMocker.ClassUnderTest.GetPlayerQuickStatsForUser(userId, gamingGroupId);

            Assert.That(result.TotalGamesWon, Is.EqualTo(topLevelTotals.TotalGamesWon));
            Assert.That(result.TotalGamesPlayed, Is.EqualTo(topLevelTotals.TotalGames));
        }
 public PlayerStatistics()
 {
     GameDefinitionTotals = new GameDefinitionTotals();
 }
Exemple #3
0
 public PlayerStatistics()
 {
     GameDefinitionTotals = new GameDefinitionTotals();
 }
 internal virtual GameDefinitionTotals GetGameDefinitionTotals(int playerId)
 {
     var playerGameSummaries = playerRepository.GetPlayerGameSummaries(playerId);
     var gameDefinitionTotals = new GameDefinitionTotals
     {
         SummariesOfGameDefinitionTotals = playerGameSummaries.Select(playerGameSummary => new GameDefinitionTotal
         {
             GameDefinitionId = playerGameSummary.GameDefinitionId,
             GameDefinitionName = playerGameSummary.GameDefinitionName,
             GamesLost = playerGameSummary.NumberOfGamesLost,
             GamesWon = playerGameSummary.NumberOfGamesWon
         }).ToList()
     };
     return gameDefinitionTotals;
 }
        internal virtual TopLevelTotals GetTopLevelTotals(GameDefinitionTotals gameDefinitionTotals)
        {
            var returnResult = new TopLevelTotals
            {
                TotalGamesLost = gameDefinitionTotals.SummariesOfGameDefinitionTotals.Sum(x => x.GamesLost),
                TotalGamesWon = gameDefinitionTotals.SummariesOfGameDefinitionTotals.Sum(x => x.GamesWon)
            };
            returnResult.TotalGames = returnResult.TotalGamesLost + returnResult.TotalGamesWon;

            return returnResult;
        }