protected override List <Node> FilterNodeList(List <Node> oldNodes) { var newNodes = new List <Node>(); bool encounteredClickable = false; foreach (var node in oldNodes) { if (ElementValidator.IsClickable(node.GetElement())) { if (!encounteredClickable) { encounteredClickable = true; newNodes.Add(node); } } else { newNodes.Add(node); } } return(newNodes); }
public void CanValidateElementByProperties() { var nullFirstNameCollection = TestingDataFactory.ElementValidation.CollectionWithNullFirstNames(); var emptyLastNameCollection = TestingDataFactory.ElementValidation.CollectionWithEmptyLastNames(); var nullElementCollection = TestingDataFactory.ElementValidation.CollectionWithNullElement(); var notNullFirstNameValidator = new ElementValidator<GenericParameter>(); notNullFirstNameValidator.CreatePropertyRule(x => x.FirstName).NotNull(); var notEmptyLastNameValidator = new ElementValidator<GenericParameter>(); notEmptyLastNameValidator.CreatePropertyRule(x => x.LastName).NotEmpty(); var compositePropertiesValidator = new ElementValidator<GenericParameter>(); compositePropertiesValidator.CreatePropertyRule(x => x.FirstName).NotNull(); compositePropertiesValidator.CreatePropertyRule(x => x.LastName).NotEmpty(); Assert.IsTrue(notNullFirstNameValidator.Validate(emptyLastNameCollection).IsValid); Assert.IsTrue(notEmptyLastNameValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(notNullFirstNameValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(notEmptyLastNameValidator.Validate(emptyLastNameCollection).IsValid); Assert.IsTrue(notNullFirstNameValidator.Validate(nullElementCollection).IsValid); Assert.IsTrue(notEmptyLastNameValidator.Validate(nullElementCollection).IsValid); Assert.IsTrue(compositePropertiesValidator.Validate(nullElementCollection).IsValid); Assert.IsFalse(compositePropertiesValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(compositePropertiesValidator.Validate(emptyLastNameCollection).IsValid); }
public override List <ControllerData> FilerData(List <ControllerData> inputData) { var resultList = Clone(inputData); var removableElements = new List <IElement>(); var validTags = ElementValidator.GetAllValidTags(); var validTypes = ElementValidator.GetAllValidTypes(); foreach (var controller in resultList) { foreach (var view in controller.GetViews()) { foreach (var viewElement in view.GetElements()) { if (!ElementValidator.IsInList(viewElement.GetTypeName(), ElementValidator.GetAllValidTypes()) && !ElementValidator.IsInList(viewElement.GetTagName(), ElementValidator.GetAllValidTags())) { removableElements.Add(viewElement); } } foreach (var removableElement in removableElements) { view.RemoveElement(removableElement); } } } return(resultList); }
public void CanValidateElementByProperties() { var nullFirstNameCollection = TestingDataFactory.ElementValidation.CollectionWithNullFirstNames(); var emptyLastNameCollection = TestingDataFactory.ElementValidation.CollectionWithEmptyLastNames(); var nullElementCollection = TestingDataFactory.ElementValidation.CollectionWithNullElement(); var notNullFirstNameValidator = new ElementValidator <GenericParameter>(); notNullFirstNameValidator.CreatePropertyRule(x => x.FirstName).NotNull(); var notEmptyLastNameValidator = new ElementValidator <GenericParameter>(); notEmptyLastNameValidator.CreatePropertyRule(x => x.LastName).NotEmpty(); var compositePropertiesValidator = new ElementValidator <GenericParameter>(); compositePropertiesValidator.CreatePropertyRule(x => x.FirstName).NotNull(); compositePropertiesValidator.CreatePropertyRule(x => x.LastName).NotEmpty(); Assert.IsTrue(notNullFirstNameValidator.Validate(emptyLastNameCollection).IsValid); Assert.IsTrue(notEmptyLastNameValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(notNullFirstNameValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(notEmptyLastNameValidator.Validate(emptyLastNameCollection).IsValid); Assert.IsTrue(notNullFirstNameValidator.Validate(nullElementCollection).IsValid); Assert.IsTrue(notEmptyLastNameValidator.Validate(nullElementCollection).IsValid); Assert.IsTrue(compositePropertiesValidator.Validate(nullElementCollection).IsValid); Assert.IsFalse(compositePropertiesValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(compositePropertiesValidator.Validate(emptyLastNameCollection).IsValid); }
private ScriptGenerator GetScriptGenerator(IElement element) { return(ElementValidator.IsClickable(element) ? (ScriptGenerator) new ClickScriptGenerator() : (ElementValidator.IsInputField(element) ? new InputScriptGenerator() : null)); }
public void Test_Symbols_Must_Be_Two_Letters() { IElementValidator validator = new ElementValidator(); var errorMessages = new List <string>(); validator.ValidateNumLetters(errorMessages, _elements.FirstOrDefault()); Assert.IsTrue(errorMessages.FirstOrDefault() == ConstantStrings.ALL_CHEM_SYMB_2_LETTERS); }
public void Test_Proper_Symbol_Syntax_Passes() { IElementValidator validator = new ElementValidator(); var errorMessages = new List <string>(); validator.ValidateNumLetters(errorMessages, _elements[1]); Assert.IsTrue(errorMessages.FirstOrDefault() == null); }
public void Test_First_Letter_Capital() { IElementValidator validator = new ElementValidator(); var errorMessages = new List <string>(); validator.ValidateFirstLetterCapitalised(errorMessages, _elements.LastOrDefault()); Assert.IsTrue(errorMessages.FirstOrDefault() == ConstantStrings.FIRST_LETTER_CAP); }
public void Test_Same_Letters_Apear_Twice_In_Element_Name() { IElementValidator validator = new ElementValidator(); var errorMessages = new List <string>(); validator.ValidateTwoLettersApearTwice(errorMessages, _elements.FirstOrDefault(x => x.Symbol == "Tt")); Assert.IsTrue(errorMessages.FirstOrDefault() == ConstantStrings.LETTERS_APEAR_TWICE); }
public void Test_Both_Letters_Apear_In_Element_Name() { IElementValidator validator = new ElementValidator(); var errorMessages = new List <string>(); validator.ValidateBothLettersApear(errorMessages, _elements.FirstOrDefault(x => x.ElementName == "Tullium")); Assert.IsTrue(errorMessages.FirstOrDefault() == ConstantStrings.BOTH_CHEM_SYMB_MUST_APPEAR); }
public void Test_Both_Letters_Apear_In_Correct_Order() { IElementValidator validator = new ElementValidator(); var errorMessages = new List <string>(); validator.ValidateTwoLettersApearInOrder(errorMessages, _elements.FirstOrDefault(x => x.ElementName == "Stantzon")); Assert.IsTrue(errorMessages.FirstOrDefault() == ConstantStrings.TWO_LETTERS_IN_ORDER); }
public void CanValidateElement() { var validCollection = TestingDataFactory.ElementValidation.SimpleRange(3, 5); var invalidCollection = TestingDataFactory.ElementValidation.SimpleRange(1, 6); var validator = new ElementValidator<int>(); validator.CreateRule().LessThan(6).GreaterThan(2); Assert.IsTrue(validator.Validate(validCollection).IsValid); Assert.IsFalse(validator.Validate(invalidCollection).IsValid); }
public void CanSetErrorMessage() { var invalidCollection = TestingDataFactory.ElementValidation.SimpleRange(1, 6); var validator = new ElementValidator <int>(); validator.CreateRule().LessThan(6).GreaterThan(2); validator.SetErrorMessage(ErrorMessageText); var result = validator.Validate(invalidCollection); Assert.AreEqual(result.First().ErrorMessage, ErrorMessageText); }
public void CanValidateElement() { var validCollection = TestingDataFactory.ElementValidation.SimpleRange(3, 5); var invalidCollection = TestingDataFactory.ElementValidation.SimpleRange(1, 6); var validator = new ElementValidator <int>(); validator.CreateRule().LessThan(6).GreaterThan(2); Assert.IsTrue(validator.Validate(validCollection).IsValid); Assert.IsFalse(validator.Validate(invalidCollection).IsValid); }
public void Index() { IElementValidator validator = new ElementValidator(); // Arrange HomeController controller = new HomeController(validator); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result); }
public List <IElement> GetInputElements(List <IElement> elements) { var resultList = new List <IElement>(); foreach (var element in elements) { if (ElementValidator.IsInputField(element)) { resultList.Add(element); } } return(resultList); }
private List <IElement> GetClickableElements(List <IElement> elements) { var resultList = new List <IElement>(); foreach (var element in elements) { if (ElementValidator.IsClickable(element)) { resultList.Add(element); } } return(resultList); }
protected override List <Node> FilterNodeList(List <Node> oldNodes) { var newNodes = new List <Node>(); foreach (var node in oldNodes) { newNodes.Add(node); if (ElementValidator.IsClickable(node.GetElement())) { break; } } return(newNodes); }
public void CanUseElementAndFluentValidation() { var nullFirstNameCollection = TestingDataFactory.ElementValidation.CollectionWithNullFirstNames(); var emptyLastNameCollection = TestingDataFactory.ElementValidation.CollectionWithEmptyLastNames(); var nullElementCollection = TestingDataFactory.ElementValidation.CollectionWithNullElement(); var compositeValidator = new ElementValidator <GenericParameter>(); compositeValidator.AddValidator(new InlineValidator <GenericParameter> { v => v.RuleFor(x => x.LastName).NotEmpty() }); compositeValidator.CreateRule().NotNull(); Assert.IsTrue(compositeValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(compositeValidator.Validate(emptyLastNameCollection).IsValid); Assert.IsFalse(compositeValidator.Validate(nullElementCollection).IsValid); }
public void CanUseFluentValidation() { var nullFirstNameCollection = TestingDataFactory.ElementValidation.CollectionWithNullFirstNames(); var emptyLastNameCollection = TestingDataFactory.ElementValidation.CollectionWithEmptyLastNames(); var nullElementCollection = TestingDataFactory.ElementValidation.CollectionWithNullElement(); var notNullFirstNameValidator = new ElementValidator<GenericParameter>(); notNullFirstNameValidator.AddValidator(new InlineValidator<GenericParameter> { v => v.RuleFor(x => x.FirstName).NotNull() }); var notEmptyLastNameValidator = new ElementValidator<GenericParameter>(); notEmptyLastNameValidator.AddValidator(new InlineValidator<GenericParameter> { v => v.RuleFor(x => x.LastName).NotEmpty() }); var compositePropertiesValidator = new ElementValidator<GenericParameter>(); compositePropertiesValidator.AddValidator(new InlineValidator<GenericParameter> { v => v.RuleFor(x => x.FirstName).NotNull() }); compositePropertiesValidator.AddValidator(new InlineValidator<GenericParameter> { v => v.RuleFor(x => x.LastName).NotEmpty() }); Assert.IsTrue(notNullFirstNameValidator.Validate(emptyLastNameCollection).IsValid); Assert.IsTrue(notEmptyLastNameValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(notNullFirstNameValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(notEmptyLastNameValidator.Validate(emptyLastNameCollection).IsValid); Assert.IsTrue(notNullFirstNameValidator.Validate(nullElementCollection).IsValid); Assert.IsTrue(notEmptyLastNameValidator.Validate(nullElementCollection).IsValid); Assert.IsTrue(compositePropertiesValidator.Validate(nullElementCollection).IsValid); Assert.IsFalse(compositePropertiesValidator.Validate(nullFirstNameCollection).IsValid); Assert.IsFalse(compositePropertiesValidator.Validate(emptyLastNameCollection).IsValid); }
public WebElement(WebDriver driver, SearchStrategies strategy, string strategyValue) : base(driver, strategy, strategyValue) { elementWaiter = new ElementWaiter(this); elementValidator = new ElementValidator(this); elementInteracting = new ElementInteracting(this); }
public CollectionValidator() { this.elementValidator = new ElementValidator <T>(); this.validators.Add(this.elementValidator); }
public void CanSetErrorMessage() { var invalidCollection = TestingDataFactory.ElementValidation.SimpleRange(1, 6); var validator = new ElementValidator<int>(); validator.CreateRule().LessThan(6).GreaterThan(2); validator.SetErrorMessage(ErrorMessageText); var result = validator.Validate(invalidCollection); Assert.AreEqual(result.First().ErrorMessage, ErrorMessageText); }