Пример #1
0
 public void TestEditMonHoc()
 {
     var _monHocController = new MonHocController();
     var monHoc = new MonHoc(id, maMH, tenMH, soTC, soGLT, soGTH, soGT, "");
     _monHocController.Create(monHoc);
     var result = _monHocController.Edit(monHoc.Id) as ViewResult;
     var mH = (MonHoc)result.ViewData.Model;
     Assert.AreEqual("Mon hoc 1", mH.tenMonHoc);
     _monHocController.Delete(monHoc.Id);
 }
Пример #2
0
        public void TestDeleteMonHoc()
        {
            //Test chuc nang xoa Mon hoc khoi database
            var _monHocController = new MonHocController();
            var monHoc = new MonHoc(id, maMH, tenMH, soTC, soGLT, soGTH, soGT, "");
            _monHocController.Create(monHoc);

            var result = _monHocController.Delete(monHoc.Id) as ViewResult;
            var mH = (MonHoc)result.ViewData.Model;
            Assert.AreEqual("Mon hoc 1", mH.tenMonHoc);
        }
Пример #3
0
        public ActionResult Create(MonHoc monhoc)
        {
            if (ModelState.IsValid)
            {
                db.monHocs.Add(monhoc);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(monhoc);
        }
Пример #4
0
        public void TestCreateMonHoc()
        {
            //Test chuc nang them mon hoc vao database
            var monHoc = new MonHoc(id, maMH, tenMH, soTC, soGLT, soGTH, soGT, "");

            var _monHocController = new MonHocController();
            var result = _monHocController.Create(monHoc) as RedirectToRouteResult;
            //Them mon hoc vao database
            Assert.NotNull(result);
            Assert.AreEqual("Index", result.RouteValues["action"]);

            _monHocController.Delete(monHoc.Id);
            //Xoa mon hoc da them
        }
Пример #5
0
        public void TestSearchMonHoc()
        {
            var _monHocController = new MonHocController();
            var monHoc = new MonHoc(id, maMH, tenMH, soTC, soGLT, soGTH, soGT, "");
            _monHocController.Create(monHoc);

            var result = _monHocController.SearchMonHoc(monHoc.tenMonHoc) as ViewResult;
            Assert.NotNull(result);
            _monHocController.Delete(monHoc.Id);
        }
Пример #6
0
 public ActionResult Edit(MonHoc monhoc)
 {
     if (ModelState.IsValid)
     {
         db.Entry(monhoc).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(monhoc);
 }