Example #1
0
        public IEnumerable <GameModel> GetGamesByPlatformType(PlatformTypeModel platformTypeModel)
        {
            PlatformType       platformType = _unitOfWork.PlatformTypeRepository.GetById(platformTypeModel.PlatformTypeId);
            IEnumerable <Game> games        = _unitOfWork.GameRepository.GetAll().Where(g => g.PlatformTypes.Contains(platformType));
            var gameModels = Mapper.Map <IEnumerable <GameModel> >(games);

            return(gameModels);
        }
Example #2
0
        public void Check_That_Right_Method_Was_Called_Inside_GetGamesByPlatformType_Action()
        {
            // Arrange
            var mockGameService = new Mock <IGameService>();

            mockGameService.Setup(m => m.GetGamesByPlatformType(It.IsAny <PlatformTypeModel>())).Verifiable();

            GameJsonController gameJsonController = GetGameJsonController(mockGameService);

            var testModel = new PlatformTypeModel();

            // Act
            gameJsonController.GetGamesByPlatformType(testModel);

            // Assert
            mockGameService.Verify(m => m.GetGamesByPlatformType(testModel));
        }
Example #3
0
        public void Check_That_Game_Service_Get_Games_By_PlatformType_Rethrows_An_Exception()
        {
            //Arrange
            var mock = new Mock <IUnitOfWork>();

            mock.Setup(m => m.PlatformTypeRepository.GetById(It.IsAny <int>()))
            .Callback(() => { throw new Exception(); });

            var gameService = new GameService(mock.Object);

            var platformTypeModel = new PlatformTypeModel
            {
                PlatformTypeId = 1,
            };

            //Act
            gameService.GetGamesByPlatformType(platformTypeModel);
        }
Example #4
0
 public async Task <IActionResult> AddPlatformType(PlatformTypeModel publisher) =>
 (await _platformTypeRepository.SaveSafe(publisher))
 .OnSuccess(created => (IActionResult)Ok(created))
 .OnFailure(_ => BadRequest(), error => error is ArgumentNullError)
 .OnFailure(error => error.ToObjectResult(), error => error != null)
 .OnFailure(_ => ModelState.ToObjectResult());
Example #5
0
        public JsonResult GetGamesByPlatformType(PlatformTypeModel platformTypeModel)
        {
            IEnumerable <GameModel> games = _gameService.GetGamesByPlatformType(platformTypeModel);

            return(Json(games, JsonRequestBehavior.AllowGet));
        }