public void return_all_comments_for_a_workitemid() { var workItemId = Any.Int(); var workItemCommentsFromWit = Any.Communications(length: 2, workItemId: workItemId); var expectedWorkItemComments = new List <WorkItemCommentModel> { workItemCommentsFromWit[0].MapCommunicationToWorkItemCommentModel(), workItemCommentsFromWit[1].MapCommunicationToWorkItemCommentModel() }; _workItemServiceRepositoryMock.Setup(repository => repository .GetAllWorkItemComments(workItemId)) .Returns(new GetWorkItemCommunicationsResponse { Communications = workItemCommentsFromWit }); var httpResponse = GetAllWorkItemComments(workItemId) as OkObjectResult; Assert.Equal(200, httpResponse.StatusCode); var actualWorkItemComments = (((httpResponse.Value as ApiOkResponse).Result as ResourceWrapper <WorkItemCommentInfoModel>).Value as WorkItemCommentInfoModel).WorkItemComments; Assert.Equal(expectedWorkItemComments[0].WorkItemId, actualWorkItemComments[0].WorkItemId); Assert.Equal(expectedWorkItemComments[0].CommentId, actualWorkItemComments[0].CommentId); Assert.Equal(expectedWorkItemComments[0].CreatedByUserName, actualWorkItemComments[0].CreatedByUserName); Assert.Equal(expectedWorkItemComments[0].CreatedDate, actualWorkItemComments[0].CreatedDate); Assert.Equal(expectedWorkItemComments[0].Details, actualWorkItemComments[0].Details); Assert.Equal(expectedWorkItemComments[1].WorkItemId, actualWorkItemComments[1].WorkItemId); Assert.Equal(expectedWorkItemComments[1].CommentId, actualWorkItemComments[1].CommentId); Assert.Equal(expectedWorkItemComments[1].CreatedByUserName, actualWorkItemComments[1].CreatedByUserName); Assert.Equal(expectedWorkItemComments[1].CreatedDate, actualWorkItemComments[1].CreatedDate); Assert.Equal(expectedWorkItemComments[1].Details, actualWorkItemComments[1].Details); }
public void get_all_comments_for_work_item() { var workItemId = Any.Int(); var expectedResponse = new GetWorkItemCommunicationsResponse { Communications = Any.Communications(length: Any.Int(), workItemId: workItemId) }; var workItemServiceMock = new Mock <IWorkItemService>(); workItemServiceMock.Setup(settings => settings .GetWorkItemCommunicationsAsync(It.Is <GetWorkItemCommunicationsRequest>(request => request.WorkItemId == workItemId))) .Returns(Task.FromResult(expectedResponse)); var actualResponse = GetAllWorkItemComments(() => { return(workItemServiceMock.Object); }, workItemId); Assert.Equal(expectedResponse, actualResponse); }