Beispiel #1
0
        public async Task ThrowsBadRequestWhenReviewThrowException()
        {
            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)).ThrowsAsync(new Exception());

            var actionResult = await sut.Deactivate(reviewViewModel.Id);

            var result = (RedirectToActionResult)actionResult;

            Assert.AreEqual("Error", result.ActionName);
            Assert.AreEqual("Home", result.ControllerName);
            Assert.IsInstanceOfType(result, typeof(RedirectToActionResult));
        }
Beispiel #2
0
        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));
        }