Ejemplo n.º 1
0
        protected ComparerResult CompareObjects(object x, object y, NumericTolerance tolerance)
        {
            var builder = new IntervalBuilder(x);

            builder.Build();
            if (builder.IsValid())
            {
                return(CompareDecimals
                       (
                           builder.GetInterval()
                           , Convert.ToDecimal(y, NumberFormatInfo.InvariantInfo)
                       ));
            }

            builder = new IntervalBuilder(y);
            builder.Build();
            if (builder.IsValid())
            {
                return(CompareDecimals
                       (
                           builder.GetInterval()
                           , Convert.ToDecimal(x, NumberFormatInfo.InvariantInfo)
                       ));
            }

            var rxDecimal = Convert.ToDecimal(x, NumberFormatInfo.InvariantInfo);
            var ryDecimal = Convert.ToDecimal(y, NumberFormatInfo.InvariantInfo);

            return(CompareDecimals(rxDecimal, ryDecimal, tolerance));
        }
Ejemplo n.º 2
0
        protected ComparerResult CompareObjects(object x, object y, NumericTolerance tolerance)
        {
            var builder = new NumericIntervalBuilder(x);

            builder.Build();
            if (builder.IsValid())
            {
                return(CompareDecimals
                       (
                           builder.GetInterval()
                           , converter.Convert(y)
                       ));
            }

            builder = new NumericIntervalBuilder(y);
            builder.Build();
            if (builder.IsValid())
            {
                return(CompareDecimals
                       (
                           builder.GetInterval()
                           , converter.Convert(x)
                       ));
            }

            var rxDecimal = converter.Convert(x);
            var ryDecimal = converter.Convert(y);

            return(CompareDecimals(rxDecimal, ryDecimal, tolerance));
        }
Ejemplo n.º 3
0
 public ResultSetComparisonSettings(KeysChoice keysDef, ValuesChoice valuesDef, NumericTolerance defaultTolerance, ICollection<IColumnDefinition> columnsDef)
 {
     KeysDef = keysDef;
     ValuesDef = valuesDef;
     DefaultTolerance = defaultTolerance;
     if (columnsDef != null)
         ColumnsDef = columnsDef;
     else
         ColumnsDef = new List<IColumnDefinition>(0);
 }
Ejemplo n.º 4
0
        protected ComparerResult CompareDecimals(decimal expected, decimal actual, NumericTolerance tolerance)
        {
            if (tolerance is NumericAbsoluteTolerance)
                return CompareDecimals(expected, actual, (NumericAbsoluteTolerance)tolerance);

            if (tolerance is NumericPercentageTolerance)
                return CompareDecimals(expected, actual, (NumericPercentageTolerance)tolerance);

            throw new ArgumentException();
        }
Ejemplo n.º 5
0
        protected ComparerResult CompareDecimals(decimal expected, decimal actual, NumericTolerance tolerance)
        {
            if (tolerance is NumericAbsoluteTolerance)
            {
                return(CompareDecimals(expected, actual, (NumericAbsoluteTolerance)tolerance));
            }

            if (tolerance is NumericPercentageTolerance)
            {
                return(CompareDecimals(expected, actual, (NumericPercentageTolerance)tolerance));
            }

            throw new ArgumentException();
        }
Ejemplo n.º 6
0
 public ResultSetComparisonSettings(KeysChoice keysDef, ValuesChoice valuesDef, NumericTolerance defaultTolerance)
     : this(keysDef, valuesDef, defaultTolerance, null)
 {
 }
Ejemplo n.º 7
0
        protected ComparerResult CompareObjects(object x, object y, NumericTolerance tolerance)
        {
            var builder = new IntervalBuilder(x);
            builder.Build();
            if (builder.IsValid())
                return CompareDecimals
                    (
                        builder.GetInterval()
                        , Convert.ToDecimal(y, NumberFormatInfo.InvariantInfo)
                    );

            builder = new IntervalBuilder(y);
            builder.Build();
            if (builder.IsValid())
                return CompareDecimals
                    (
                        builder.GetInterval()
                        , Convert.ToDecimal(x, NumberFormatInfo.InvariantInfo)
                    );

            var rxDecimal = Convert.ToDecimal(x, NumberFormatInfo.InvariantInfo);
            var ryDecimal = Convert.ToDecimal(y, NumberFormatInfo.InvariantInfo);

            return CompareDecimals(rxDecimal, ryDecimal, tolerance);
        }
Ejemplo n.º 8
0
        protected ComparerResult CompareObjects(object x, object y, NumericTolerance tolerance)
        {
            var builder = new IntervalBuilder(x);
            builder.Build();
            if (builder.IsValid())
                return CompareDecimals
                    (
                        builder.GetInterval()
                        , converter.Convert(y)
                    );

            builder = new IntervalBuilder(y);
            builder.Build();
            if (builder.IsValid())
                return CompareDecimals
                    (
                        builder.GetInterval()
                        , converter.Convert(x)
                    );

            var rxDecimal = converter.Convert(x);
            var ryDecimal = converter.Convert(y);

            return CompareDecimals(rxDecimal, ryDecimal, tolerance);
        }