public void IsNullOrEmpty() { var strList1 = new List <string> { "1", "2" }; var strList2 = new List <string>(); List <string> strList3 = null; Assert.True(!EmptyUtil.IsNullOrEmpty(strList1)); Assert.True(EmptyUtil.IsNullOrEmpty(strList2)); Assert.True(EmptyUtil.IsNullOrEmpty(strList3)); var intList1 = new List <int> { 1, 2 }; var intList2 = new List <int>(); List <int> intList3 = null; Assert.True(!EmptyUtil.IsNullOrEmpty(intList1)); Assert.True(EmptyUtil.IsNullOrEmpty(intList2)); Assert.True(EmptyUtil.IsNullOrEmpty(intList3)); }
public ActionResult Login(User user) { if (loginService.CheckLogin(user)) { Session["Name"] = loginService.GetName(user); Session["Account"] = loginService.GetUser(user.UserName, user.Password); return(RedirectToAction("Home", "Home")); } else { if (EmptyUtil.CheckEmpty(user.UserName) || EmptyUtil.CheckEmpty(user.Password)) { ModelState.AddModelError("", "Hãy nhập tài khoản hoặc mật khẩu!"); } else { ModelState.AddModelError("", "Tài khoản hoặc mật khẩu không đúng!"); } } return(View()); }