public void TestDeleteUserRole() { var origUserRole = _userRoleService.Create(RandomUserRole()).Result; Assert.That(_userRoleService.GetAllUserRoles(_projId).Result, Has.Count.EqualTo(1)); _ = _userRoleController.Delete(_projId, origUserRole.Id).Result; Assert.That(_userRoleService.GetAllUserRoles(_projId).Result, Has.Count.EqualTo(0)); }
public void UserRoleService_DeleteById() { UserRoleController _controller = new UserRoleController(_mockService.Object); var result = _controller.Delete(1); Assert.IsNotNull(result); }
public void UserRoleService_DeleteFromBody() { CACI.DAL.Models.UserRole application = new CACI.DAL.Models.UserRole() { CreatedDate = DateTime.Now.AddDays(-8), ModifiedDate = DateTime.Now, UserRoleId = 1, RoleId = 1, UserId = 1, }; UserRoleController _controller = new UserRoleController(_mockService.Object); var result = _controller.Delete(application); Assert.IsNotNull(result); }
public async void Delete_Errors() { UserRoleControllerMockFacade mock = new UserRoleControllerMockFacade(); var mockResult = new Mock <ActionResponse>(); mockResult.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Delete(It.IsAny <string>())).Returns(Task.FromResult <ActionResponse>(mockResult.Object)); UserRoleController controller = new UserRoleController(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(string)); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Delete(It.IsAny <string>())); }
public void DeleteTests() { var getUserRole = _userRoleController.Delete(userRoleDTO); Assert.ReferenceEquals(Microsoft.AspNetCore.Http.StatusCodes.Status200OK, getUserRole); }