public void ParseValue_Nullable() { // arrange var type = new DecimalType(); decimal?input = 123M; // act FloatValueNode output = (FloatValueNode)type.ParseValue(input); // assert Assert.Equal(123M, output.ToDecimal()); }
public void ParseValue_Null() { // arrange var type = new DecimalType(); object input = null; // act object output = type.ParseValue(input); // assert Assert.IsType <NullValueNode>(output); }
public void ParseValue_MinValue_Violation() { // arrange var type = new DecimalType(1, 100); decimal input = 0M; // act Action action = () => type.ParseValue(input); // assert Assert.Throws <SerializationException>(action); }
public void ParseValue_MinValue() { // arrange var type = new DecimalType(1, 100); decimal input = 1M; // act var literal = (FloatValueNode)type.ParseValue(input); // assert Assert.Equal(1M, literal.ToDecimal()); }
public void ParseValue_Decimal_Min() { // arrange DecimalType type = new DecimalType(); decimal input = decimal.MinValue; string expectedLiteralValue = "-7.922816e+028"; // act FloatValueNode literal = (FloatValueNode)type.ParseValue(input); // assert Assert.Equal(expectedLiteralValue, literal.Value, StringComparer.InvariantCulture); }
public void ParseValue_FormatsToSpecifiedNumberOfDecimalDigitsLong() { // arrange var type = new DecimalType(); var input = 1234567.890123456789m; var output = "1234567.890123456789"; // act var result = type.ParseValue(input); // assert Assert.True(result is FloatValueNode); Assert.True(result.Value is string); Assert.Equal(output, (string)result.Value); }
public void ParseValue_Handle12Digits() { // arrange var type = new DecimalType(); var input = 1234567.890123456789m; var output = "1234567.890123456789"; // act var result = type.ParseValue(input); // assert Assert.True(result is FloatValueNode); Assert.True(result.Value is string); Assert.Equal(output, (string)result.Value); }
public void ParseValue_FormatsToDefaultSignificantDigits() { // arrange var type = new DecimalType(); var input = 1234567.891123456789m; var output = "1234567.891123456789"; // act var result = type.ParseValue(input); // assert Assert.True(result is FloatValueNode); Assert.True(result.Value is string); Assert.Equal(output, (string)result.Value); }