Exemplo n.º 1
0
        public void Test_NewGame()
        {
            //arrange
            GamesController controller = new GamesController(
                _gameService.Object,
                null,
                _genreService.Object,
                _platformTypeService.Object,
                _publisherService.Object);
            CreateGameViewModel game = new CreateGameViewModel()
            {
                Key = "key",
                Description = "description",
                GameId = 1,
                Name = "name",
                Genres = new List<int> { 1 },
                PlatformTypes = new List<int>() { 1 },
                Publishers = "name1"
            };

            //act
            var result = controller.New(game) as ViewResult;

            //assert
            _gameService.Verify(s => s.CreateGame(It.IsAny<GameDTO>()), Times.Once());
        }
Exemplo n.º 2
0
        public void Test_UpdateGame()
        {
            //arrange
            GamesController controller = new GamesController(_gameService.Object, null, null, null, null);
            GameDTO game = new GameDTO() { Key = "key", Description = "description", GameId = 1, Name = "name" };

            //act
            var result = controller.Update(game);

            //assert
            _gameService.Verify(s => s.Edit(It.IsAny<GameDTO>()), Times.Once());
        }
Exemplo n.º 3
0
        public void Test_NumberOfAllGames_Return_Right_Number_Of_Games()
        {
            //arrange
            GamesController controller = new GamesController(_gameService.Object, null, null, null, null);

            //act
            var result = controller.NumberOfAllGames();

            //assert
            Assert.AreEqual(1, (int)result.Model);
        }
Exemplo n.º 4
0
        public void Test_New_Model_Contains_All_PlatformTypes()
        {
            //arrange
            GamesController controller = new GamesController(_gameService.Object, null, _genreService.Object, _platformTypeService.Object, _publisherService.Object);

            //act
            var result = controller.New();

            //assert
            Assert.IsInstanceOfType(result.Model, typeof(GameViewModel));
            Assert.AreEqual(2, (result.Model as GameViewModel).PlatformTypes.Count());
        }
Exemplo n.º 5
0
        public void Test_NewGame_Try_Add_Game_With_Empty_Field()
        {
            //arrange
            GamesController controller = new GamesController(
                _gameService.Object,
                null,
                _genreService.Object,
                _platformTypeService.Object,
                _publisherService.Object);
            CreateGameViewModel game = new CreateGameViewModel()
            {
                Key = "",
                Description = "description",
                GameId = 1,
                Name = "name",
                Genres = new List<int> { 1 },
                PlatformTypes = new List<int> { 1 }
            };

            //act
            controller.ViewData.ModelState.AddModelError("Key", "message");
            var result = controller.New(game) as ViewResult;

            //assert
            Assert.IsFalse(controller.ViewData.ModelState.IsValid);
            Assert.AreEqual(1, result.ViewData.ModelState.Count);
        }
Exemplo n.º 6
0
        public void Test_NewGame_Selected_Genres()
        {
            //arrange
            GamesController controller = new GamesController(
                _gameService.Object,
                null,
                _genreService.Object,
                _platformTypeService.Object,
                _publisherService.Object);
            CreateGameViewModel game = new CreateGameViewModel()
            {
                Key = "key",
                Description = "description",
                GameId = 1,
                Name = "name",
                Genres = new List<int> { 1 },
                PlatformTypes = new List<int> { 1 }
            };

            //act
            controller.ViewData.ModelState.AddModelError("Key", "message");
            var result = controller.New(game) as ViewResult;

            //assert
            Assert.IsInstanceOfType(result.Model, typeof(GameViewModel));
            Assert.AreEqual(2, (result.Model as GameViewModel).PlatformTypes.Count());
        }