/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { int counter = ((int?)context.GetData(this)).GetValueOrDefault(); context.SetData(this, counter + 1); return(counter == index); }
public override bool Compare(IAttributeBag attributeBag) { ElementAttributeBag elementAttributeBag = (ElementAttributeBag)attributeBag; IHTMLElement element = elementAttributeBag.IHTMLElement; if (IsTextContainedIn(element.innerText)) { // Get all elements and filter this for TableCells IHTMLTableRow tableRowElement = (IHTMLTableRow)element; IHTMLElementCollection tableCellElements = tableRowElement.cells; if (tableCellElements.length - 1 >= columnIndex) { IHTMLTableCell tableCell = (IHTMLTableCell)tableCellElements.item(columnIndex, null); ICompareElement elementComparer = comparer as ICompareElement; if (elementComparer != null) { return(elementComparer.Compare(new TableCell(elementAttributeBag.DomContainer, tableCell))); } return(base.Compare(new ElementAttributeBag(elementAttributeBag.DomContainer, (IHTMLElement)tableCell))); } } return(false); }
protected override bool DoCompare(IAttributeBag attributeBag) { bool resultOr; bool resultAnd = false; resultOr = false; if (_andBaseConstraint != null) { resultAnd = _andBaseConstraint.Compare(attributeBag); } if (resultAnd || _andBaseConstraint == null) { counter++; } if (_orBaseConstraint != null && resultAnd == false) { resultOr = _orBaseConstraint.Compare(attributeBag); } return((counter == index) || resultOr); }
public override bool Compare(IAttributeBag attributeBag) { base.LockCompare(); bool resultOr; try { bool resultAnd = false; resultOr = false; if (andAttribute != null) { resultAnd = andAttribute.Compare(attributeBag); } if (resultAnd || andAttribute == null) { counter++; } if (orAttribute != null && resultAnd == false) { resultOr = orAttribute.Compare(attributeBag); } } finally { base.UnLockCompare(); } return((counter == index) || resultOr); }
public override bool Compare(IAttributeBag attributeBag) { ElementAttributeBag elementAttributeBag = (ElementAttributeBag) attributeBag; IHTMLElement element = elementAttributeBag.IHTMLElement; if (IsTextContainedIn(element.innerText)) { // Get all elements and filter this for TableCells IHTMLTableRow tableRowElement = (IHTMLTableRow)element; IHTMLElementCollection tableCellElements = tableRowElement.cells; if (tableCellElements.length - 1 >= columnIndex) { IHTMLTableCell tableCell = (IHTMLTableCell)tableCellElements.item(columnIndex, null); ICompareElement elementComparer = comparer as ICompareElement; if (elementComparer != null) { return elementComparer.Compare(new TableCell(elementAttributeBag.DomContainer, tableCell)); } return base.Compare(new ElementAttributeBag(elementAttributeBag.DomContainer, (IHTMLElement) tableCell)); } } return false; }
protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { var regex = _ignoreCase ? new Regex(_regexAsString, RegexOptions.IgnoreCase) : new Regex(_regexAsString); var constraint = _constraintFactory.Invoke(regex); return(constraint.Matches(attributeBag, context)); }
/// <inheritdoc /> public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { Element element = attributeBag.GetAdapter<Element>(); if (element == null) throw new WatiNException("This constraint class can only be used to compare against an element"); return comparer.Compare(element); }
/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { Component component = attributeBag.GetAdapter<Component>(); if (component == null) throw new WatiNException("This constraint class can only be used to compare against a component"); return comparer.Compare(component); }
/// <inheritdoc /> public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { Component component = attributeBag.GetAdapter <Component>(); if (component == null) { throw new WatiNException("This constraint class can only be used to compare against a component"); } return(comparer.Compare(component)); }
/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { T value = attributeBag.GetAdapter <T>(); if (value == null) { throw new WatiNException(string.Format("This constraint class can only be used to compare against values adaptable to {0}.", typeof(T))); } return(predicate(value)); }
protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { string classValue = attributeBag.GetAttributeValue("class"); if (classValue == null) classValue = attributeBag.GetAttributeValue("ClassName"); if (classValue == null) return false; return _comparer.Compare(classValue); }
/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { var element = attributeBag.GetAdapter<Element>(); if (element == null) throw new WatiNException("This constraint class can only be used to compare against an element"); var cache = (LabelCache)context.GetData(this); if (cache == null) { cache = new LabelCache(labelText); context.SetData(this, cache); } return cache.IsMatch(element); }
protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { string classValue = attributeBag.GetAttributeValue("class"); if (classValue == null) { classValue = attributeBag.GetAttributeValue("ClassName"); } if (classValue == null) { return(false); } return(_comparer.Compare(classValue)); }
/// <summary> /// This methode implements an exact match comparison. If you want /// different behaviour, inherit this class or one of its subclasses and /// override Compare with a specific implementation. /// <seealso cref="LockCompare"/> /// <seealso cref="UnLockCompare"/> /// </summary> /// <param name="attributeBag">Value to compare with</param> /// <returns><c>true</c> if the searched for value equals the given value</returns> /// <example> /// The following example shows the use of the LockCompare and UnlockCompare methods. /// <code> /// public override bool Compare(IAttributeBag attributeBag) /// { /// bool result = false; /// /// // Call LockCompare if you don't call base.compare. /// base.LockCompare(); /// /// try /// { /// // Your compare code goes here. /// /// // Don't call base.compare here because that will throw /// // a ReEntryException since you already locked the compare /// // method for recursive calls. /// } /// finally /// { /// // Call UnLockCompare if you called LockCompare. /// base.UnLockCompare(); /// } /// /// return result; /// } /// </code> /// </example> public virtual bool Compare(IAttributeBag attributeBag) { LockCompare(); bool returnValue; try { returnValue = DoCompare(attributeBag); } finally { UnLockCompare(); } return(returnValue); }
/// <summary> /// Evaluates the and or attributes. /// </summary> /// <param name="attributeBag">The attribute bag.</param> /// <param name="initialReturnValue">if set to <c>false</c> it will skip the And evaluation.</param> /// <returns></returns> protected bool EvaluateAndOrAttributes(IAttributeBag attributeBag, bool initialReturnValue) { bool returnValue = initialReturnValue; if (returnValue && andAttribute != null) { returnValue = andAttribute.Compare(attributeBag); } if (returnValue == false && orAttribute != null) { returnValue = orAttribute.Compare(attributeBag); } return(returnValue); }
/// <summary> /// Evaluates the and or attributes. /// </summary> /// <param name="attributeBag">The attribute bag.</param> /// <param name="initialReturnValue">if set to <c>false</c> it will skip the And evaluation.</param> /// <returns></returns> protected bool EvaluateAndOrAttributes(IAttributeBag attributeBag, bool initialReturnValue) { bool returnValue = initialReturnValue; if (returnValue && _andBaseConstraint != null) { returnValue = _andBaseConstraint.Compare(attributeBag); } if (returnValue == false && _orBaseConstraint != null) { returnValue = _orBaseConstraint.Compare(attributeBag); } return(returnValue); }
/// <summary> /// Returns true if the constraint matches an object described by an attribute bag. /// </summary> /// <param name="attributeBag">The attribute bag</param> /// <param name="context">The constraint matching context</param> /// <returns>True if the constraint matches</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="attributeBag"/> or <paramref name="context"/> is null</exception> public bool Matches(IAttributeBag attributeBag, ConstraintContext context) { if (attributeBag == null) throw new ArgumentNullException("attributeBag"); if (context == null) throw new ArgumentNullException("context"); try { EnterMatch(); return MatchesImpl(attributeBag, context); } finally { ExitMatch(); } }
public override bool Compare(IAttributeBag attributeBag) { bool result; LockCompare(); try { result = !(attribute.Compare(attributeBag)); } finally { UnLockCompare(); } return(result); }
/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { var element = attributeBag.GetAdapter <Element>(); if (element == null) { throw new WatiNException("This constraint class can only be used to compare against an element"); } var cache = (LabelCache)context.GetData(this); if (cache == null) { cache = new LabelCache(labelText); context.SetData(this, cache); } return(cache.IsMatch(element)); }
/// <summary> /// Returns true if the constraint matches an object described by an attribute bag. /// </summary> /// <param name="attributeBag">The attribute bag</param> /// <param name="context">The constraint matching context</param> /// <returns>True if the constraint matches</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="attributeBag"/> or <paramref name="context"/> is null</exception> public bool Matches(IAttributeBag attributeBag, ConstraintContext context) { if (attributeBag == null) { throw new ArgumentNullException("attributeBag"); } if (context == null) { throw new ArgumentNullException("context"); } try { EnterMatch(); return(MatchesImpl(attributeBag, context)); } finally { ExitMatch(); } }
protected override bool DoCompare(IAttributeBag attributeBag) { Element element = null; ElementAttributeBag elementAttributeBag = attributeBag as ElementAttributeBag; if (elementAttributeBag != null) { element = elementAttributeBag.ElementTyped; } if (element == null) { element = attributeBag as Element; } if (element != null) { return EvaluateAndOrAttributes(attributeBag, _comparer.Compare(element)); } throw new Exceptions.WatiNException("This constraint class can only be used to compare against an element"); }
protected override bool DoCompare(IAttributeBag attributeBag) { Element element = null; ElementAttributeBag elementAttributeBag = attributeBag as ElementAttributeBag; if (elementAttributeBag != null) { element = elementAttributeBag.ElementTyped; } if (element == null) { element = attributeBag as Element; } if (element != null) { return(EvaluateAndOrAttributes(attributeBag, _comparer.Compare(element))); } throw new Exceptions.WatiNException("This constraint class can only be used to compare against an element"); }
/// <inheritdoc /> public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { var typeToConvertTo = typeof(T); if (typeToConvertTo.IsSubclassOf(typeof(Control))) { if (attributeBag.GetType().IsSubclassOf(typeof(Element))) { T control = Control.CreateControl(typeToConvertTo, (Element)attributeBag) as T; return(predicate(control)); } } else { T value = attributeBag.GetAdapter <T>(); if (value == null) { throw new WatiNException(string.Format("The PredicateConstraint class can only be used to compare against values adaptable to {0}.", typeToConvertTo)); } return(predicate(value)); } return(false); }
protected override bool DoCompare(IAttributeBag attributeBag) { bool resultOr; bool resultAnd = false; resultOr = false; if (_andBaseConstraint != null) { resultAnd = _andBaseConstraint.Compare(attributeBag); } if (resultAnd || _andBaseConstraint == null) { counter++; } if (_orBaseConstraint != null && resultAnd == false) { resultOr = _orBaseConstraint.Compare(attributeBag); } return (counter == index) || resultOr; }
/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return first.Matches(attributeBag, context) && second.Matches(attributeBag, context); }
/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return(false); }
/// <inheritdoc /> public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { var attributeValue = attributeBag.GetAttributeValue(attributeName); return comparer.Compare(attributeValue); }
/// <summary> /// Returns true if the constraint matches an object described by an attribute bag. /// </summary> /// <param name="attributeBag">The attribute bag, not null</param> /// <param name="context">The constraint matching context, not null</param> /// <returns>True if the constraint matches</returns> protected abstract bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context);
/// <summary> /// This methode implements an exact match comparison. If you want /// different behaviour, inherit this class or one of its subclasses and /// override Compare with a specific implementation. /// <seealso cref="LockCompare"/> /// <seealso cref="UnLockCompare"/> /// </summary> /// <param name="attributeBag">Value to compare with</param> /// <returns><c>true</c> if the searched for value equals the given value</returns> /// <example> /// The following example shows the use of the LockCompare and UnlockCompare methods. /// <code> /// public override bool Compare(IAttributeBag attributeBag) /// { /// bool result = false; /// /// // Call LockCompare if you don't call base.compare. /// base.LockCompare(); /// /// try /// { /// // Your compare code goes here. /// /// // Don't call base.compare here because that will throw /// // a ReEntryException since you already locked the compare /// // method for recursive calls. /// } /// finally /// { /// // Call UnLockCompare if you called LockCompare. /// base.UnLockCompare(); /// } /// /// return result; /// } /// </code> /// </example> public virtual bool Compare(IAttributeBag attributeBag) { LockCompare(); bool returnValue; try { returnValue = DoCompare(attributeBag); } finally { UnLockCompare(); } return returnValue; }
/// <summary> /// Does the compare without calling <see cref="BaseConstraint.LockCompare"/> and <see cref="BaseConstraint.UnLockCompare"/>. /// </summary> /// <param name="attributeBag">The attribute bag.</param> protected abstract bool DoCompare(IAttributeBag attributeBag);
public override bool Compare(IAttributeBag attributeBag) { bool result; LockCompare(); try { result = !(attribute.Compare(attributeBag)); } finally { UnLockCompare(); } return result; }
/// <inheritdoc /> public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return first.Matches(attributeBag, context) || second.Matches(attributeBag, context); }
/// <summary> /// Does the compare without calling <see cref="BaseConstraint.LockCompare"/> and <see cref="BaseConstraint.UnLockCompare"/>. /// </summary> /// <param name="attributeBag">The attribute bag.</param> protected override bool DoCompare(IAttributeBag attributeBag) { return(EvaluateAndOrAttributes(attributeBag, comparer.Compare(attributeBag.GetValue(attributeName)))); }
/// <inheritdoc /> public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { int counter = ((int?)context.GetData(this)).GetValueOrDefault(); context.SetData(this, counter + 1); return counter == index; }
/// <inheritdoc /> public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return(first.Matches(attributeBag, context) && second.Matches(attributeBag, context)); }
/// <summary> /// Does the compare without calling <see cref="BaseConstraint.LockCompare"/> and <see cref="BaseConstraint.UnLockCompare"/>. /// </summary> /// <param name="attributeBag">The attribute bag.</param> /// <returns>Will always return <c>true</c></returns> protected override bool DoCompare(IAttributeBag attributeBag) { return(true); }
/// <summary> /// Evaluates the and or attributes. /// </summary> /// <param name="attributeBag">The attribute bag.</param> /// <param name="initialReturnValue">if set to <c>false</c> it will skip the And evaluation.</param> /// <returns></returns> protected bool EvaluateAndOrAttributes(IAttributeBag attributeBag, bool initialReturnValue) { bool returnValue = initialReturnValue; if (returnValue && andAttribute != null) { returnValue = andAttribute.Compare(attributeBag); } if (returnValue == false && orAttribute != null) { returnValue = orAttribute.Compare(attributeBag); } return returnValue; }
/// <summary> /// Does the compare without calling <see cref="BaseConstraint.LockCompare"/> and <see cref="BaseConstraint.UnLockCompare"/>. /// </summary> /// <param name="attributeBag">The attribute bag.</param> protected override bool DoCompare(IAttributeBag attributeBag) { return !(_baseConstraint.Compare(attributeBag)); }
/// <inheritdoc /> public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { var attributeValue = attributeBag.GetAttributeValue(attributeName); return(comparer.Compare(attributeValue)); }
/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return(first.Matches(attributeBag, context) || second.Matches(attributeBag, context)); }
protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return true; }
/// <summary> /// Evaluates the and or attributes. /// </summary> /// <param name="attributeBag">The attribute bag.</param> /// <param name="initialReturnValue">if set to <c>false</c> it will skip the And evaluation.</param> /// <returns></returns> protected bool EvaluateAndOrAttributes(IAttributeBag attributeBag, bool initialReturnValue) { bool returnValue = initialReturnValue; if (returnValue && _andBaseConstraint != null) { returnValue = _andBaseConstraint.Compare(attributeBag); } if (returnValue == false && _orBaseConstraint != null) { returnValue = _orBaseConstraint.Compare(attributeBag); } return returnValue; }
protected bool doCompare(IAttributeBag attributeBag) { return DoCompare(attributeBag); }
public override bool Compare(IAttributeBag attributeBag) { base.LockCompare(); bool resultOr; try { bool resultAnd = false; resultOr = false; if (andAttribute != null) { resultAnd = andAttribute.Compare(attributeBag); } if (resultAnd || andAttribute == null) { counter++; } if (orAttribute != null && resultAnd == false) { resultOr = orAttribute.Compare(attributeBag); } } finally { base.UnLockCompare(); } return (counter == index) || resultOr; }
/// <summary> /// Returns true if the constraint matches an object described by an attribute bag. /// </summary> /// <param name="attributeBag">The attribute bag, not null</param> /// <param name="context">The constraint matching context, not null</param> /// <returns>True if the constraint matches</returns> public abstract bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context);
public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return(ActualConstraint.MatchesImpl(attributeBag, context)); }
/// <summary> /// Does the compare without calling <see cref="BaseConstraint.LockCompare"/> and <see cref="BaseConstraint.UnLockCompare"/>. /// </summary> /// <param name="attributeBag">The attribute bag.</param> /// <returns>Will always return <c>true</c></returns> protected override bool DoCompare(IAttributeBag attributeBag) { return true; }
protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { var element = attributeBag.GetAdapter<Element>(); return element != null && Comparer.Compare(IsVisible(element).ToString()); }
protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { var element = attributeBag.GetAdapter <Element>(); return(element != null && Comparer.Compare(IsVisible(element).ToString())); }
/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return ! inner.Matches(attributeBag, context); }
public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return ActualConstraint.MatchesImpl(attributeBag, context); }
public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return(true); }
/// <summary> /// Does the compare without calling <see cref="BaseConstraint.LockCompare"/> and <see cref="BaseConstraint.UnLockCompare"/>. /// </summary> /// <param name="attributeBag">The attribute bag.</param> protected override bool DoCompare(IAttributeBag attributeBag) { return EvaluateAndOrAttributes(attributeBag, comparer.Compare(attributeBag.GetValue(attributeName))); }
/// <inheritdoc /> protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return(!inner.Matches(attributeBag, context)); }
/// <inheritdoc /> public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context) { return false; }
protected bool doCompare(IAttributeBag attributeBag) { return(DoCompare(attributeBag)); }
/// <summary> /// Does the compare without calling <see cref="LockCompare"/> and <see cref="UnLockCompare"/>. /// </summary> /// <param name="attributeBag">The attribute bag.</param> protected virtual bool doCompare(IAttributeBag attributeBag) { return EvaluateAndOrAttributes(attributeBag, comparer.Compare(attributeBag.GetValue(attributeName))); }