/// <summary> /// Searches for the item that matches the conditions defined by the specified predicate expression /// and returns the zero-based index of the first occurrence. /// </summary> /// <param name="predicateExpression">The predicate expression to test each item.</param> /// <returns>The zero-based index of the first occurrence of item, if found; otherwise, <c>–1</c>.</returns> public DataProvider <int, TOwner> IndexOf(Expression <Func <TItem, bool> > predicateExpression) { predicateExpression.CheckNotNull(nameof(predicateExpression)); string itemName = UIComponentResolver.ResolveControlName <TItem, TOwner>(predicateExpression); return(Component.GetOrCreateDataProvider( $"{ComponentPartName} index of \"{itemName}\" {ItemComponentTypeName}", () => IndexOf(itemName, predicateExpression))); }
/// <summary> /// Gets the control that matches the conditions defined by the specified predicate expression. /// </summary> /// <param name="predicateExpression">The predicate expression to test each item.</param> /// <returns>The first item that matches the conditions of the specified predicate.</returns> public TItem this[Expression <Func <TItem, bool> > predicateExpression] { get { predicateExpression.CheckNotNull(nameof(predicateExpression)); string itemName = UIComponentResolver.ResolveControlName <TItem, TOwner>(predicateExpression); return(GetItem(itemName, predicateExpression)); } }
public static TOwner Contain <TControl, TOwner>(this IDataVerificationProvider <IEnumerable <TControl>, TOwner> should, Expression <Func <TControl, bool> > predicateExpression) where TControl : Control <TOwner> where TOwner : PageObject <TOwner> { predicateExpression.CheckNotNull(nameof(predicateExpression)); var predicate = predicateExpression.Compile(); return(should.Satisfy( actual => actual != null && actual.Any(predicate), $"contain \"{UIComponentResolver.ResolveControlName<TControl, TOwner>(predicateExpression)}\" {UIComponentResolver.ResolveControlTypeName<TControl>()}")); }