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)); }
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)); }
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[")); }
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); }
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); }
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)); }
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)); }
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)); }