Esempio n. 1
0
        public void Controller_HttpPostDeleteConfirm_Confirms()
        {
            DbSetup();
            ReviewsController controller = new ReviewsController(mock.Object);

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

            //Assert
            Assert.IsInstanceOfType(result, typeof(Task <IActionResult>));
        }
Esempio n. 2
0
        public void testDb_Delete_RemovesFromDb()
        {
            ReviewsController controller = new ReviewsController(db);


            Review testReview = new Review {
                ReviewId = 2, Body = "A Review", Rating = 4, UserName = "******", ItemId = 1
            };


            controller.Create(testReview);
            controller.DeleteConfirmed(testReview.ReviewId);
            var collection = (controller.Index() as ViewResult).ViewData.Model as List <Review>;

            CollectionAssert.DoesNotContain(collection, testReview);
        }
        public async void TestDelete_InvalidReview_ShouldFail(string value)
        {
            // Arrange
            ReviewsController controller = new ReviewsController(_context);
            int gameId = int.Parse(value);

            try
            {
                // Act
                var result = await controller.DeleteConfirmed(gameId);
            }
            // Assert
            catch (Exception ex)
            {
                Assert.Equal("System.ArgumentNullException", ex.GetType().ToString());
            }
        }
Esempio n. 4
0
        public void DB_DeleteConfirmedEntryPOST_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;

            reviewController.DeleteConfirmed(reviewId);
            var collection = db.Reviews.ToList();

            //Assert
            CollectionAssert.DoesNotContain(collection, reviewToDelete);
        }
Esempio n. 5
0
        public async Task DeleteReview_OutOfBounds()
        {
            // Arrange
            var repo         = new FakeReviewRepository(TestData.Reviews());
            var purchaseRepo = new FakePurchaseService(TestData.Purchases());

            using (var controller = new ReviewsController(repo, purchaseRepo, new NullLogger <ReviewsController>()))
            {
                var reviewId = -5;

                // Act
                var result = await controller.DeleteConfirmed(reviewId);

                // Assert
                Assert.IsInstanceOfType(result, typeof(BadRequestResult));
            }
        }