public HttpResponseMessage GetMilestones([FromUri] Guid id) { try { var milestones = _milestoneService.GetAllMilestones(id); if (milestones == null) { return(Request.CreateResponse(HttpStatusCode.OK, new List <MilestoneDto>())); } return(Request.CreateResponse(HttpStatusCode.OK, milestones)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public void ShouldReturnAKnownCollectionOfOrderedMilestones() { //Arrange IEnumerable<Milestone> expectedMilestones = new List<Milestone>() { new Milestone(1, 100, "Testing 1", null), new Milestone(7, 200, "Testing 2", null), new Milestone(2, 300, "Testing 3", null), new Milestone(4, 400, "Testing 4", null), new Milestone(3, 500, "Testing 5", null) }; IEnumerable<Milestone> expectedOrderedMilestones = expectedMilestones.OrderBy(m => m.Id); mockRepository.Setup(r => r.GetAll()).Returns(expectedMilestones); IMilestoneService service = new MilestoneService(mockRepository.Object); //Act IEnumerable<Milestone> milestones = service.GetAllMilestones(); //Assert milestones.Should().NotBeNull(); milestones.Should().ContainInOrder(expectedOrderedMilestones); milestones.Count().Should().Be(expectedOrderedMilestones.Count()); }