Beispiel #1
0
        public async void Task_DeleteCategory_Return_NotFound()
        {
            var controller = new ProductCategoryController(context);
            int?id         = 5;
            var data       = await controller.Delete(id);

            Assert.IsType <NotFoundResult>(data);
        }
Beispiel #2
0
        public async void Task_DeleteCategory_Return_BAdResult()
        {
            var controller = new ProductCategoryController(context);
            int?id         = null;
            var data       = await controller.Delete(id);

            Assert.IsType <BadRequestResult>(data);
        }
Beispiel #3
0
        public async void Task_DeleteCategory_Return_OkResult()
        {
            var controller = new ProductCategoryController(context);
            var id         = 3;
            var data       = await controller.Delete(id);

            Assert.IsType <OkObjectResult>(data);
        }
        public async void Task_Delete_return_NotFoundResult()
        {
            var controller = new ProductCategoryController(_context);
            var id         = 18;
            var data       = await controller.Delete(id);

            Assert.IsType <NotFoundResult>(data);
        }
Beispiel #5
0
        public async void Task_DeletePC_Return_OkNotFoundResult()
        {
            var controller = new ProductCategoryController(context);
            var Id         = 9;
            var data       = await controller.Delete(Id);

            Assert.IsType <NotFoundResult>(data);
        }
Beispiel #6
0
        public async void Delete_Errors()
        {
            ProductCategoryControllerMockFacade mock = new ProductCategoryControllerMockFacade();
            var mockResult = new Mock <ActionResponse>();

            mockResult.SetupGet(x => x.Success).Returns(false);
            mock.ServiceMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.FromResult <ActionResponse>(mockResult.Object));
            ProductCategoryController controller = new ProductCategoryController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Delete(default(int));

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Delete(It.IsAny <int>()));
        }