public void TestSetup() { App.DottedCircle = "0"; App.DottedCircleC = '0'; App.DiacriticPlaceholder = "[0]"; _validator = new AndGroupValidator(_prj); }
/// ------------------------------------------------------------------------------------ public bool GetIsValid(SearchQuery query) { try { Errors.Clear(); VerifyMatchingSymbolPairs(query.Pattern); var pattern = query.SearchItem + "/" + query.PrecedingEnvironment + "_" + query.FollowingEnvironment; if (!VerifyGeneralPatternStructure(pattern)) { var error = new SearchQueryValidationError(GetPatternSyntaxErrorMsg()); Errors.Add(error); } VerifySearchItem(query.SearchItem); VerifyPrecedingEnvironment(query.PrecedingEnvironment); VerifyFollowingEnvironment(query.FollowingEnvironment); VerifyPhonesAndSymbols(query); foreach (var item in new[] { query.SearchItem, query.PrecedingEnvironment, query.FollowingEnvironment }) { VerifyTextInSquareBrackets(item); VerifyTextInAngleBrackets(item); VerifyDiacriticPlaceholders(item); VerifyOneDiacriticPlaceholderPerAndGroup(item); VerifyNoEmptyTextBetweenOpenAndCloseSymbols(item, PatternParser.FindInnerMostSquareBracketPairs, string.Format(LocalizationManager.GetString("PhoneticSearchingMessages.EmptySquareBracketsMsg", "The pattern '{0}' contains at least one set of empty square brackets."), item)); VerifyNoEmptyTextBetweenOpenAndCloseSymbols(item, PatternParser.FindInnerMostBracesPair, string.Format(LocalizationManager.GetString("PhoneticSearchingMessages.EmptyBracesMsg", "The pattern '{0}' contains at least one set of empty braces."), item)); VerifyNoEmptyTextBetweenOpenAndCloseSymbols(item, PatternParser.FindInnerAngleBracketPairs, string.Format(LocalizationManager.GetString("PhoneticSearchingMessages.EmptyAngleBracketsMsg", "The pattern '{0}' contains at least one set of empty angle brackets."), item)); VerifyMatchingSymbolPairs(item); ValidateOrGroups(item); var andGroupValidator = new AndGroupValidator(_project); andGroupValidator.Verify(item); if (andGroupValidator.HasErrors) { Errors.AddRange(andGroupValidator.Errors); } } } catch (Exception e) { Errors.Add(SearchQueryValidationError.MakeErrorFromException(e, query.Pattern)); } query.Errors.AddRange(Errors); return(!HasErrors); }