예제 #1
0
        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());
        }
예제 #2
0
        public void ParseValue_Null()
        {
            // arrange
            var    type  = new DecimalType();
            object input = null;

            // act
            object output = type.ParseValue(input);

            // assert
            Assert.IsType <NullValueNode>(output);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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());
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }