public void Merge_Alerts() { Alerts part = new Alerts(); part.AddError("SecondError"); alerts.AddError("FirstError"); IEnumerable <Alert> expected = alerts.Union(part); IEnumerable <Alert> actual = alerts; alerts.Merge(part); Assert.Equal(expected, actual); }
public void OnActionExecuted_MergesTempDataAlerts() { Alerts alerts = new Alerts(); alerts.AddError("Test1"); controller.TempData["Alerts"] = JsonSerializer.Serialize(alerts); controller.Alerts.AddError("Test2"); alerts.AddError("Test2"); controller.OnActionExecuted(new ActionExecutedContext(action, new List <IFilterMetadata>(), null)); Object expected = JsonSerializer.Serialize(alerts); Object actual = controller.TempData["Alerts"]; Assert.Equal(expected, actual); }
private Boolean IsActive(String? username) { Boolean isActive = UnitOfWork .Select<Account>() .Any(account => !account.IsLocked && account.Username.ToLower() == (username ?? "").ToLower()); if (!isActive) Alerts.AddError(Validation.For<AccountView>("LockedAccount")); return isActive; }
private Boolean IsValidResetToken(String? token) { Boolean isValid = UnitOfWork .Select<Account>() .Any(account => account.RecoveryToken == token && account.RecoveryTokenExpirationDate > DateTime.Now); if (!isValid) Alerts.AddError(Validation.For<AccountView>("ExpiredToken")); return isValid; }
private Boolean IsActive(String username) { Boolean isActive = UnitOfWork .Select <Account>() .Any(account => !account.IsLocked && account.Username.ToLower() == username.ToLower()); if (!isActive) { Alerts.AddError(Validations.LockedAccount); } return(isActive); }
private Boolean IsValidResetToken(String token) { Boolean isValid = UnitOfWork .Select <Account>() .Any(account => account.RecoveryToken == token && account.RecoveryTokenExpirationDate > DateTime.Now); if (!isValid) { Alerts.AddError(Validations.ExpiredToken); } return(isValid); }
private Boolean IsActive(String username) { Boolean isActive = UnitOfWork .Select <Account>() .Any(account => !account.IsLocked && account.Username == username); if (!isActive) { Alerts.AddError(Validation.For <AccountView>("LockedAccount")); } return(isActive); }
private Boolean IsAuthenticated(String? username, String? password) { String? passhash = UnitOfWork .Select<Account>() .Where(account => account.Username.ToLower() == (username ?? "").ToLower()) .Select(account => account.Passhash) .SingleOrDefault(); Boolean isCorrect = Hasher.VerifyPassword(password, passhash); if (!isCorrect) Alerts.AddError(Validation.For<AccountView>("IncorrectAuthentication")); return isCorrect; }
private Boolean IsAuthenticated(String username, String password) { String passhash = UnitOfWork .Select <Account>() .Where(account => account.Username.ToLower() == username.ToLower()) .Select(account => account.Passhash) .SingleOrDefault(); Boolean isCorrect = Hasher.VerifyPassword(password, passhash); if (!isCorrect) { Alerts.AddError(Validations.IncorrectAuthentication); } return(isCorrect); }