public void Create_NullObject_ShouldReturnBadRequest() { mock.Setup(repo => repo.GetAllItems(null)).Returns(listItems.AsQueryable()); mock.Setup(repo => repo.Create(null)); var controller = new OfferingController(mockChild.Object, mock.Object); var result = controller.Create(null); Assert.IsType <BadRequestResult>(result.Result); }
public void Create_ValidObject_ShouldReturnValidObjectAndCreatedAtObjectResult() { var offering3 = new Offering { Id = 3, Name = "name3", Departments = null }; mock.Setup(repo => repo.GetAllItems(null)).Returns(listItems.AsQueryable()); mock.Setup(repo => repo.Create(offering3)); var controller = new OfferingController(mockChild.Object, mock.Object); var result = controller.Create(offering3); Assert.IsAssignableFrom <ActionResult <Offering> >(result); Assert.IsType <CreatedAtActionResult>(result.Result); }