Esempio n. 1
0
        /// <summary>
        /// Validates the list row count.
        /// </summary>
        /// <param name="comparisonType">Type of the comparison.</param>
        /// <param name="expectedRowCount">The expected row count.</param>
        /// <returns>A tuple indicating if the results were successful and the actual row count.</returns>
        public override Tuple <bool, int> ValidateListRowCount(NumericComparisonType comparisonType, int expectedRowCount)
        {
            var actualRowCount = 0;
            var isValid        = this.action(this.ElementHandler,
                                             e =>
            {
                var rowCount   = ((IEnumerable <TElement>)e).Count();
                actualRowCount = rowCount;

                switch (comparisonType)
                {
                case NumericComparisonType.Equals:
                    return(rowCount == expectedRowCount);

                case NumericComparisonType.GreaterThanEquals:
                    return(rowCount >= expectedRowCount);

                case NumericComparisonType.LessThanEquals:
                    return(rowCount <= expectedRowCount);

                default:
                    return(false);
                }
            });

            return(new Tuple <bool, int>(isValid, actualRowCount));
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidateListRowCountContext" /> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="compareType">Type of the compare.</param>
 /// <param name="rowCount">The row count.</param>
 public ValidateListRowCountContext(string propertyName, NumericComparisonType compareType, int rowCount)
     : base(propertyName)
 {
     this.CompareType = compareType;
     this.RowCount    = rowCount;
 }
Esempio n. 3
0
 /// <summary>
 /// Validates the list row count.
 /// </summary>
 /// <param name="comparisonType">Type of the comparison.</param>
 /// <param name="expectedRowCount">The expected row count.</param>
 /// <returns>A tuple indicating if the results were successful and the actual row count.</returns>
 public virtual Tuple <bool, int> ValidateListRowCount(NumericComparisonType comparisonType, int expectedRowCount)
 {
     throw this.CreateNotSupportedException("Validating a list row count");
 }
Esempio n. 4
0
 /// <summary>
 /// Constructs a new access policy condition that compares two numbers.
 /// </summary>
 /// <param name="type">The type of comparison to perform.</param>
 /// <param name="key">The access policy condition key specifying where to get the
 ///           first number for the comparison.</param>
 /// <param name="value">The second number to compare against.</param>
 public static Condition NewCondition(NumericComparisonType type, string key, string value)
 {
     return(new Condition(type.ToString(), key, value));
 }
Esempio n. 5
0
 /// <summary>
 /// Constructs a new access policy condition that compares two numbers.
 /// </summary>
 /// <param name="type">The type of comparison to perform.</param>
 /// <param name="key">The access policy condition key specifying where to get the
 ///           first number for the comparison.</param>
 /// <param name="value">The second number to compare against.</param>
 public static Condition NewCondition(NumericComparisonType type, string key, string value)
 {
     return new Condition(type.ToString(), key, value);
 }