public async Task GetUserProjectByID_ShouldReturnNotFound_WhenUserProjectIsNull() { int id = -2; UserProject userProject = null; _projectBLMock.Setup(i => i.GetUserProjectByIDAsync(id)).ReturnsAsync(userProject); UserProjectController userProjectController = new UserProjectController(_projectBLMock.Object); var result = await userProjectController.GetUserProjectByIDAsync(id); Assert.IsType <NotFoundResult>(result); }
public async Task GetUserProjectByIdShouldGetUserProject() { var userProjectId = 1; var userProject = new UserProject { Id = userProjectId }; _projectBLMock.Setup(x => x.GetUserProjectByIDAsync(It.IsAny <int>())).Returns(Task.FromResult(userProject)); var userProjectController = new UserProjectController(_projectBLMock.Object); var result = await userProjectController.GetUserProjectByIDAsync(userProjectId); Assert.Equal(userProjectId, ((UserProject)((OkObjectResult)result).Value).Id); _projectBLMock.Verify(x => x.GetUserProjectByIDAsync(userProjectId)); }