예제 #1
0
        protected ComparerResult CompareObjects(object x, object y, NumericTolerance tolerance)
        {
            var builder = new NumericIntervalBuilder(x);

            builder.Build();
            if (builder.IsValid())
            {
                return(CompareDecimals
                       (
                           builder.GetInterval()
                           , caster.Execute(y)
                       ));
            }

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

            var rxDecimal = caster.Execute(x);
            var ryDecimal = caster.Execute(y);

            return(CompareDecimals(rxDecimal, ryDecimal, tolerance));
        }
예제 #2
0
        protected override ComparerResult CompareObjects(object x, object y)
        {
            var builder = new NumericIntervalBuilder(x);

            builder.Build();
            if (builder.IsValid())
            {
                return(CompareDecimals
                       (
                           builder.GetInterval()
                           , caster.Execute(y)
                       ));
            }

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

            return(CompareObjects(x, y, NumericAbsoluteTolerance.None));
        }
예제 #3
0
        public void ToString_ClosedOpen_ReturnCorrectDisplay()
        {
            var builder = new NumericIntervalBuilder(" [10 ; 200 [");

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

            Assert.That(interval.ToString(), Is.EqualTo("[10;200["));
        }
예제 #4
0
        public void Build_OpenClosed_ReturnOpenClosed()
        {
            var builder = new NumericIntervalBuilder(" ] 10 ; 200]");

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

            Assert.That(interval.Left.IsOpen, Is.True);
            Assert.That(interval.Right.IsClosed, Is.True);
        }
예제 #5
0
        public void Build_OpenOpen_ReturnBothNotClosed()
        {
            var builder = new NumericIntervalBuilder(" ] 10 ; 200[");

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

            Assert.That(interval.Left.IsClosed, Is.False);
            Assert.That(interval.Right.IsClosed, Is.False);
        }
예제 #6
0
        protected override bool Apply(object x)
        {
            var builder = new NumericIntervalBuilder(Reference);

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

            var caster = new NumericCaster();
            var numX   = caster.Execute(x);

            return(interval.Contains(numX));
        }
예제 #7
0
        public override bool Apply(object x)
        {
            var builder = new NumericIntervalBuilder(Reference);

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

            var converter = new NumericConverter();
            var numX      = converter.Convert(x);

            return(interval.Contains(numX));
        }
예제 #8
0
        protected override bool ApplyWithReference(object reference, object x)
        {
            var builder = new NumericIntervalBuilder(reference);

            builder.Build();
            if (!builder.IsValid())
            {
                throw builder.GetException();
            }
            var interval = builder.GetInterval();

            var caster = new NumericCaster();
            var numX   = caster.Execute(x);

            return(interval.Contains(numX));
        }