public void EditReview_OnGetGivenViewModel_ReturnsCorrectInformation()
        {
            var review = new Review
            {
                Restaurant     = _testContext.Restaurants.First(),
                ReviewId       = Guid.Parse("9e648277-e81f-44a8-9b32-519c3d1c6afc"),
                ReviewPublicId = Guid.Parse("649ec18a-910e-4ee8-a805-d0c0343b7853"),
                ReviewerName   = "Default",
                Comment        = "Default Comment",
                Rating         = 1
            };

            _testContext.Reviews.RemoveRange(_testContext.Reviews);
            _testContext.Reviews.Add(review);
            _testContext.SaveChanges();

            var result = _controller.EditReview(new RestaurantReviewsViewModel {
                SelectReviewPublicId = review.ReviewPublicId
            }) as ViewResult;

            Approvals.Verify(result.Model.ToString());
        }
        public async Task Edit_ShouldNotFound()
        {
            var mock = new Mock <IReviewService>(MockBehavior.Strict);

            mock.Setup(repo => repo.DoesReviewExists(10)).Returns(Task.FromResult(false)).Verifiable();
            var controller = new ReviewController(mock.Object);

            var result = await controller.EditReview(10, "Seen better.", 3);

            var controllerResult = result as NotFoundResult;

            Assert.IsNotNull(controllerResult);

            mock.Verify();
            mock.Verify(repo => repo.DoesReviewExists(10), Times.Once);
        }
示例#3
0
        public void EditReview_OnGetViewModel_ReturnsCorrectView()
        {
            var result = _controller.EditReview(new RestaurantReviewsViewModel()) as ViewResult;

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