The controller has a method for adding a new record to the database.

public ActionResult Create() { return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "Id,Cat")] Category category) // { if (ModelState.IsValid) { db.Categories.Add(category); db.SaveChanges(); TempData["message"] = string.Format("Добавление прошло успешно!"); return RedirectToAction("Index"); } return View(category); } 

How to perform a unit test to check the addition. All the examples I was looking for are based on code first, and are completely different from my controller.

  • specify what you want to check. What controller will be called? What controller will cause something? What model will be saved? - Mikhail Vaysman
  • That the controller will call something and save. - test19
  • one
    This is not a unit test. - Mikhail Vaysman

0