public static Tolerance Instantiate(ColumnType type, string value) { if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value)) { return(null); } Tolerance tolerance = null; switch (type) { case ColumnType.Text: tolerance = new TextToleranceFactory().Instantiate(value); break; case ColumnType.Numeric: tolerance = new NumericToleranceFactory().Instantiate(value); break; case ColumnType.DateTime: tolerance = new DateTimeToleranceFactory().Instantiate(value); break; case ColumnType.Boolean: break; default: break; } return(tolerance); }
public static Tolerance Instantiate(ColumnType type, string value) { Tolerance tolerance = null; switch (type) { case ColumnType.Text: break; case ColumnType.Numeric: tolerance = new NumericToleranceFactory().Instantiate(value); break; case ColumnType.DateTime: tolerance = new DateTimeToleranceFactory().Instantiate(value); break; case ColumnType.Boolean: break; default: break; } return(tolerance); }
public void Instantiate_Absolute_Value() { var value = "50000"; var tolerance = new NumericToleranceFactory().Instantiate(value); Assert.That(tolerance, Is.TypeOf<NumericAbsoluteTolerance>()); Assert.That(tolerance.Value, Is.EqualTo(50000)); Assert.That(tolerance.ValueString, Is.EqualTo("50000")); }
public void Instantiate_OneSidedLess_Value() { var value = "-16.25"; var tolerance = new NumericToleranceFactory().Instantiate(value); Assert.That(tolerance, Is.TypeOf<NumericAbsoluteTolerance>()); var boundedTolerance = tolerance as NumericAbsoluteTolerance; Assert.That(boundedTolerance.Value, Is.EqualTo(16.25)); Assert.That(boundedTolerance.ValueString, Is.EqualTo("-16.25")); }
public void Instantiate_BoundedPercentage_Value() { var value = "50% (min 0.001)"; var tolerance = new NumericToleranceFactory().Instantiate(value); Assert.That(tolerance, Is.TypeOf<NumericBoundedPercentageTolerance>()); var boundedTolerance = tolerance as NumericBoundedPercentageTolerance; Assert.That(boundedTolerance.Value, Is.EqualTo(0.5)); Assert.That(boundedTolerance.Min, Is.EqualTo(0.001)); Assert.That(boundedTolerance.Max, Is.EqualTo(0)); Assert.That(boundedTolerance.ValueString, Is.EqualTo("50.0% (min: 0.001)")); }
public void Instantiate_BoundedPercentageWithEqual_Value() { var value = "10%(max=125) "; var tolerance = new NumericToleranceFactory().Instantiate(value); Assert.That(tolerance, Is.TypeOf<NumericBoundedPercentageTolerance>()); var boundedTolerance = tolerance as NumericBoundedPercentageTolerance; Assert.That(boundedTolerance.Value, Is.EqualTo(0.1)); Assert.That(boundedTolerance.Min, Is.EqualTo(0)); Assert.That(boundedTolerance.Max, Is.EqualTo(125)); Assert.That(boundedTolerance.ValueString, Is.EqualTo("10.0% (max: 125)")); }
public static Tolerance Instantiate(ColumnType type, string value) { Tolerance tolerance=null; switch (type) { case ColumnType.Text: break; case ColumnType.Numeric: tolerance = new NumericToleranceFactory().Instantiate(value); break; case ColumnType.DateTime: tolerance = new DateTimeToleranceFactory().Instantiate(value); break; case ColumnType.Boolean: break; default: break; } return tolerance; }
public void Instantiate_OneSidedMore_Value() { var value = " + 50%"; var tolerance = new NumericToleranceFactory().Instantiate(value); Assert.That(tolerance, Is.TypeOf<NumericPercentageTolerance>()); var boundedTolerance = tolerance as NumericPercentageTolerance; Assert.That(boundedTolerance.Value, Is.EqualTo(0.5)); Assert.That(boundedTolerance.ValueString, Is.EqualTo("+50.0%")); }
public void Instantiate_Percentage_Value() { var value = "50%"; var tolerance = new NumericToleranceFactory().Instantiate(value); Assert.That(tolerance, Is.TypeOf<NumericPercentageTolerance>()); Assert.That(tolerance.Value, Is.EqualTo(0.5)); Assert.That(tolerance.ValueString, Is.EqualTo("50.0%")); }