protected void CheckSettingsAndFirstRow(DataTable dt, SettingsResultSetComparisonByIndex settings) { if (dt.Rows.Count == 0) { return; } var dr = dt.Rows[0]; for (int i = 0; i < dr.Table.Columns.Count; i++) { CheckSettingsFirstRowCell( settings.GetColumnRole(i) , settings.GetColumnType(i) , dr.Table.Columns[i] , dr.IsNull(i) ? DBNull.Value : dr[i] , new string[] { "The column with index '{0}' is expecting a numeric value but the first row of your result set contains a value '{1}' not recognized as a valid numeric value or a valid interval." , " Aren't you trying to use a comma (',' ) as a decimal separator? NBi requires that the decimal separator must be a '.'." , "The column with index '{0}' is expecting a 'date & time' value but the first row of your result set contains a value '{1}' not recognized as a valid date & time value." } ); } }
protected virtual void BuildDefaultSettings(int columnsCount) { Settings = new SettingsResultSetComparisonByIndex( columnsCount, SettingsResultSetComparisonByIndex.KeysChoice.All, SettingsResultSetComparisonByIndex.ValuesChoice.None); }
public void Compare_SameKeysSameValuesUselessColumnsNoneValuesMatching_ReturnEqual() { var settings = new SettingsResultSetComparisonByIndex( SettingsResultSetComparisonByIndex.KeysChoice.First, SettingsResultSetComparisonByIndex.ValuesChoice.None, new List <IColumnDefinition>() { new Column() { Index = 1, Role = ColumnRole.Value, Type = ColumnType.Numeric } } ); //Buiding object used during test var comparer = new ResultSetComparerByIndex(AnalyzersFactory.EqualTo(), settings); var reference = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }, new string[] { "Useless0", "Useless1" }); var actual = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }, new string[] { "0Useless0", "0Useless1" }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultSetCompareResult.Matching)); }
protected void WriteSettingsToDataTableProperties(DataTable dt, SettingsResultSetComparisonByIndex settings) { foreach (DataColumn column in dt.Columns) { WriteSettingsToDataTableProperties( column , settings.GetColumnRole(column.Ordinal) , settings.GetColumnType(column.Ordinal) , null , null ); } }
protected void CheckSettingsAndDataTable(DataTable dt, SettingsResultSetComparisonByIndex settings) { var max = settings.GetMaxColumnIndexDefined(); if (dt.Columns.Count <= max) { var exception = string.Format("You've defined a column with an index of {0}, meaning that your result set would have at least {1} columns but your result set has only {2} columns." , max , max + 1 , dt.Columns.Count); if (dt.Columns.Count == max && settings.GetMinColumnIndexDefined() == 1) { exception += " You've no definition for a column with an index of 0. Are you sure you'vent started to index at 1 in place of 0?"; } throw new ResultSetComparerException(exception); } }