public void ParseScalarAndConvert()
        {
            // arrange
            var sourceType = new IntType();
            var targetType = typeof(string);
            var literal    = new IntValueNode("1");

            // act
            object result = ValueDeserializer
                            .ParseLiteral(sourceType, targetType, literal);

            // assert
            Assert.IsType <string>(result);
            Assert.Equal("1", result);
        }
        public void ParseScalar()
        {
            // arrange
            IntType      sourceType = new IntType();
            Type         targetType = typeof(int);
            IntValueNode literal    = new IntValueNode("1");

            // act
            object result = ValueDeserializer
                            .ParseLiteral(sourceType, targetType, literal);

            // assert
            Assert.IsType <int>(result);
            Assert.Equal(1, result);
        }
Ejemplo n.º 3
0
        public void IsInstanceOfType()
        {
            // arrange
            IntValueNode    intLiteral    = new IntValueNode(null, "12345");
            StringValueNode stringLiteral = new StringValueNode(null, "12345", false);
            NullValueNode   nullLiteral   = new NullValueNode(null);

            // act
            IntType integerType               = new IntType();
            bool    isIntLiteralInstanceOf    = integerType.IsInstanceOfType(intLiteral);
            bool    isStringLiteralInstanceOf = integerType.IsInstanceOfType(stringLiteral);
            bool    isNullLiteralInstanceOf   = integerType.IsInstanceOfType(nullLiteral);

            // assert
            Assert.True(isIntLiteralInstanceOf);
            Assert.False(isStringLiteralInstanceOf);
            Assert.True(isNullLiteralInstanceOf);
        }