public async Task DeletePrecaution_ReturnsNoContentResult()
        {
            //Arrange
            _PrecautionController.ControllerContext = _context;
            _precautionService
            .Setup(x => x.DeletePrecautionAsync(It.IsAny <int>(), It.IsAny <User>()));
            PrecautionController precautionController = _PrecautionController;
            //Act
            var result = await precautionController.DeletePrecaution(It.IsAny <int>());

            //Assert
            _precautionService.Verify();
            Assert.IsNotNull(result);
            Assert.IsInstanceOf <NoContentResult>(result);
        }
Exemplo n.º 2
0
        public async Task DeletePrecaution_ReturnsNoContentResult()
        {
            //Arrange
            var httpContext = new Mock <HttpContext>();

            httpContext
            .Setup(m => m.User.IsInRole("Admin"))
            .Returns(true);
            var context = new ControllerContext(
                new ActionContext(
                    httpContext.Object, new RouteData(),
                    new ControllerActionDescriptor()));

            _PrecautionController.ControllerContext = context;
            _precautionService
            .Setup(x => x.DeletePrecautionAsync(It.IsAny <int>(), It.IsAny <User>()));
            //Act
            var result = await _PrecautionController.DeletePrecaution(It.IsAny <int>());

            //Assert
            _precautionService.Verify();
            Assert.IsNotNull(result);
            Assert.IsInstanceOf <NoContentResult>(result);
        }