public void Test_NewComment_Return_Right_Number_Of_Comments() { //arrange GameController controller = new GameController(_gameService.Object, _commentServise.Object, null, _genreService.Object, _platformTypeService.Object); CommentViewModel model = new CommentViewModel() { Body = "body", Name = "Name", GameKey = "key" }; //act controller.ViewData.ModelState.AddModelError("body", "empty"); var result = controller.NewComment(model) as ViewResult; //arrange Assert.AreEqual(1, (result.Model as GameCommentsViewModel).Comments.Count()); }
public void Test_NewComment_Try_Add_With_Empty_Body() { //arrange GameController controller = new GameController(_gameService.Object, _commentServise.Object, null, _genreService.Object, _platformTypeService.Object); CommentViewModel model = new CommentViewModel() { Body = "body", Name = "Name", GameKey = "key" }; //act controller.ViewData.ModelState.AddModelError("body", "empty"); var result = controller.NewComment(model) as ViewResult; //arrange Assert.IsNotNull(result); Assert.AreEqual(1, controller.ViewData.ModelState.Count); Assert.IsInstanceOfType(result.Model, typeof(GameCommentsViewModel)); }
public void Test_NewComment_Call_AddCommentToGame() { //arrange GameController controller = new GameController(_gameService.Object, _commentServise.Object, null, _genreService.Object, _platformTypeService.Object); CommentViewModel model = new CommentViewModel() {Body = "body", Name = "Name", GameKey = "key"}; //act var result = controller.NewComment(model); //arrange _commentServise.Verify(s => s.AddCommentToGame(It.IsAny<CommentDTO>(), It.IsAny<GameDTO>()), Times.Once()); }