Esempio n. 1
0
        public async void Test_Controller_Delete()
        {
            var resultFail = await _controller.Delete(0);

            var resultPass = await _controller.Delete(1);

            Assert.NotNull(resultFail);
            Assert.NotNull(resultPass);
        }
Esempio n. 2
0
 protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
 {
     if (e.CommandName == "Remove")
     {
         int id = Convert.ToInt32(e.CommandArgument);
         _review.Delete(id);
         DataList2.DataBind();
     }
 }
Esempio n. 3
0
        public void DeleteModelUnitTest()
        {
            ReviewController controller = new ReviewController();

            var deleteData = controller.Delete(10) as ViewResult;
            var actual     = deleteData.Model;

            Assert.IsNotNull(actual);
        }
        public void DeletTest()
        {
            ReviewController controller = new ReviewController();

            var delete = controller.Delete(4) as ViewResult;
            var actual = delete.Model;

            Assert.IsNotNull(actual);
        }
Esempio n. 5
0
        public void ReviewControllerTestDeleteModelBinding()
        {
            ReviewController controller = new ReviewController();

            ViewResult view  = (ViewResult)controller.Delete(1);
            var        model = view.Model;

            Assert.IsNotNull(model);
        }
        private void BtDeleteReview_Click(object sender, RoutedEventArgs e)
        {
            Review seletedReview = reviewDataGrid.SelectedItems[0] as Review;
            int    selectedId    = !string.IsNullOrEmpty(TbReviewId.Text) ? TransformStringIntoInt(TbReviewId.Text) : seletedReview.BookID;

            Review deletedBook = reviewsController.Delete(selectedId);

            MessageBox.Show("The Review with " + deletedBook.ToString() + "has been deleted succesfully");
            LoadBooks();
        }
        public void Delete()
        {
            //Arrange
            ReviewController controller = new ReviewController();

            //Act
            ViewResult result = controller.Delete(7) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Esempio n. 8
0
        public void DeleteReview()
        {
            var review = _reviewGenerator.Get();

            _fakeRepository.Setup(m => m.Delete(review.Id));

            var result = _controller.Delete(review.Id);

            result.Should()
            .NotBeNull("a result is always expected").And
            .BeAssignableTo <IActionResult>("it should implement IActionResult").And
            .BeOfType <NoContentResult>("it should be a NoContent result");
        }
Esempio n. 9
0
        public void Mock_GetViewResultDeleteGet_ActionResult()
        {
            //Arrange
            Dispose();
            DbSetup();
            ReviewController controller = new ReviewController(mock.Object);

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

            //Assert
            Assert.IsInstanceOfType(result, typeof(ActionResult));
        }
        public void Delete_Test_ValidInput()
        {
            // Arrange
            int             breweryId = bLogic.GetBreweries().LastOrDefault().BreweryID;
            ReviewViewModel review    = CreateReviewFromForm(collection);

            rLogic.PostReview(review);
            review = rLogic.GetReviews().FirstOrDefault();

            // Act
            RedirectToRouteResult result = controller.Delete(review.ReviewID, collection) as RedirectToRouteResult;

            // Assert
            Assert.AreEqual("Details", result.RouteValues["action"]);
        }
Esempio n. 11
0
        public async Task Delete_Review_From_Database()
        {
            // Arrange
            var review = new GoodReview()
            {
                Id = 1, Message = "Test"
            };

            // Act
            context.Reviews.Add(review);
            context.SaveChanges();
            await controller.Delete(context.Reviews.First().Id);

            // Assert
            Assert.AreEqual(0, context.Reviews.Count());
        }
Esempio n. 12
0
        public void TestReviewDelete()
        {
            // Arrange
            var fakeReview = FakeReviews().First();

            var mockBusinessLogic = new Mock <ISportStoreBusinessLogic>();

            mockBusinessLogic
            .Setup(bl => bl.Review.DeleteById(fakeReview.Id));

            var controller = new ReviewController(mockBusinessLogic.Object);

            // Act
            var result = controller.Delete(fakeReview.Id);

            // Assert
            mockBusinessLogic.VerifyAll();

            Assert.IsInstanceOfType(result, typeof(OkResult));
        }