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