コード例 #1
0
 public ActionResult Create(Country country)
 {
     // TODO: Add insert logic here
     if (ModelState.IsValid)
     {
         _Country.Create(country);
         return(RedirectToAction("Index"));
     }
     return(View(country));
 }
コード例 #2
0
        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"));
        }
コード例 #3
0
        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);
        }