Esempio n. 1
0
        public async Task DeleteGet_Success()
        {
            // Arrange
            var repo         = new FakeReviewRepository(TestData.Reviews());
            var purchaseRepo = new FakePurchaseService(TestData.Purchases());

            using (var controller = new ReviewsController(repo, purchaseRepo, new NullLogger <ReviewsController>()))
            {
                var id = 1;

                // Act
                var result = await controller.Delete(id) as ViewResult;

                // Assert
                Assert.IsNotNull(result);
                var review = result.Model as Review;
                Assert.IsNotNull(review);
                var expected = TestData.Reviews().FirstOrDefault(r => r.Id == id);

                Assert.AreEqual(expected.Id, review.Id);
                Assert.AreEqual(expected.Content, review.Content);
                Assert.AreEqual(expected.IsVisible, review.IsVisible);
                Assert.AreEqual(expected.PurchaseId, review.PurchaseId);
                Assert.AreEqual(expected.Rating, review.Rating);
            }
        }
Esempio n. 2
0
        public void DeleteTest_FailureReturnsObject()
        {
            var RC     = new ReviewsController(connection);
            var review = new ReviewsDAL(connection.AWSconnstring()).GetAllReviews().LastOrDefault();
            var result = RC.Delete(review.ReviewId + 100);

            Assert.IsType <StatusCodeResult>(result);
        }
Esempio n. 3
0
        public void Delete_Review()
        {
            var controller = new ReviewsController(new ReviewRepositoryMock(), new ClientRepositoryMock());

            var result = controller.Delete(ClientRepositoryMock.TestClient.Id);

            Assert.IsType <NoContentResult>(result);
        }
Esempio n. 4
0
        public void DeleteTest_SuccessReturnsOK()
        {
            var RC     = new ReviewsController(connection);
            var review = new ReviewsDAL(connection.AWSconnstring()).GetAllReviews().LastOrDefault();
            var result = RC.Delete(review.ReviewId);

            Assert.IsType <OkResult>(result);
        }
Esempio n. 5
0
        public void TestDeleteCallsDao()
        {
            // Act
            controllerUnderTest.Delete("ABC123");

            // Assert
            mockDao.Verify(dao => dao.Delete("ABC123"));
        }
        public void Delete([Frozen] Mock <IReviewRepository> reviewRepository, [Frozen] Mock <IPaginationHandler <Review, ReviewSortOrder> > paginationHandler)
        {
            var sut = new ReviewsController(reviewRepository.Object, paginationHandler.Object);

            // Act
            ViewResult result = sut.Delete(15) as ViewResult;

            // Assert
            Assert.NotNull(result);
        }
Esempio n. 7
0
        public void DeleteReview()
        {
            // Arrange
            ReviewsController controller = new ReviewsController();

            // Act
            ActionResult result = controller.Delete(null) as HttpNotFoundResult;

            // Assert
            Assert.IsNull(result);
        }
        public void DeleteTest()
        {
            //Arrange
            ReviewsController reviewsController = new ReviewsController();

            //Act
            HttpStatusCodeResult result = reviewsController.Delete(1) as HttpStatusCodeResult;

            //Assert
            Assert.AreEqual(result.StatusCode, 404);
        }
        public void Delete_deletes_review()
        {
            var review = new Review();

            commentRepository.Expect(x => x.GetById(5)).Return(review);

            controller.Delete(5)
            .ReturnsResult <RedirectToReferrerResult>();

            commentRepository.AssertWasCalled(x => x.DeleteOnSubmit(review));
        }
Esempio n. 10
0
        public void Controller_GetViewDelete_Deletes()
        {
            DbSetup();
            ReviewsController controller = new ReviewsController(mock.Object);

            //Act
            var result = controller.Delete(1);

            //Assert
            Assert.IsInstanceOfType(result, typeof(Task <IActionResult>));
        }
        public void Post_DeleteReviewShouldRedirectToCompanyDetailsWhenNotConfirmed()
        {
            //Arrange
            var controller = new ReviewsController(null, this.reviewService.Object, null);

            //Act
            var result = controller.Delete(ReviewId, CompanyId, false);

            //Assert
            this.AssertRedirectToCompanyDetails(result);
        }
        public void Delete_CallsRepository_Returns()
        {
            var reviewRepository = new Mock <IReviewRepository>();

            reviewRepository.Setup(x => x.DeleteReviewAsync(123)).Returns(Task.CompletedTask);

            var sut = new ReviewsController(reviewRepository.Object);

            sut.Delete(123).Wait();

            reviewRepository.VerifyAll();
        }
        public void TestReviewsDelete()
        {
            //Arrange
            FakeRestaurantRepository fakeRestaurantRepository = new FakeRestaurantRepository();
            FakeReviewRepository     fakeReviewRepository     = new FakeReviewRepository();
            ReviewsController        controller = new ReviewsController(fakeRestaurantRepository, fakeReviewRepository);

            //Act
            var result = controller.Delete(2) as ViewResult;
            var data   = result.Model as Review;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("B", data.ReviewerName);
        }
Esempio n. 14
0
        public void DB_DeleteEntryGET_Test()
        {
            CreateReview();
            //Arrange

            var reviewController = new ReviewsController(db);
            var reviewId         = db.Reviews.ToList()[0].ReviewId;
            //Act
            var viewResult     = reviewController.Delete(reviewId) as ViewResult;
            var reviewToDelete = viewResult.ViewData.Model as Review;
            var collection     = db.Reviews.ToList();

            //Assert
            CollectionAssert.Contains(collection, reviewToDelete);
        }
        public void Post_DeleteReviewShouldRedirectToCompanyDetailsWithValidData()
        {
            //Arrange
            var controller = new ReviewsController(null, this.reviewService.Object, null);

            this.reviewService.Setup(r => r.Delete(It.IsAny <int>()))
            .Returns(true);

            this.PrepareTempData();

            controller.TempData = this.tempData.Object;

            //Act
            var result = controller.Delete(ReviewId, CompanyId, true);

            //Assert
            this.AssertRedirectToCompanyDetails(result);
        }
        public void Post_DeleteReviewShouldRedirectToHomeForNonExistingReview()
        {
            //Arrange
            var controller = new ReviewsController(null, this.reviewService.Object, null);

            this.reviewService.Setup(r => r.Delete(It.IsAny <int>()))
            .Returns(false);

            this.PrepareTempData();

            controller.TempData = this.tempData.Object;

            //Act
            var result = controller.Delete(ReviewId, CompanyId, true);

            //Assert
            this.AssertRedirectToHome(result);
            this.customMessage.Should().Be(string.Format(WebConstants.Message.NonExistingEntity, WebConstants.Entity.Review, ReviewId));
        }
Esempio n. 17
0
        public async Task DeleteGet_NoReview()
        {
            // Arrange
            var repo         = new FakeReviewRepository(TestData.Reviews());
            var purchaseRepo = new FakePurchaseService(TestData.Purchases());

            using (var controller = new ReviewsController(repo, purchaseRepo, new NullLogger <ReviewsController>()))
            {
                var id = 360;

                // Act
                var result = await controller.Delete(id);

                // Assert
                Assert.IsNotNull(result);
                var objResult = result as NotFoundResult;
                Assert.IsNotNull(objResult);
            }
        }