public async Task HideReview_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.HideReview(10); var controllerResult = result as NotFoundResult; Assert.IsNotNull(controllerResult); mock.Verify(); mock.Verify(repo => repo.DoesReviewExists(10), Times.Once); }
public async Task HideReview_ShouldOk() { var mock = new Mock <IReviewService>(MockBehavior.Strict); mock.Setup(repo => repo.DoesReviewExists(1)).Returns(Task.FromResult(true)).Verifiable(); mock.Setup(repo => repo.HideReviewAsync(1, "")).Returns(Task.Run(() => { })).Verifiable(); var controller = new ReviewController(mock.Object); var result = await controller.HideReview(1); var controllerResult = result as OkResult; Assert.IsNotNull(controllerResult); mock.Verify(); mock.Verify(repo => repo.DoesReviewExists(1), Times.Once); mock.Verify(repo => repo.HideReviewAsync(1, ""), Times.Once); }