public void ItReturnsResultsFromTheGameDefinitionRetrieverIfTheResultsArentAlreadyInTheCache() { //--arrange var expectedResults = new List<TrendingGame>(); var trendingGamesRequest = new TrendingGamesRequest(1, 2); _autoMocker.Get<IGameDefinitionRetriever>().Expect(mock => mock.GetTrendingGames(trendingGamesRequest.NumberOfTrendingGamesToShow, trendingGamesRequest.NumberOfDaysOfTrendingGames)) .Return(expectedResults); //--act var actualResults = _autoMocker.ClassUnderTest.GetFromSource(trendingGamesRequest); //--assert Assert.That(actualResults, Is.SameAs(expectedResults)); }
public virtual ActionResult ShowTrendingGames() { var trendingGamesRequest = new TrendingGamesRequest(NUMBER_OF_TRENDING_GAMES_TO_SHOW, NUMBER_OF_DAYS_OF_TRENDING_GAMES); var trendingGames = _trendingGamesRetriever.GetResults(trendingGamesRequest); var trendingGamesViewModels = trendingGames.Select(_transformer.Transform<TrendingGameViewModel>).ToList(); ViewBag.NumTrendingDays = NUMBER_OF_DAYS_OF_TRENDING_GAMES; return View(MVC.GameDefinition.Views.TrendingGames, trendingGamesViewModels); }
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; }
public virtual ActionResult Index() { var recentPlayerAchievements = _recentPlayerAchievementsUnlockedRetreiver.GetResults(new GetRecentPlayerAchievementsUnlockedQuery {PageSize = NUMBER_OF_RECENT_ACHIEVEMENTS_TO_SHOW }); var recentPlayerAchievementsViewModel = recentPlayerAchievements.ToMappedPagedList(_mapperFactory.GetMapper<PlayerAchievement,PlayerAchievementWinnerViewModel>()); var recentlyPlayedGamesFilter = new RecentlyPlayedGamesFilter { NumberOfGamesToRetrieve = NUMBER_OF_RECENT_PUBLIC_GAMES_TO_SHOW }; var publicGameSummaries = _recentPublicGamesRetriever.GetResults(recentlyPlayedGamesFilter); var topGamingGroups = _topGamingGroupsRetriever.GetResults(NUMBER_OF_TOP_GAMING_GROUPS_TO_SHOW); var topGamingGroupViewModels = topGamingGroups.Select(_transformer.Transform<TopGamingGroupSummaryViewModel>).ToList(); var trendingGamesRequest = new TrendingGamesRequest(NUMBER_OF_TRENDING_GAMES_TO_SHOW, NUMBER_OF_DAYS_OF_TRENDING_GAMES); var trendingGames = _trendingGamesRetriever.GetResults(trendingGamesRequest); var trendingGameViewModels = trendingGames.Select(_transformer.Transform<TrendingGameViewModel>).ToList(); var homeIndexViewModel = new HomeIndexViewModel() { RecentAchievementsUnlocked = recentPlayerAchievementsViewModel, RecentPublicGames = publicGameSummaries, TopGamingGroups = topGamingGroupViewModels, TrendingGames = trendingGameViewModels }; ViewBag.NumTrendingGameDays = NUMBER_OF_DAYS_OF_TRENDING_GAMES; return View(MVC.Home.Views.Index, homeIndexViewModel); }