Beispiel #1
0
        public void ItRequiresAPlayedGame()
        {
            var exception = Assert.Throws <ArgumentNullException>(() =>
                                                                  builder.Build(null, currentUser)
                                                                  );

            Assert.AreEqual("playedGame", exception.ParamName);
        }
        private void SetItAllUp(WinnerTypes winnerType)
        {
            Stack <int> gameRankStack = new Stack <int>();

            if (winnerType == WinnerTypes.PlayerWin)
            {
                gameRankStack.Push(1);
                gameRankStack.Push(2);
                gameRankStack.Push(3);
            }
            else if (winnerType == WinnerTypes.TeamLoss)
            {
                gameRankStack.Push(2);
                gameRankStack.Push(2);
                gameRankStack.Push(2);
            }
            else if (winnerType == WinnerTypes.TeamWin)
            {
                gameRankStack.Push(1);
                gameRankStack.Push(1);
                gameRankStack.Push(1);
            }

            _gamingGroup = new GamingGroup
            {
                Id   = _gamingGroupId,
                Name = "gaming group name"
            };
            _playedGame = new PlayedGame
            {
                Id                = 11111,
                GameDefinition    = new GameDefinition(),
                GamingGroup       = _gamingGroup,
                GameDefinitionId  = 2222,
                PlayerGameResults = new List <PlayerGameResult>(),
                GamingGroupId     = _gamingGroupId,
                Notes             = "some notes" + Environment.NewLine + "some notes on a separate line",
                WinnerType        = winnerType
            };

            _playedGame.PlayerGameResults.Add(new PlayerGameResult()
            {
                GameRank = gameRankStack.Pop(),
                NemeStatsPointsAwarded = 3,
                Id           = 1,
                PlayedGameId = _playedGame.Id,
                PlayerId     = 1
            });

            _playedGame.PlayerGameResults.Add(new PlayerGameResult()
            {
                GameRank = gameRankStack.Pop(),
                NemeStatsPointsAwarded = 2,
                Id           = 2,
                PlayedGameId = _playedGame.Id,
                PlayerId     = 2
            });

            _playedGame.PlayerGameResults.Add(new PlayerGameResult()
            {
                GameRank = gameRankStack.Pop(),
                NemeStatsPointsAwarded = 1,
                Id           = 3,
                PlayedGameId = _playedGame.Id,
                PlayerId     = 3,
                PlayedGame   = new PlayedGame()
                {
                    GameDefinition = new GameDefinition()
                    {
                        Id   = 135,
                        Name = "Test game name"
                    }
                }
            });

            _detailsBuilder = MockRepository.GenerateMock <IGameResultViewModelBuilder>();
            _builder        = new PlayedGameDetailsViewModelBuilder(_detailsBuilder);

            int totalPlayerGameResults = _playedGame.PlayerGameResults.Count;

            for (int i = 0; i < totalPlayerGameResults; i++)
            {
                _detailsBuilder.Expect(
                    x => x.Build(_playedGame.PlayerGameResults[i]))
                .Repeat
                .Once()
                .Return(new GameResultViewModel()
                {
                    PlayerId = _playedGame.PlayerGameResults[i].PlayerId
                });
            }
            _currentUser = new ApplicationUser()
            {
                CurrentGamingGroupId = _gamingGroupId
            };

            _actualViewModel = _builder.Build(_playedGame, _currentUser, false);
        }