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));
        }
        public void ItReturnsTheSpecifiedNumberOfTrendingGames()
        {
            var expectedTrendingGame1 = new TrendingGame();
            var expectedTrendingGame2 = new TrendingGame();
            var expectedTrendingGames = new List <TrendingGame>
            {
                expectedTrendingGame1,
                expectedTrendingGame2
            };

            autoMocker.Get <ITrendingGamesRetriever>()
            .Expect(
                mock =>
                mock.GetResults(Arg <TrendingGamesRequest> .Is.Anything))
            .Return(expectedTrendingGames);

            var expectedViewModel1 = new TrendingGameViewModel();

            autoMocker.Get <ITransformer>().Expect(mock => mock.Transform <TrendingGameViewModel>(
                                                       expectedTrendingGame1))
            .Return(expectedViewModel1);

            var expectedViewModel2 = new TrendingGameViewModel();

            autoMocker.Get <ITransformer>().Expect(mock => mock.Transform <TrendingGameViewModel>(
                                                       expectedTrendingGame2))
            .Return(expectedViewModel2);

            var numberOfGames = 1;
            var numberOfDays  = 2;

            //--act
            var results = autoMocker.ClassUnderTest.GetTrendingGamesViewModels(numberOfGames, numberOfDays);

            //--assert
            autoMocker.Get <ITrendingGamesRetriever>()
            .AssertWasCalled(
                mock =>
                mock.GetResults(Arg <TrendingGamesRequest> .Matches(x => x.NumberOfDaysOfTrendingGames == numberOfDays
                                                                    &&
                                                                    x.NumberOfTrendingGamesToShow == numberOfGames)));

            results[0].ShouldBeSameAs(expectedViewModel1);
            results[1].ShouldBeSameAs(expectedViewModel2);
        }
Exemplo n.º 3
0
        public void It_Returns_The_Trending_Games_Partial_View_With_View_Models_For_Specific_Number_Of_Trending_Games()
        {
            //--arrange
            var expectedTrendingGames = new List <TrendingGame>
            {
                new TrendingGame(),
                new TrendingGame()
            };

            _autoMocker.Get <ITrendingGamesRetriever>()
            .Expect(mock => mock.GetResults(Arg <TrendingGamesRequest> .Is.Anything))
            .Return(expectedTrendingGames);
            var expectedViewModel1 = new TrendingGameViewModel();
            var expectedViewModel2 = new TrendingGameViewModel();

            _autoMocker.Get <ITransformer>().Expect(mock => mock.Transform <TrendingGameViewModel>(expectedTrendingGames[0])).Return(expectedViewModel1);
            _autoMocker.Get <ITransformer>().Expect(mock => mock.Transform <TrendingGameViewModel>(expectedTrendingGames[1])).Return(expectedViewModel2);

            //--act
            var results = _autoMocker.ClassUnderTest.TrendingGames();

            //--assert
            _autoMocker.Get <ITrendingGamesRetriever>().AssertWasCalled(
                mock => mock.GetResults(Arg <TrendingGamesRequest> .Matches(
                                            x => x.NumberOfTrendingGamesToShow == HomeController.NUMBER_OF_TRENDING_GAMES_TO_SHOW &&
                                            x.NumberOfDaysOfTrendingGames == HomeController.NUMBER_OF_DAYS_OF_TRENDING_GAMES)));
            var viewResult = results as PartialViewResult;

            viewResult.ShouldNotBeNull();
            var viewModel = viewResult.Model as List <TrendingGameViewModel>;

            viewModel.ShouldNotBeNull();
            viewResult.ViewName.ShouldBe(MVC.GameDefinition.Views._TrendingGamesPartial);
            viewModel[0].ShouldBeSameAs(expectedViewModel1);
            viewModel[1].ShouldBeSameAs(expectedViewModel2);
        }
        public void It_Returns_The_Trending_Games_Partial_View_With_View_Models_For_Specific_Number_Of_Trending_Games()
        {
            //--arrange
            var numberOfGamesToShow    = 1;
            var numberOfDaysToConsider = 2;
            var expectedTrendingGames  = new List <TrendingGame>
            {
                new TrendingGame(),
                new TrendingGame()
            };

            _autoMocker.Get <ITrendingGamesRetriever>()
            .Expect(mock => mock.GetResults(Arg <TrendingGamesRequest> .Is.Anything))
            .Return(expectedTrendingGames);
            var expectedViewModel1 = new TrendingGameViewModel();
            var expectedViewModel2 = new TrendingGameViewModel();

            _autoMocker.Get <ITransformer>().Expect(mock => mock.Transform <TrendingGameViewModel>(expectedTrendingGames[0])).Return(expectedViewModel1);
            _autoMocker.Get <ITransformer>().Expect(mock => mock.Transform <TrendingGameViewModel>(expectedTrendingGames[1])).Return(expectedViewModel2);

            //--act
            var results = _autoMocker.ClassUnderTest.GetTopGamesPartialView(numberOfGamesToShow, numberOfDaysToConsider);

            //--assert
            _autoMocker.Get <ITrendingGamesRetriever>().AssertWasCalled(
                mock => mock.GetResults(Arg <TrendingGamesRequest> .Matches(
                                            x => x.NumberOfTrendingGamesToShow == numberOfGamesToShow &&
                                            x.NumberOfDaysOfTrendingGames == numberOfDaysToConsider)));
            results.ShouldNotBeNull();
            var viewModel = results.Model as List <TrendingGameViewModel>;

            viewModel.ShouldNotBeNull();
            results.ViewName.ShouldBe(MVC.GameDefinition.Views._TrendingGamesPartial);
            viewModel[0].ShouldBeSameAs(expectedViewModel1);
            viewModel[1].ShouldBeSameAs(expectedViewModel2);
        }
Exemplo n.º 5
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;
        }