public async Task Succeed() { var reviewServiceMock = new Mock <IReviewService>(); var businessUnitServiceMock = new Mock <IBusinessUnitService>(); var userServiceMock = new Mock <IUserService>(); var wrapperMock = new Mock <IUserServiceWrapper>(); var sut = new ReviewsController(reviewServiceMock.Object, businessUnitServiceMock.Object, userServiceMock.Object, wrapperMock.Object); var reviewViewModel = new ReviewViewModel() { Id = 2, OriginalDescription = "This is second review", EditedDescription = "This is EDIT second review", BusinessUnitId = 1, isVisible = true, Rating = 2 }; reviewServiceMock.Setup(x => x.MakeInVisibleReviewAsync(reviewViewModel.Id)).ReturnsAsync(TestHelpersReviewController.TestReviewDTO02()); var actionResult = await sut.Deactivate(reviewViewModel.Id); Assert.IsInstanceOfType(actionResult, typeof(OkObjectResult)); }
public async Task Succeed() { var reviewServiceMock = new Mock <IReviewService>(); var sut = new ReviewsController(reviewServiceMock.Object); var reviewViewModel = new ReviewViewModel() { Id = 1, OriginalDescription = "This is first review", BusinessUnitId = 1, Rating = 1 }; reviewServiceMock.Setup(x => x.CreateReviewAsync(reviewViewModel.OriginalDescription, reviewViewModel.BusinessUnitId, reviewViewModel.Rating)).ReturnsAsync(TestHelpersReviewController.TestReviewDTO01()); var actionResult = await sut.Create(reviewViewModel); Assert.IsInstanceOfType(actionResult, typeof(OkObjectResult)); }
public async Task ThrowsBadRequestWhenReviewWasNotCreatedNotFoundReviewId() { var reviewServiceMock = new Mock <IReviewService>(); var sut = new ReviewsController(reviewServiceMock.Object); var reviewViewModel = new ReviewViewModel() { Id = 3, OriginalDescription = null, BusinessUnitId = 1, Rating = 1 }; reviewServiceMock.Setup(x => x.CreateReviewAsync(reviewViewModel.OriginalDescription, reviewViewModel.BusinessUnitId, reviewViewModel.Rating)).ReturnsAsync(TestHelpersReviewController.TestReviewDTO01()); var actionResult = await sut.Create(reviewViewModel); Assert.IsInstanceOfType(actionResult, typeof(BadRequestObjectResult)); }
public async Task ThrowsBadRequestWhenReviewWasNotUpdatedNotArgumentExceptionBiggerOriginalDescr() { var reviewServiceMock = new Mock <IReviewService>(); var businessUnitServiceMock = new Mock <IBusinessUnitService>(); var userServiceMock = new Mock <IUserService>(); var wrapperMock = new Mock <IUserServiceWrapper>(); var sut = new ReviewsController(reviewServiceMock.Object, businessUnitServiceMock.Object, userServiceMock.Object, wrapperMock.Object); var reviewViewModel = new ReviewViewModel() { Id = 2, OriginalDescription = new string ('a', 1000), BusinessUnitId = 1, Rating = 2 }; reviewServiceMock.Setup(x => x.UpdateReviewAsync(reviewViewModel.Id, reviewViewModel.EditedDescription)).ReturnsAsync(TestHelpersReviewController.TestReviewDTO02()); var actionResult = await sut.Update(reviewViewModel); Assert.IsInstanceOfType(actionResult, typeof(BadRequestObjectResult)); }