public void GetByParentId_ValidId_ShouldReturnValidObject() { listItems[0].Families = childListItems; mock.Setup(repo => repo.GetAllItems(null)).Returns(listItems.AsQueryable()); mockChild.Setup(repo => repo.GetItemsByParentId(1, null)).Returns(childListItems.AsQueryable()); var controller = new BusinessController(mockChild.Object, mock.Object); var result = controller.GetFamiliesByIdBusiness(1); Assert.IsAssignableFrom <ActionResult <IEnumerable <Family> > >(result); Assert.Equal(listItems[0].Families.Count, result.Value.ToList().Count); }
public void GetByParentId_InvalidId_ShouldReturnNotFoundResult() { listItems[0].Families = childListItems; mock.Setup(repo => repo.GetAllItems(null)).Returns(listItems.AsQueryable()); mockChild.Setup(repo => repo.GetItemsByParentId(4, null)).Returns(childListItems.AsQueryable()); var controller = new BusinessController(mockChild.Object, mock.Object); var result = controller.GetFamiliesByIdBusiness(4); Assert.IsAssignableFrom <ActionResult <IEnumerable <Family> > >(result); Assert.IsType <NotFoundResult>(result.Result); }