Esempio n. 1
0
        public void CreateReviewTest()
        {
            ReviewsController controller = new ReviewsController();

            ViewResult result = controller.CreateReview(2) as ViewResult;

            Assert.IsNotNull(result);
        }
        public async Task CreateReview_ReturnsBadRequest_WhenModelStateIsInvalid()
        {
            // arrange
            var controller = new ReviewsController(_context);

            controller.ModelState.AddModelError("Description", "Required");

            // act
            var result = await controller.CreateReview(new Review());

            // assert
            Assert.IsType <BadRequestObjectResult>(result);
        }
        public async Task CreateReview_ReturnsOkObjectResult_WhenInsertingReview()
        {
            // arrange
            var controller = new ReviewsController(_context);

            // act
            var result = await controller.CreateReview(new Review {
                Id          = 4,
                Description = "Good course!",
                ProgramId   = 6,
                CourseId    = 3,
                SchoolId    = 1,
                Rating      = 4,
                CampusId    = 1,
                InterestId  = 1,
                UsersId     = 1
            });

            // assert
            Assert.IsType <OkObjectResult>(result);
        }