public void EditData_ValidOrInvalidData_Successful() { const string Message = "Data doesnt exsist in the topicinformation db."; //Arrange ManageData manageDataTest = new ManageData(); TopicInformation topicinformation = new TopicInformation { WeekNumber = 12, Topic = "Revision" }; //Act bool isDataEditted = manageDataTest.EditData(topicinformation, "*****@*****.**"); //Assert try { //Returns true if the data passed as parameter to EditData( data ) function exsists in the database Assert.IsTrue(isDataEditted, "Data exsists to be editted."); } catch { //Returns false if the data passed as parameter to EditData( data ) function does not exsist in the database Assert.IsFalse(isDataEditted, Message); } }
public ActionResult Edit([Bind(Include = "WeekNumber,Topic")] TopicInformation topicInformation) { if (!ModelState.IsValid) { return(View(topicInformation)); } bool dataEdit = manageData.EditData(topicInformation, User.Identity.Name); if (dataEdit) { return(RedirectToAction("Index")); } else { ViewBag.Error = "Error occured while editing !"; return(View(topicInformation)); } }