コード例 #1
0
        public void DeleteTest()
        {
            School v = new School();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.SchoolCode = "ece";
                v.SchoolName = "QZ8AgkqPf";
                context.Set <School>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(SchoolVM));

            SchoolVM vm = rv.Model as SchoolVM;

            v         = new School();
            v.ID      = vm.Entity.ID;
            vm.Entity = v;
            _controller.Delete(v.ID.ToString(), null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <School>().Count(), 0);
            }
        }
コード例 #2
0
        public JsonResult DeleteSchool(int ID)
        {
            SchoolController obj = new SchoolController();
            var response         = obj.Delete(ID);

            return(Json(response, JsonRequestBehavior.AllowGet));;
        }
コード例 #3
0
        public void DeleteSchoolByID_ReturnsHttpOkResult(int schoolId)
        {
            var result = _schoolController.Delete(schoolId);

            Assert.IsInstanceOf <OkObjectResult>(result);
        }