public async Task ChangeUserPrecaution_ReturnsNoContentResult()
        {
            //Arrange
            _PrecautionController.ControllerContext = _context;
            _userPrecautionService
            .Setup(x => x.ChangeUserPrecautionAsync(It.IsAny <UserPrecautionDTO>(), It.IsAny <User>()));
            //Act
            var result = await _PrecautionController.EditUserPrecaution(It.IsAny <UserPrecautionDTO>());

            //Assert
            _userPrecautionService.Verify();
            _userManager.Verify();
            Assert.IsInstanceOf <NoContentResult>(result);
        }
Exemple #2
0
        public async Task ChangeUserPrecaution_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;
            _userPrecautionService
            .Setup(x => x.ChangeUserPrecautionAsync(It.IsAny <UserPrecautionDTO>(), It.IsAny <User>()));
            //Act
            var result = await _PrecautionController.EditUserPrecaution(It.IsAny <UserPrecautionDTO>());

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