public void DeleteReview_OnPostViewModel_ReturnsCorrectRedirect() { var result = _controller.DeleteReview(new RestaurantReviewsViewModel()) as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("ListRestaurants", result.RouteValues["Action"]); Assert.AreEqual("Restaurant", result.RouteValues["Controller"]); }
protected void btnDelete_Click(object sender, EventArgs e) { string token = Request.QueryString["Token"]; Models.Review review = ReviewController.GetReviewByToken(token); if (review != null) { ReviewController.DeleteReview(review.Id); lblError.Text = ""; Response.Redirect("ReviewPage.aspx?Token=" + token); } }
public void DeleteReview() { // Arrange var review = DataSeeder.Reviews[0]; Mock.Get(_repositoryWrapper.Review).Setup(x => x.DeleteReview(review)); Mock.Get(_repositoryWrapper.Review).Setup(x => x.GetReviewById(review.Id)).ReturnsAsync(review); var controller = new ReviewController(_loggerManager, _mapper, _repositoryWrapper); // Act var actionResult = controller.DeleteReview(review.Id).Result; // Assert var noContentResult = actionResult as NoContentResult; Assert.IsNotNull(noContentResult); }
public async Task Delete_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.DeleteReview(10); var controllerResult = result as NotFoundResult; Assert.IsNotNull(controllerResult); mock.Verify(); mock.Verify(repo => repo.DoesReviewExists(10), Times.Once); }
public async Task Delete_ShouldOk() { var mock = new Mock <IReviewService>(MockBehavior.Strict); mock.Setup(repo => repo.DoesReviewExists(1)).Returns(Task.FromResult(true)).Verifiable(); mock.Setup(repo => repo.DeleteReviewAsync(1, "")).Returns(Task.Run(() => { })).Verifiable(); var controller = new ReviewController(mock.Object); var result = await controller.DeleteReview(1); var controllerResult = result as OkResult; Assert.IsNotNull(controllerResult); mock.Verify(); mock.Verify(repo => repo.DoesReviewExists(1), Times.Once); mock.Verify(repo => repo.DeleteReviewAsync(1, ""), Times.Once); }
protected void cmdDelete_Click(object sender, EventArgs e) { try { if (!Null.IsNull(_nav.ReviewID)) { ReviewController controller = new ReviewController(); controller.DeleteReview(_nav.ReviewID); _nav.ReviewID = Null.NullInteger; } InvokeEditComplete(); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public void DeleteReview_OnPostViewModel_DeletesReview() { var review = new Review { Restaurant = _testContext.Restaurants.First(), ReviewId = Guid.Parse("80d38bb3-026e-4911-917e-f3e9f0e3a2c9"), ReviewPublicId = Guid.Parse("3176bb5f-c69a-48fe-900d-10d3e3a6f58e"), ReviewerName = "Default", Comment = "Default Comment", Rating = 1 }; _testContext.Reviews.RemoveRange(_testContext.Reviews); _testContext.Reviews.Add(review); _testContext.SaveChanges(); _controller.DeleteReview(new RestaurantReviewsViewModel { SelectReviewPublicId = review.ReviewPublicId }); var reviews = _testContext.Reviews.ToList(); Assert.IsFalse(reviews.Contains(review)); }