private float?GeneratePositiveSingleValue(DbaseField field) { if (field.Length < DbaseSingle.PositiveValueMinimumLength || !SingleSupportedFieldTypes.Contains(field.FieldType)) { return(null); } var digits = DbaseIntegerDigits.Min(field.PositiveIntegerDigits, DbaseSingle.MaximumIntegerDigits); var number = GeneratePositiveNumber(digits, field.DecimalCount); return(Single.Parse( number, NumberStyles.AllowDecimalPoint, new NumberFormatInfo { NumberDecimalDigits = field.DecimalCount.ToInt32(), NumberDecimalSeparator = "." })); }
private double?GenerateNegativeDoubleValue(DbaseField field) { if (field.Length < DbaseDouble.NegativeValueMinimumLength || !DoubleSupportedFieldTypes.Contains(field.FieldType)) { return(null); } var digits = DbaseIntegerDigits.Min(field.NegativeIntegerDigits, DbaseDouble.MaximumIntegerDigits); var number = GenerateNegativeNumber(digits, field.DecimalCount); return(Double.Parse( number, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, new NumberFormatInfo { NumberDecimalDigits = field.DecimalCount.ToInt32(), NumberDecimalSeparator = ".", NegativeSign = "-" })); }
public void MinReturnsExpectedResult(int left, int right, int expected) { var result = DbaseIntegerDigits.Min(new DbaseIntegerDigits(left), new DbaseIntegerDigits(right)); Assert.Equal(new DbaseIntegerDigits(expected), result); }