public void It_Returns_The_Specified_Number_Of_Top_Gaming_Groups() { //--arrange var expectedTopGamingGroupSummary = new TopGamingGroupSummary(); var gamingGroupList = new List <TopGamingGroupSummary> { expectedTopGamingGroupSummary }; autoMocker.Get <IGamingGroupRetriever>().Expect(mock => mock.GetTopGamingGroups(Arg <int> .Is.Anything)).Return(gamingGroupList); var expectedViewModel = new TopGamingGroupSummaryViewModel(); autoMocker.Get <ITransformer>().Expect(mock => mock.Transform <TopGamingGroupSummaryViewModel>(expectedTopGamingGroupSummary)) .Return(expectedViewModel); //--act var viewResult = autoMocker.ClassUnderTest.GetTopGamingGroups() as PartialViewResult; //--assert viewResult.ShouldNotBeNull(); viewResult.ViewName.ShouldBe(MVC.GamingGroup.Views.TopGamingGroups); var actualViewModel = viewResult.ViewData.Model as List <TopGamingGroupSummaryViewModel>; actualViewModel.ShouldNotBeNull(); actualViewModel.Count.ShouldBe(1); actualViewModel[0].ShouldBeSameAs(expectedViewModel); }
public override void SetUp() { base.SetUp(); List <TopPlayer> topPlayers = new List <TopPlayer>() { new TopPlayer() }; playerSummaryBuilderMock.Expect(mock => mock.GetTopPlayers(HomeController.NUMBER_OF_TOP_PLAYERS_TO_SHOW)) .Return(topPlayers); expectedPlayer = new TopPlayerViewModel(); topPlayerViewModelBuilderMock.Expect(mock => mock.Build(Arg <TopPlayer> .Is.Anything)) .Return(expectedPlayer); expectedPublicGameSummary = new PublicGameSummary(); List <PublicGameSummary> publicGameSummaries = new List <PublicGameSummary>() { expectedPublicGameSummary }; playedGameRetrieverMock.Expect(mock => mock.GetRecentPublicGames(HomeController.NUMBER_OF_RECENT_PUBLIC_GAMES_TO_SHOW)) .Return(publicGameSummaries); List <NemesisChange> expectedNemesisChanges = new List <NemesisChange>(); nemesisHistoryRetrieverMock.Expect(mock => mock.GetRecentNemesisChanges(HomeController.NUMBER_OF_RECENT_NEMESIS_CHANGES_TO_SHOW)) .Return(expectedNemesisChanges); expectedNemesisChangeViewModels = new List <NemesisChangeViewModel>(); nemesisChangeViewModelBuilderMock.Expect(mock => mock.Build(expectedNemesisChanges)) .Return(expectedNemesisChangeViewModels); expectedTopGamingGroup = new TopGamingGroupSummary() { GamingGroupId = 1, GamingGroupName = "gaming group name", NumberOfGamesPlayed = 2, NumberOfPlayers = 3 }; List <TopGamingGroupSummary> expectedTopGamingGroupSummaries = new List <TopGamingGroupSummary>() { expectedTopGamingGroup }; gamingGroupRetrieverMock.Expect(mock => mock.GetTopGamingGroups(HomeController.NUMBER_OF_TOP_GAMING_GROUPS_TO_SHOW)) .Return(expectedTopGamingGroupSummaries); expectedTopGamingGroupViewModel = Mapper.Map <TopGamingGroupSummary, TopGamingGroupSummaryViewModel>(expectedTopGamingGroupSummaries[0]); HomeIndexViewModel indexViewModel = new HomeIndexViewModel(); viewResult = homeControllerPartialMock.Index() as ViewResult; }
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; }