public ActionResult Create(Country country) { // TODO: Add insert logic here if (ModelState.IsValid) { _Country.Create(country); return(RedirectToAction("Index")); } return(View(country)); }
public ActionResult Create(Country country) { // TODO: Add insert logic here if (!ModelState.IsValid) { //ModelState.AddModelError("Name", @"Please Insert Valid Country Name"); return(View(country)); } _country.Create(country); return(RedirectToAction("Index")); }
public void Can_Add_Country() { //Arrange var Id = 1; var emp = new Country { Name = "UK" }; _mockRepository.Setup(m => m.Add(emp)).Returns((Country e) => { e.Id = Id; return(e); }); //Act _service.Create(emp); //Assert Assert.AreEqual(Id, emp.Id); _mockRepository.Verify(m => m.Save(), Times.Once); }