예제 #1
0
        public void SetUp()
        {
            _autoMocker = new RhinoAutoMocker<UniversalGameController>();
            _currentUser = new ApplicationUser();

            _expectedPlayedGame1 = new PlayedGame();
            _expectedPlayedGame2 = new PlayedGame();
            _expectedPlayerWinRecord1 = new PlayerWinRecord();
            _expectedPlayerWinRecord2 = new PlayerWinRecord();
            _expectedGameDefinitionSummary = new GameDefinitionSummary
            {
                Id = 50,
                AveragePlayersPerGame = 2.59M,
                GamingGroupName = "some gaming group name",
                TotalNumberOfGamesPlayed = 3,
                PlayedGames = new List<PlayedGame>
                {
                    _expectedPlayedGame1,
                    _expectedPlayedGame2
                },
                PlayerWinRecords = new List<PlayerWinRecord>
                {
                    _expectedPlayerWinRecord1,
                    _expectedPlayerWinRecord2
                }
            };
            _expectedBoardGameGeekGameSummary = new BoardGameGeekGameSummary
            {
                GamingGroupGameDefinitionSummary = _expectedGameDefinitionSummary
            };
            _expectedUniversalGameDetailsViewModel = new UniversalGameDetailsViewModel
            {
                BoardGameGeekInfo = new BoardGameGeekInfoViewModel()
            };

            _autoMocker.Get<IUniversalGameRetriever>().Expect(mock => mock.GetBoardGameGeekGameSummary(Arg<int>.Is.Anything, Arg<ApplicationUser>.Is.Anything, Arg<int>.Is.Anything))
                .Return(_expectedBoardGameGeekGameSummary);
            _autoMocker.Get<ITransformer>()
                .Expect(mock => mock.Transform<UniversalGameDetailsViewModel>(Arg<BoardGameGeekGameSummary>.Is.Anything))
                .Return(_expectedUniversalGameDetailsViewModel);
        }
예제 #2
0
 public MapFromPlayerWinRecord()
 {
     PlayerWinRecord = new PlayerWinRecord();
 }
        public void FixtureSetUp()
        {
            _autoMocker = new RhinoAutoMocker<GameDefinitionDetailsViewModelBuilder>();
            _autoMocker.PartialMockTheClassUnderTest();

            _expectedPlayerSummary1 = new GameDefinitionPlayerSummaryViewModel();
            _expectedPlayerSummary2 = new GameDefinitionPlayerSummaryViewModel();

            List<PlayedGame> playedGames = new List<PlayedGame>();
            playedGames.Add(new PlayedGame
            {
                    Id = 10
                });
            _playedGameDetailsViewModel1 = new PlayedGameDetailsViewModel();
            playedGames.Add(new PlayedGame
            {
                Id = 11
            });
            _playedGameDetailsViewModel2 = new PlayedGameDetailsViewModel();
            _championPlayer = new Player
            {
                Name = _championName,
                Id = _championPlayerId,
                Active = true
            };
            _previousChampionPlayer = new Player
            {
                Name = _previousChampionName,
                Id = _previousChampionPlayerId,
                Active = false
            };
            _champion = new Champion
            {
                Player = _championPlayer,
                WinPercentage = _championWinPercentage,
                NumberOfGames = _championNumberOfGames,
                NumberOfWins = _championNumberOfWins
            };
            _previousChampion = new Champion
            {
                Player = _previousChampionPlayer
            };
            _playerWinRecord1 = new PlayerWinRecord
            {
                GamesWon = 1,
                GamesLost = 2,
                PlayerName = "player name",
                WinPercentage = 33,
                PlayerId = 3
            };
            _playerWinRecord2 = new PlayerWinRecord();

            _autoMocker.Get<ITransformer>().Expect(mock => mock.Transform<GameDefinitionPlayerSummaryViewModel>(_playerWinRecord1))
                       .Return(_expectedPlayerSummary1);
            _autoMocker.Get<ITransformer>().Expect(mock => mock.Transform<GameDefinitionPlayerSummaryViewModel>(_playerWinRecord2))
                 .Return(_expectedPlayerSummary2); 

            _gameDefinitionSummary = new GameDefinitionSummary
            {
                Id = 1,
                Name = "game definition name",
                Description = "game definition description",
                GamingGroupId = _gamingGroupid,
                GamingGroupName = "gaming group name",
                PlayedGames = playedGames,
                TotalNumberOfGamesPlayed = 3,
                AveragePlayersPerGame = 2.2M,
                BoardGameGeekGameDefinitionId = 123,
                BoardGameGeekGameDefinition = new BoardGameGeekGameDefinition() { Id = 123},
                Champion = _champion,
                PreviousChampion = _previousChampion,
                PlayerWinRecords = new List<PlayerWinRecord>
                {
                    _playerWinRecord1,
                    _playerWinRecord2
                },
                BoardGameGeekInfo = new BoardGameGeekInfo()
            };
            _currentUser = new ApplicationUser
            {
                CurrentGamingGroupId = _gamingGroupid
            };
            _autoMocker.Get<IPlayedGameDetailsViewModelBuilder>().Expect(mock => mock.Build(_gameDefinitionSummary.PlayedGames[0], _currentUser, true))
                .Return(_playedGameDetailsViewModel1);
            _autoMocker.Get<IPlayedGameDetailsViewModelBuilder>().Expect(mock => mock.Build(_gameDefinitionSummary.PlayedGames[1], _currentUser, true))
                .Return(_playedGameDetailsViewModel2);

            _expectedBoardGameGeekInfo = new BoardGameGeekInfoViewModel();
            _autoMocker.Get<ITransformer>().Expect(mock => mock.Transform<BoardGameGeekInfoViewModel>(_gameDefinitionSummary.BoardGameGeekInfo))
                .Return(_expectedBoardGameGeekInfo);

            _viewModel = _autoMocker.ClassUnderTest.Build(_gameDefinitionSummary, _currentUser);
        }