void init() //刷新所有页面与数据 { PageList.PageInit(); game = new Game(); adminlogindata = new AdminLoginData(); question = new Question(); i = 0; }
public void DoLogin_With_Right_Credentials(string username, string password) { //DaoFactory.Register<IAdminLoginDao>(typeof(FakeAdminLoginDao)); also works var adminLoginService = new AdminLoginService(new FakeAdminLoginDao()); IAdminLoginData loginData = new AdminLoginData { Username = username, Password = password }; var loginInfo = adminLoginService.DoLogin(loginData); Assert.AreEqual(0, loginInfo.ErrorMessages.Count); Assert.AreEqual(StatusCode.Success, loginInfo.StatusCode); Assert.AreEqual(username, loginInfo.Administrator.Username); }
[TestCase("Cindy", "Eke")] //test property validators seperately public void DoLogin_With_Wrong_Credentials(string username, string password) { DaoFactory.Register <IAdminLoginDao>(typeof(FakeAdminLoginDao)); var adminLoginService = new AdminLoginService(); IAdminLoginData loginData = new AdminLoginData { Username = username, Password = password }; var loginInfo = adminLoginService.DoLogin(loginData); Assert.GreaterOrEqual(loginInfo.ErrorMessages.Count, 1); Assert.AreEqual(StatusCode.Failure, loginInfo.StatusCode); Assert.AreEqual(null, loginInfo.Administrator); }
public AdminLoginInfo DoLogin(IAdminLoginData iAdminLoginData) { AdminLoginInfo adminInfo = new AdminLoginInfo(); AdminLoginData adminLoginData = Mapper.Map <IAdminLoginData, AdminLoginData>(iAdminLoginData); if (!adminLoginData.IsValid()) { return(GetErrorResponse <AdminLoginInfo>(adminLoginData.ErrorMessages)); } Admin admin = adminLoginDao.GetLoginAdmin(adminLoginData); if (admin == null) { return(GetErrorResponse <AdminLoginInfo>("Invalid username/password.")); } adminInfo.Administrator = admin; return(GetSuccessResponse("Successfully Validated", adminInfo)); }
public ActionResult Login(AdminLoginData data) { if (ModelState.IsValid) { var edata = Db.Admins.FirstOrDefault(x => x.Email == data.Email && x.Password == data.Password); var timedata = new AdminLoginData { Email = data.Email, Password = data.Password, }; Db.AdminLoginDatas.Add(timedata); Db.SaveChanges(); if (edata != null) { Session["AdminIsLogedIn"] = true; return(RedirectToAction("Dashboard", "AdminProfile")); } } ViewBag.Error = "Wrong username and password given"; return(View()); }
public AdminLoginInfo DoLogin(AdminLoginData adminLoginData) { return(adminLoginService.DoLogin(adminLoginData)); }