public void Test_Buy_Add_New_Order() { //arrange OrderViewModel model = new OrderViewModel(); model.OrderDetailsList = new List<OrderDetailsViewModel>(); GameController controller = new GameController(_gameService.Object, _commentServise.Object, null, _genreService.Object, _platformTypeService.Object); //act var result = controller.Buy("key", model); //assert Assert.AreEqual( 1, model.OrderDetailsList.Count()); }
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()); }
public void Test_GetGameByKey() { //arrange GameController controller = new GameController(_gameService.Object, _commentServise.Object, null, _genreService.Object, _platformTypeService.Object); //act var result = controller.GetGameByKey("key"); //assert Assert.AreEqual(1, (result.Model as GameDetailsViewModel).GameId); }
public void Test_Download() { //arrange GameController controller = new GameController(_gameService.Object, _commentServise.Object, null, _genreService.Object, _platformTypeService.Object); //act var result = controller.Download("key") as FileContentResult; //arrange Assert.AreEqual(0, result.FileContents.Length); }
public void Test_Delete_Call_Delete() { //arrange GameController controller = new GameController(null, _commentServise.Object, null, null, null); //act controller.DeleteComment(1); //assert _commentServise.Verify( c => c.DeleteComment(It.IsAny<int>()), Times.Once () ); }
public void Test_Comments_Return_Right_Number_Of_Comments() { //arrange GameController controller = new GameController(_gameService.Object, _commentServise.Object, null, _genreService.Object, _platformTypeService.Object); //act var result = controller.Comments("key"); //assert Assert.AreEqual(1, (result.Model as GameCommentsViewModel).Comments.Count()); }