public void UpdateTests() { var getUserRole = _userRoleController.Update(userRoleDTO); Assert.NotNull(getUserRole); Assert.IsInstanceOf <long>(getUserRole); }
public async void Update_NotFound() { UserRoleControllerMockFacade mock = new UserRoleControllerMockFacade(); var mockResult = new Mock <UpdateResponse <ApiUserRoleResponseModel> >(); mockResult.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Update(It.IsAny <string>(), It.IsAny <ApiUserRoleRequestModel>())).Returns(Task.FromResult <UpdateResponse <ApiUserRoleResponseModel> >(mockResult.Object)); mock.ServiceMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <ApiUserRoleResponseModel>(null)); UserRoleController controller = new UserRoleController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiUserRoleModelMapper()); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Update(default(string), new ApiUserRoleRequestModel()); response.Should().BeOfType <StatusCodeResult>(); (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound); mock.ServiceMock.Verify(x => x.Get(It.IsAny <string>())); }