Exemplo n.º 1
0
        protected override ComparerResult CompareObjects(object x, object y)
        {
            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)
                       ));
            }

            return(CompareObjects(x, y, new NumericAbsoluteTolerance(0)));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        protected override ComparerResult CompareObjects(object x, object y)
        {
            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)
                       ));
            }

            return(CompareObjects(x, y, NumericAbsoluteTolerance.None));
        }
Exemplo n.º 5
0
        public void ToString_ClosedOpen_ReturnCorrectDisplay()
        {
            var builder = new IntervalBuilder(" [10 ; 200 [");

            builder.Build();
            var interval = builder.GetInterval();

            Assert.That(interval.ToString(), Is.EqualTo("[10;200["));
        }
Exemplo n.º 6
0
        public void Build_OpenClosed_ReturnOpenClosed()
        {
            var builder = new IntervalBuilder(" ] 10 ; 200]");

            builder.Build();
            var interval = builder.GetInterval();

            Assert.That(interval.Left.IsOpen, Is.True);
            Assert.That(interval.Right.IsClosed, Is.True);
        }
Exemplo n.º 7
0
        public void Build_OpenOpen_ReturnBothNotClosed()
        {
            var builder = new IntervalBuilder(" ] 10 ; 200[");

            builder.Build();
            var interval = builder.GetInterval();

            Assert.That(interval.Left.IsClosed, Is.False);
            Assert.That(interval.Right.IsClosed, Is.False);
        }
Exemplo n.º 8
0
        protected override ComparerResult CompareObjects(object x, object y)
        {
            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)
                    );

            return CompareObjects(x, y, new NumericAbsoluteTolerance(0));
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        protected override ComparerResult CompareObjects(object x, object y)
        {
            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)
                    );

            return CompareObjects(x, y, NumericAbsoluteTolerance.None);
        }
Exemplo n.º 11
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);
        }