public void GetAllShouldWorkCorrectly()
        {
            var fakeGamesService      = A.Fake <IGamesService>();
            var fakeGenresService     = A.Fake <IGenresService>();
            var fakeLanguagesService  = A.Fake <ILanguagesService>();
            var fakePublishersService = A.Fake <IPublishersService>();
            var fakeTagsService       = A.Fake <ITagsService>();
            var fakeEnvironment       = A.Fake <IWebHostEnvironment>();
            var fakeWishlistService   = A.Fake <IWishlistService>();
            var fakeOrdersService     = A.Fake <IOrdersService>();
            var fakeCartService       = A.Fake <ICartService>();
            var fakeCache             = A.Fake <IMemoryCache>();

            A.CallTo(() => fakeGamesService.All <GameInListViewModel>(1, 16))
            .Returns(A.CollectionOfFake <GameInListViewModel>(20));

            var gamesController = new GamesController(
                fakeGamesService,
                fakeGenresService,
                fakeLanguagesService,
                fakeTagsService,
                fakePublishersService,
                fakeEnvironment,
                fakeWishlistService,
                fakeOrdersService,
                fakeCartService,
                fakeCache);

            var result = gamesController.All();

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <GamesListViewModel>(viewResult.Model);

            Assert.Equal(20, model.Games.Count());
        }
Beispiel #2
0
        public void GamesAll_ShouldReturnGameStatesOnlyAvailableWithCount2()
        {
            var controller = new GamesController(mockData.Object);

            var actionResult  = controller.All();
            var contentResult = actionResult as OkNegotiatedContentResult <IQueryable <GetGameDataModel> >;

            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(2, contentResult.Content.Count());
        }
Beispiel #3
0
        public void GamesAll_ShouldReturnGameStatesOnlyAvailable()
        {
            var controller = new GamesController(mockData.Object);

            var actionResult  = controller.All();
            var contentResult = actionResult as OkNegotiatedContentResult <IQueryable <GetGameDataModel> >;

            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);

            foreach (var game in contentResult.Content)
            {
                Assert.AreEqual(GameState.WaitingForOpponent.ToString(), game.GameState);
            }
        }