public void GetTasks_returns_correct_response()
 {
     var requestMessage = HttpRequestMessageFactory.CreateRequestMessage();
     var request = new PagedDataRequest(1, 25);
     var response = new PagedDataInquiryResponse<Task>();
     _mockBlock.PagedDataRequestFactoryMock
         .Setup(x => x.Create(requestMessage.RequestUri)).Returns(request);
     _mockBlock.AllTasksInquiryProcessorMock
         .Setup(x => x.GetTasks(request)).Returns(response);
     var actualResponse = _controller.GetTasks(requestMessage);
     Assert.AreSame(response, actualResponse);
 }
 public PagedTaskDataInquiryResponse GetTasks(PagedDataRequest requestInfo)
 {
     var queryResult = _queryProcessor.GetTasks(requestInfo);
     var tasks = GetTasks(queryResult.QueriedItems).ToList();
     var inquiryResponse = new PagedTaskDataInquiryResponse
     {
         Items = tasks,
         PageCount = queryResult.TotalPageCount,
         PageNumber = requestInfo.PageNumber,
         PageSize = requestInfo.PageSize
     };
     AddLinksToInquiryResponse(inquiryResponse);
     return inquiryResponse;
 }
 public void GetTasks_returns_correct_result()
 {
     var requestInfo = new PagedDataRequest(PageNumber, PageSize);
     var taskEntity = new Task {TaskId = 300};
     var queriedItems = new[] {taskEntity};
     var queryResult = new QueryResult<Task>(queriedItems, queriedItems.Count(), PageSize);
     var task = new Models.Task {TaskId = taskEntity.TaskId};
     var tasks = new[] {task};
     _allTasksQueryProcessorMock.Setup(x => x.GetTasks(requestInfo)).Returns(queryResult);
     _inquiryProcessor.GetTasksTestDouble = items => items == queriedItems ? tasks : null;
     var actualResult = _inquiryProcessor.GetTasks(requestInfo);
     Assert.IsTrue(tasks.SequenceEqual(actualResult.Items), "Incorrect Items in result");
     Assert.AreEqual(queryResult.TotalPageCount, actualResult.PageCount, "Incorrect PageCount in result");
     Assert.AreEqual(PageNumber, actualResult.PageNumber, "Incorrect PageNumber in result");
     Assert.AreEqual(PageSize, actualResult.PageSize, "Incorrect PageSize in result");
 }
 public void GetTasks_adds_links()
 {
     var requestInfo = new PagedDataRequest(PageNumber, PageSize);
     var taskEntity = new Task {TaskId = 300};
     var queriedItems = new[] {taskEntity};
     var queryResult = new QueryResult<Task>(queriedItems, queriedItems.Count(), PageSize);
     var task = new Models.Task {TaskId = taskEntity.TaskId};
     var tasks = new[] {task};
     _allTasksQueryProcessorMock.Setup(x => x.GetTasks(requestInfo)).Returns(queryResult);
     _inquiryProcessor.GetTasksTestDouble = items => items == queriedItems ? tasks : null;
     var linksWereAdded = false;
     _inquiryProcessor.AddLinksToInquiryResponseTestDouble =
         response => linksWereAdded = tasks.SequenceEqual(response.Items)
                                      && response.PageCount == queryResult.TotalPageCount
                                      && response.PageNumber == PageNumber
                                      && response.PageSize == PageSize;
     _inquiryProcessor.GetTasks(requestInfo);
     Assert.IsTrue(linksWereAdded);
 }