Exemplo n.º 1
0
        public void ItReturnsTheSpecifiedNumberOfTrendingGames()
        {
            var expectedTrendingGame = new TrendingGame();
            var expectedTrendingGames = new List<TrendingGame>
            {
                expectedTrendingGame
            };

            autoMocker.Get<ITrendingGamesRetriever>()
                      .Expect(
                              mock =>
                              mock.GetResults(Arg<TrendingGamesRequest>.Matches(x => x.NumberOfDaysOfTrendingGames == GameDefinitionController.NUMBER_OF_DAYS_OF_TRENDING_GAMES
                                                                                     &&
                                                                                     x.NumberOfTrendingGamesToShow == GameDefinitionController.NUMBER_OF_TRENDING_GAMES_TO_SHOW)))
                      .Return(expectedTrendingGames);

            var expectedViewModel = new TrendingGameViewModel();
            autoMocker.Get<ITransformer>().Expect(mock => mock.Transform<TrendingGameViewModel>(
                expectedTrendingGame))
                .Return(expectedViewModel);
            var viewResult = autoMocker.ClassUnderTest.ShowTrendingGames() as ViewResult;

            var actualModel = viewResult.ViewData.Model as List<TrendingGameViewModel>;

            Assert.That(actualModel[0], Is.SameAs(expectedViewModel));
        }
Exemplo n.º 2
0
        public override void SetUp()
        {
            base.SetUp();


            recentAchievementsUnlocks = new List<PlayerAchievement>
            {
                new PlayerAchievement()
                {
                    DateCreated = DateTime.UtcNow,
                    LastUpdatedDate = DateTime.UtcNow,
                    AchievementId = AchievementId.BoardGameGeek2016_10x10
                }


            };

            _autoMocker.Get<IRecentPlayerAchievementsUnlockedRetreiver>().Expect(mock => mock.GetResults(Arg<GetRecentPlayerAchievementsUnlockedQuery>.Is.Anything))
                .Return(recentAchievementsUnlocks.ToPagedList(1, HomeController.NUMBER_OF_RECENT_ACHIEVEMENTS_TO_SHOW));


            expectedPublicGameSummary = new PublicGameSummary();
            var publicGameSummaries = new List<PublicGameSummary>()
            {
                expectedPublicGameSummary
            };
            _autoMocker.Get<IRecentPublicGamesRetriever>().Expect(mock => mock.GetResults(Arg<RecentlyPlayedGamesFilter>.Matches(x => x.NumberOfGamesToRetrieve == HomeController.NUMBER_OF_RECENT_PUBLIC_GAMES_TO_SHOW)))
                .Return(publicGameSummaries);

            var expectedNemesisChanges = new List<NemesisChange>();
            _autoMocker.Get<INemesisHistoryRetriever>().Expect(mock => mock.GetRecentNemesisChanges(HomeController.NUMBER_OF_RECENT_NEMESIS_CHANGES_TO_SHOW))
                                   .Return(expectedNemesisChanges);

            expectedNemesisChangeViewModels = new List<NemesisChangeViewModel>();
            _autoMocker.Get<INemesisChangeViewModelBuilder>().Expect(mock => mock.Build(expectedNemesisChanges))
                                         .Return(expectedNemesisChangeViewModels);

            expectedTopGamingGroup = new TopGamingGroupSummary()
            {
                GamingGroupId = 1,
                GamingGroupName = "gaming group name",
                NumberOfGamesPlayed = 2,
                NumberOfPlayers = 3
            };
            var expectedTopGamingGroupSummaries = new List<TopGamingGroupSummary>()
            {
                expectedTopGamingGroup
            };
            _autoMocker.Get<ITopGamingGroupsRetriever>().Expect(mock => mock.GetResults(HomeController.NUMBER_OF_TOP_GAMING_GROUPS_TO_SHOW))
                                    .Return(expectedTopGamingGroupSummaries);

            expectedTopGamingGroupViewModel = new TopGamingGroupSummaryViewModel();
            _autoMocker.Get<ITransformer>()
                .Expect(mock => mock.Transform<TopGamingGroupSummaryViewModel>(expectedTopGamingGroupSummaries[0]))
                .Return(expectedTopGamingGroupViewModel);

            _expectedTrendingGame = new TrendingGame
            {
                BoardGameGeekGameDefinitionId = 1,
                GamesPlayed = 1,
                GamingGroupsPlayingThisGame = 2,
                ThumbnailImageUrl = "some thumbnail"
            };
            var expectedTopGames = new List<TrendingGame>
            {
                _expectedTrendingGame
            };
            _expectedTrendingGameViewModel = new TrendingGameViewModel();
            var trendingGamesRequest = new TrendingGamesRequest(HomeController.NUMBER_OF_TRENDING_GAMES_TO_SHOW, HomeController.NUMBER_OF_DAYS_OF_TRENDING_GAMES);
            _autoMocker.Get<ITrendingGamesRetriever>().Expect(mock => mock.GetResults(Arg<TrendingGamesRequest>.Is.Equal(trendingGamesRequest))).Return(expectedTopGames);
            _autoMocker.Get<ITransformer>().Expect(mock => mock.Transform<TrendingGameViewModel>(expectedTopGames[0])).Return(_expectedTrendingGameViewModel);

            viewResult = _autoMocker.ClassUnderTest.Index() as ViewResult;

        }