Пример #1
0
        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());
        }
Пример #2
0
        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());
        }
Пример #3
0
        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));
        }
Пример #4
0
        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());
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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 () );
        }
Пример #8
0
        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());
        }