public void GetById_InvalidId_ShouldReturnNotFoundResult() { mock.Setup(repo => repo.GetAllItems(null)).Returns(listItems.AsQueryable()); mock.Setup(repo => repo.GetItem(4, null)).Returns(listItems[0]); var controller = new OfferingController(mockChild.Object, mock.Object); var result = controller.GetById(4); Assert.IsAssignableFrom <ActionResult <Offering> >(result); Assert.IsType <NotFoundResult>(result.Result); }
public void GetById_ValidId_ShouldReturnValidObject() { mock.Setup(repo => repo.GetAllItems(null)).Returns(listItems.AsQueryable()); mock.Setup(repo => repo.GetItem(1, null)).Returns(listItems[0]); var controller = new OfferingController(mockChild.Object, mock.Object); var result = controller.GetById(1); Assert.IsAssignableFrom <ActionResult <Offering> >(result); Assert.Equal(listItems[0].Id, result.Value.Id); }