public void TestEditPost() { var db = new CsK23T2aEntities1(); var model = new tableCUSTOMER { idKH = db.tableCUSTOMERs.AsNoTracking().First().idKH, tenKH = "Nguyen123" }; var controller = new Admin_tableCUSTOMERsController(); using (var scope = new TransactionScope()) { var result = controller.Create(model); var view = result as ViewResult; controller = new Admin_tableCUSTOMERsController(); result = controller.Edit(model); var redirect = result as RedirectToRouteResult; Assert.IsNotNull(redirect); Assert.AreEqual("Index", redirect.RouteValues["action"]); var item = db.tableCUSTOMERs.Find(model.idKH); Assert.IsNotNull(item); Assert.AreEqual(model.tenKH, item.tenKH); } }
public void TestCreatePost() { var db = new CsK23T2aEntities1(); var model = new tableCUSTOMER { tenKH = "Nguyen", gioitinh = "Nam", sodienthoaiKH = "0979320779", diachi = "HCM", ghichu = "1" }; var controller = new Admin_tableCUSTOMERsController(); using (var scope = new TransactionScope()) { var result = controller.Create(model); var redirect = result as RedirectToRouteResult; Assert.IsNotNull(redirect); Assert.AreEqual("Index", redirect.RouteValues["action"]); var item = db.tableCUSTOMERs.Find(model.idKH); Assert.IsNotNull(item); Assert.AreEqual(model.tenKH, item.tenKH); Assert.AreEqual(model.gioitinh, item.gioitinh); Assert.AreEqual(model.sodienthoaiKH, item.sodienthoaiKH); Assert.AreEqual(model.diachi, item.diachi); Assert.AreEqual(model.ghichu, item.ghichu); } }
public void TestTraLoiGet() { var db = new CsK23T2aEntities1(); var item = db.Contacts.First(); var controller = new Admin_CapNhat_Xoa_TraLoiController(); var result = controller.TraLoi(2); Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult)); result = controller.TraLoi(item.idContact); var view = result as ViewResult; Assert.IsNotNull(view); var model = view.Model as Contact; Assert.IsNotNull(model); Assert.AreEqual(item.idContact, model.idContact); Assert.AreEqual(item.chuDe, model.chuDe); Assert.AreEqual(item.tieuDe, model.tieuDe); Assert.AreEqual(item.noiDung, model.noiDung); Assert.AreEqual(item.hoTen, model.hoTen); Assert.AreEqual(item.email, model.email); Assert.AreEqual(item.sdt, model.sdt); Assert.AreEqual(item.thoiGianGui, model.thoiGianGui); Assert.AreEqual(item.traLoi, model.traLoi); Assert.AreEqual(item.thoigianTraLoi, model.thoigianTraLoi); Assert.AreEqual(item.trangThai, model.trangThai); Assert.AreEqual(item.ghiChu, model.ghiChu); }
public void TestEditPost() { var db = new CsK23T2aEntities1(); var model = new tablePRODUCTofYourCart { idSP = db.tablePRODUCTofYourCarts.AsNoTracking().First().idSP, tenSP = "Vay Sieu Nhan" }; var controller = new Admin_tablePRODUCTofYourCartsController(); using (var scope = new TransactionScope()) { //var result = controller.Create(model); //var view = result as ViewResult; //controller = new Admin_tablePRODUCTofYourCartsController(); //result = controller.Edit(model); //var redirect = result as RedirectToRouteResult; //Assert.IsNotNull(redirect); //Assert.AreEqual("Index", redirect.RouteValues["action"]); //var item = db.tablePRODUCTofYourCarts.Find(model.idSP); //Assert.IsNotNull(item); //Assert.AreEqual(model.tenSP, item.tenSP); } }
public void TestEditGet() { var db = new CsK23T2aEntities1(); var item = db.tablePRODUCTofYourCarts.First(); var controller = new Admin_tablePRODUCTofYourCartsController(); var result = controller.Edit(0); Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult)); }
public void TestDelete() { var controller = new Admin_tableCUSTOMERsController(); var db = new CsK23T2aEntities1(); using (var scope = new TransactionScope()) { var result = controller.Delete(0); Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult)); } }
public void TestCreatePost() { var db = new CsK23T2aEntities1(); var model = new tablePRODUCTofYourCart { tenSP = "Vay Sieu Nhan", ghichu = "1" }; var controller = new Admin_tablePRODUCTofYourCartsController(); using (var scope = new TransactionScope()) { } }
public void TestIndex() { var db = new CsK23T2aEntities1(); var controller = new Admin_tableCUSTOMERsController(); var result = controller.Index(searchString); var view = result as ViewResult; Assert.IsNotNull(view); var model = view.Model as List <tableCUSTOMER>; var movies = from m in db.tableCUSTOMERs select m; Assert.IsNotNull(movies); Assert.AreEqual(model, searchString); }
public void TestTraLoiPost() { var db = new CsK23T2aEntities1(); var model = new Contact { idContact = db.Contacts.AsNoTracking().First().idContact, chuDe = "chủ đề", tieuDe = "Tiêu đề", hoTen = "Họ tên", noiDung = "Nội dung", email = "Email", sdt = "0123456789", }; var controller = new Admin_CapNhat_Xoa_TraLoiController(); using (var scope = new TransactionScope()) { var result = controller.TraLoi(model); var view = result as ViewResult; //Assert.IsNotNull(view); //Assert.IsInstanceOfType(view.Model, typeof(Contact)); //model.traLoi = "Trả Lời"; //model.trangThai = true; //model.thoigianTraLoi = DateTime.Now.Date; //controller = new Admin_CapNhat_Xoa_TraLoiController(); //result = controller.TraLoi(model); //var redirect = result as RedirectToRouteResult; //Assert.IsNotNull(redirect); //Assert.AreEqual("Index", redirect.RouteValues["action"]); //var item = db.Contacts.Find(model.idContact); //Assert.IsNotNull(item); //Assert.AreEqual(model.idContact, item.idContact); //Assert.AreEqual(model.chuDe, item.chuDe); //Assert.AreEqual(model.tieuDe, item.tieuDe); //Assert.AreEqual(model.noiDung, item.noiDung); //Assert.AreEqual(model.hoTen, item.hoTen); //Assert.AreEqual(model.email, item.email); //Assert.AreEqual(model.sdt, item.sdt); //Assert.AreEqual(model.thoiGianGui, item.thoiGianGui); //Assert.AreEqual(model.traLoi, item.traLoi); //Assert.AreEqual(model.thoigianTraLoi, item.thoigianTraLoi); //Assert.AreEqual(model.trangThai, item.trangThai); //Assert.AreEqual(model.ghiChu, item.ghiChu); } }
public void TestCreatePost() { var db = new CsK23T2aEntities1(); var model = new tableBILL { tenKH = "Nguyen", sodienthoaiKH = "0979320779", ngaydathang = null, ngaynhanhang = null, diachinhanhang = "HCM", tenSP = "sda", dongiaSP = 100, soluongSP = 5, ghichuSP = "khong", thanhtienBILL = 500, ghichuBILL = "khong" }; var controller = new Admin_tableBILLsController(); using (var scope = new TransactionScope()) { var result = controller.Create(model); var redirect = result as RedirectToRouteResult; Assert.IsNotNull(redirect); Assert.AreEqual("Index", redirect.RouteValues["action"]); var item = db.tableBILLs.Find(model.idHD); Assert.IsNotNull(item); Assert.AreEqual(model.tenKH, item.tenKH); Assert.AreEqual(model.sodienthoaiKH, item.sodienthoaiKH); Assert.AreEqual(model.ngaydathang, item.ngaydathang); Assert.AreEqual(model.ngaynhanhang, item.ngaynhanhang); Assert.AreEqual(model.diachinhanhang, item.diachinhanhang); Assert.AreEqual(model.tenSP, item.tenSP); Assert.AreEqual(model.dongiaSP, item.dongiaSP); Assert.AreEqual(model.soluongSP, item.soluongSP); Assert.AreEqual(model.ghichuSP, item.ghichuSP); Assert.AreEqual(model.thanhtienBILL, item.thanhtienBILL); Assert.AreEqual(model.ghichuBILL, item.ghichuBILL); } }
public void TestEditGet() { var db = new CsK23T2aEntities1(); var item = db.tableCUSTOMERs.First(); var controller = new Admin_tableCUSTOMERsController(); var result = controller.Edit(0); Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult)); result = controller.Edit(item.idKH); var view = result as ViewResult; Assert.IsNotNull(view); var model = view.Model as tableCUSTOMER; Assert.IsNotNull(model); }
public void TestXoa() { var db = new CsK23T2aEntities1(); var controller = new Admin_CapNhat_Xoa_TraLoiController(); using (var scope = new TransactionScope()) { var result = controller.Xoa(2); Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult)); var model = db.Contacts.AsNoTracking().First(); result = controller.Xoa(model.idContact); var redirect = result as RedirectToRouteResult; Assert.IsNotNull(redirect); Assert.AreEqual("Index", redirect.RouteValues["action"]); var item = db.Contacts.Find(model.idContact); Assert.IsNull(item); } }