public async Task TestSearchAssignmentReturnArgumentInRangeInProgressAssignedCreated() { // arrange var assignmentController = GetAssignmentController(); PopulateDataSet1(); var searchQuery = new SearchAssignmentBindingModel { Statuses = new List <AssignmentStatus> { AssignmentStatus.InProgress, AssignmentStatus.Assigned, AssignmentStatus.Created }, StartDateTime = new DateTimeOffset(new DateTime(2017, 05, 13, 15, 30, 0)), EndDateTime = new DateTimeOffset(new DateTime(2017, 05, 13, 16, 30, 0)) }; // act var actualResult = await assignmentController.SearchAssignments(searchQuery); // assert var actualUpdateAssignmentResult = actualResult as OkObjectResult; Assert.True(actualUpdateAssignmentResult != null, "actualUpdateAssignmentResult should be of type OkObjectResult"); Assert.Equal(200, actualUpdateAssignmentResult.StatusCode); Assert.NotNull(actualUpdateAssignmentResult.Value); Assert.Equal(4, ((IEnumerable <AssignmentViewModel>)actualUpdateAssignmentResult.Value).Count()); }
public async Task <IActionResult> SearchAssignments([FromQuery] SearchAssignmentBindingModel search) { var(assignments, outcome, message) = await _assignmentRepository .SearchAssignmentAsync(search.StartDateTime, search.EndDateTime, search.Statuses, populateClient : true, populateWorker : true); var assignmentResponses = outcome == RepositoryOutcomeAction.OkNone ? assignments.Select(MapToAssignmentResponseViewModel).ToList() : null; return(this.FromRepositoryOutcome(outcome, message, assignmentResponses)); }