Пример #1
0
        public void ParseLiteral_Null_Throws()
        {
            // arrange
            var type = new DecimalType();

            // act
            // assert
            Assert.Throws <ArgumentNullException>(
                () => type.ParseLiteral(null));
        }
Пример #2
0
        public void ParseLiteral_Wrong_ValueNode_Throws()
        {
            // arrange
            var type  = new DecimalType();
            var input = new StringValueNode("abc");

            // act
            // assert
            Assert.Throws <SerializationException>(
                () => type.ParseLiteral(input));
        }
Пример #3
0
        public void ParseLiteral_NullValueNode()
        {
            // arrange
            var type = new DecimalType();

            // act
            var output = type.ParseLiteral(NullValueNode.Default);

            // assert
            Assert.Null(output);
        }
Пример #4
0
        public void ParseLiteral_NullValueNode()
        {
            // arrange
            DecimalType   type  = new DecimalType();
            NullValueNode input = new NullValueNode();

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

            // assert
            Assert.Null(output);
        }
Пример #5
0
        public void ParseLiteral_IntLiteral()
        {
            // arrange
            var type    = new DecimalType();
            var literal = new IntValueNode(123);

            // act
            var value = type.ParseLiteral(literal);

            // assert
            Assert.IsType <decimal>(value);
            Assert.Equal(literal.ToDecimal(), value);
        }
Пример #6
0
        public void ParseLiteral_ExponentialLiteral()
        {
            // arrange
            var            type    = new DecimalType();
            FloatValueNode literal = CreateExponentialLiteral();

            // act
            var value = type.ParseLiteral(literal);

            // assert
            Assert.IsType <decimal>(value);
            Assert.Equal(literal.ToDecimal(), value);
        }
Пример #7
0
        public void ParseLiteral_FloatValueNode()
        {
            // arrange
            DecimalType    type  = new DecimalType();
            FloatValueNode input = new FloatValueNode("1.000000e+000");

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

            // assert
            Assert.IsType <decimal>(output);
            Assert.Equal(1.0m, output);
        }