public void createMainfoodWithoutName() { var menu = new MainFood() { }; Exception ex = Assert.ThrowsException <ArgumentException>(() => mainFoodService.AddMainFood(menu)); Assert.AreEqual("Main Food needs a name.", ex.Message); }
public ActionResult <MainFood> Post([FromBody] MainFood mFood) { try { return(Ok(_mainFoodService.AddMainFood(mFood))); } catch (Exception e) { return(BadRequest(e.Message)); } }