public void CreateReview_OnGetViewModel_ReturnsCorrectInformation()
        {
            var viewModel = new ListRestaurantsViewModel
            {
                ListOrder = "List Order",
                SelectRestaurantPublicId = Guid.Parse("3c1c1b2d-90c5-4be1-a433-65e19dc50896"),
                ViewRestaurantViewModels = new List <ViewRestaurantViewModel>()
            };

            var result = _controller.CreateReview(viewModel) as ViewResult;

            Approvals.Verify(result.Model.ToString());
        }
Beispiel #2
0
        public void Review_Is_Created_By_Create_Action()
        {
            Review review = new Review();

            //ReviewController underTest = new ReviewController ();

            underTest.CreateReview(2);
            var result = db.Reviews;

            Assert.Equals(1);
        }
        public async Task Create_ShouldOk()
        {
            var mock = new Mock <IReviewService>(MockBehavior.Strict);

            mock.Setup(repo => repo.CreateReviewAsync(4, 6, "Mick", "Seen better.", 3)).Returns(Task.Run(() => { })).Verifiable();
            var controller = new ReviewController(mock.Object);

            var result = await controller.CreateReview(4, 6, "Mick", "Seen better.", 3);

            var controllerResult = result as OkResult;

            Assert.IsNotNull(controllerResult);

            mock.Verify();
            mock.Verify(repo => repo.CreateReviewAsync(4, 6, "Mick", "Seen better.", 3), Times.Once);
        }
Beispiel #4
0
        public void CreateReview()
        {
            // Arrange
            var reviewDto = new ReviewDto
            {
                Comment      = "Comment 1",
                Rating       = 4,
                RestaurantId = DataSeeder.Restaurants[0].Id,
                UserId       = DataSeeder.Users[0].Id
            };
            var review = _mapper.Map <Review>(reviewDto);

            Mock.Get(_repositoryWrapper.Review).Setup(x => x.CreateReview(review));
            Mock.Get(_repositoryWrapper.Review).Setup(x => x.GetReviewById(review.Id)).ReturnsAsync(review);
            var controller = new ReviewController(_loggerManager, _mapper, _repositoryWrapper);
            // Act
            var actionResult = controller.CreateReview(reviewDto).Result;
            // Assert
            var okObjectResult = actionResult as OkObjectResult;

            Assert.IsNotNull(okObjectResult);
        }
Beispiel #5
0
        public void CreateReview_OnGetViewModel_ReturnsCorrectView()
        {
            var result = _controller.CreateReview(new ListRestaurantsViewModel()) as ViewResult;

            Assert.AreEqual("CreateReview", result.ViewName);
        }