Exemple #1
0
        /// <summary>Execute cell comparisons for a data row</summary>
        /// <param name="row">the index of the row to be compared</param>
        /// <returns>the list of cell comparisons that didn't pass (empty list if all passed)</returns>
        private List <CellComparison> RowErrors(int row)
        {
            var currentRow = row < ExpectedTable.RowCount
                ? ExpectedTable.DataCell(row, 0)
                : ActualTable.DataCell(row, 0);
            var result     = new List <CellComparison>();
            var maxColumns = Math.Max(ExpectedTable.Row(row).Length, ActualTable.Row(row).Length);

            for (var column = 0; column < maxColumns; column++)
            {
                var currentColumn = ExpectedTable.Header(column);
                var expectedValue = ExpectedTable.DataCell(row, column);
                var actualValue   = ActualTable.DataCell(row, column);
                // reset tolerance range to force recalculating per comparison
                _tolerance.DataRange = null;
                var comparison = new CellComparison(
                    row, currentRow, column, currentColumn, expectedValue, actualValue, _tolerance
                    );
                if (!comparison.Cell.IsOk())
                {
                    result.Add(comparison);
                }
            }
            return(result);
        }
        /// <summary>
        /// Check if number is valid
        /// </summary>
        /// <param name="number">Number as string</param>
        /// <returns>Return true if data is valid</returns>
        public bool IsValidNumber(string number)
        {
            foreach (char item in number.ToUpper())
            {
                if (!ActualTable.Contains(item.ToString()))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #3
0
        /// <summary>Execute cell comparison for the header row</summary>
        /// <returns>the list of cell comparisons that didn't pass (empty list if all passed)</returns>
        private List <CellComparison> HeaderErrors()
        {
            const int headerRowNo = -1;
            var       maxColumns  = Math.Max(ExpectedTable.ColumnCount, ActualTable.ColumnCount);
            var       result      = new List <CellComparison>();
            var       rowName     = ExpectedTable.Header(0);

            for (var column = 0; column < maxColumns; column++)
            {
                var columnName = ExpectedTable.Header(column);
                var comparison = new CellComparison(
                    headerRowNo, rowName, column, columnName, columnName, ActualTable.Header(column), _tolerance
                    );
                if (!comparison.Cell.IsOk())
                {
                    result.Add(comparison);
                }
            }
            return(result);
        }