public async Task DeleteUserProjectAsync_ShouldReturnStatusCode500_WhenUserprojectIsInvalid() { int id = -2; UserProject userProject = null; _projectBLMock.Setup(i => i.DeleteUserProjectAsync(userProject)).Throws(new Exception()); UserProjectController userProjectController = new UserProjectController(_projectBLMock.Object); var result = await userProjectController.DeleteUserProjectAsync(id); Assert.IsType <StatusCodeResult>(result); Assert.Equal(500, ((StatusCodeResult)result).StatusCode); }
public async Task DeleteUserShouldDeleteUser() { var userProject = new UserProject { Id = 1 }; _projectBLMock.Setup(x => x.DeleteUserProjectAsync(It.IsAny <UserProject>())).Returns(Task.FromResult <UserProject>(userProject)); var userProjectController = new UserProjectController(_projectBLMock.Object); var result = await userProjectController.DeleteUserProjectAsync(userProject.Id); Assert.IsAssignableFrom <NoContentResult>(result); _projectBLMock.Verify(x => x.DeleteUserProjectAsync((It.IsAny <UserProject>()))); }