public void CheckEmailTakenTest() { //arrange IAccountContext context = new TestDateContext(); AccountLogic logic = new AccountLogic(); string email = "*****@*****.**"; //act bool checkAccountTaken = logic.CheckAccountTaken(context, email); //assert Assert.IsTrue(checkAccountTaken); }
public IActionResult Register(RegisterViewModel model) { if (!_accountLogic.CheckAccountTaken(model.Email)) { if (model.Password.Length >= 8) { User user = new User(model.Email, model.Username, model.Birthday, model.Password, false); _accountLogic.RegisterAccount(user); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Password is too short, it has to be at least 8 characters"); } else { ModelState.AddModelError("", "Email has already been taken"); } return(View(model)); }