Exemple #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));
        }
Exemple #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));
        }
 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);
 }
Exemple #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();
        }
Exemple #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();
        }
 public ResultSetComparisonSettings(KeysChoice keysDef, ValuesChoice valuesDef, NumericTolerance defaultTolerance)
     : this(keysDef, valuesDef, defaultTolerance, null)
 {
 }
Exemple #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);
        }
        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);
        }