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