Exemplo n.º 1
0
        public void Compare_SameKeysSameValuesUselessColumnsNoneValuesMatching_ReturnEqual()
        {
            var settings = new SettingsIndexResultSet(
                SettingsIndexResultSet.KeysChoice.First,
                SettingsIndexResultSet.ValuesChoice.None,
                new List <IColumnDefinition>()
            {
                new Column()
                {
                    Index = 1, Role = ColumnRole.Value, Type = ColumnType.Numeric
                }
            }
                );

            //Buiding object used during test
            var comparer  = new IndexEquivaler(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(ResultResultSet.Matching));
        }
Exemplo n.º 2
0
        protected void CheckSettingsAndFirstRow(DataTable dt, SettingsIndexResultSet 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."
                }
                    );
            }
        }
Exemplo n.º 3
0
 protected void WriteSettingsToDataTableProperties(DataTable dt, SettingsIndexResultSet settings)
 {
     foreach (DataColumn column in dt.Columns)
     {
         WriteSettingsToDataTableProperties(
             column
             , settings.GetColumnRole(column.Ordinal)
             , settings.GetColumnType(column.Ordinal)
             , settings.GetTolerance(column.Ordinal)
             , settings.GetRounding(column.Ordinal)
             );
     }
 }
Exemplo n.º 4
0
        protected void CheckSettingsAndDataTable(DataTable dt, SettingsIndexResultSet 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 EquivalerException(exception);
            }
        }
Exemplo n.º 5
0
 public IndexEquivaler(IEnumerable <IRowsAnalyzer> analyzers, SettingsIndexResultSet settings)
     : base(analyzers)
 {
     base.Settings = settings;
 }
Exemplo n.º 6
0
 public IndexEvaluator(SettingsIndexResultSet settings)
     : base(settings)
 {
 }