Esempio n. 1
0
        public void IsInstanceOfType_NullValueNode()
        {
            // arrange
            var type = new IdType();
            NullValueNode input = NullValueNode.Default;

            // act
            bool result = type.IsInstanceOfType(input);

            // assert
            Assert.True(result);
        }
Esempio n. 2
0
        public void IsInstanceOfType_Wrong_ValueNode()
        {
            // arrange
            var type = new IdType();
            var input = new FloatValueNode(123456.0);

            // act
            bool result = type.IsInstanceOfType(input);

            // assert
            Assert.False(result);
        }
Esempio n. 3
0
        public void ParseValue_String()
        {
            // arrange
            var type = new IdType();
            object input = "hello";

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

            // assert
            Assert.IsType<StringValueNode>(output);
        }
Esempio n. 4
0
        public void IsInstanceOfType_IntValueNode()
        {
            // arrange
            var type = new IdType();
            var input = new IntValueNode(123456);

            // act
            bool result = type.IsInstanceOfType(input);

            // assert
            Assert.True(result);
        }
Esempio n. 5
0
        public void ParseLiteral_NullValueNode()
        {
            // arrange
            var type = new IdType();
            NullValueNode input = NullValueNode.Default;

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

            // assert
            Assert.Null(output);
        }
Esempio n. 6
0
        public void ParseValue_Null()
        {
            // arrange
            var type = new IdType();
            object input = null;

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

            // assert
            Assert.IsType<NullValueNode>(output);
        }
Esempio n. 7
0
        public void Deserialize_Float()
        {
            // arrange
            var type = new IdType();
            float serialized = 1.1f;

            // act
            bool success = type.TryDeserialize(serialized, out object value);

            // assert
            Assert.False(success);
        }
Esempio n. 8
0
        public void Deserialize_Null()
        {
            // arrange
            var type = new IdType();
            object serialized = null;

            // act
            bool success = type.TryDeserialize(serialized, out object value);

            // assert
            Assert.Null(value);
        }
Esempio n. 9
0
        public void ParseValue_Int()
        {
            // arrange
            var    type  = new IdType();
            object input = 1234;

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

            // assert
            Assert.IsType <IntValueNode>(output);
        }
Esempio n. 10
0
        public void Serialize_String()
        {
            // arrange
            var type  = new IdType();
            var input = "123456";

            // act
            object serializedValue = type.Serialize(input);

            // assert
            Assert.IsType <string>(serializedValue);
            Assert.Equal("123456", serializedValue);
        }
Esempio n. 11
0
        public void ParseLiteral_IntValueNode()
        {
            // arrange
            var type  = new IdType();
            var input = new IntValueNode("123456");

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

            // assert
            Assert.IsType <string>(output);
            Assert.Equal("123456", output);
        }
Esempio n. 12
0
        public void Deserialize_Int()
        {
            // arrange
            var type = new IdType();
            var serialized = 123456;

            // act
            bool success = type.TryDeserialize(serialized, out object value);

            // assert
            Assert.True(success);
            Assert.Equal("123456", Assert.IsType<string>(value));
        }
Esempio n. 13
0
        public void Deserialize_Int()
        {
            // arrange
            IdType type = SchemaBuilder.New()
                          .AddQueryType(c => c
                                        .Name("QueryRoot")
                                        .Field("abc")
                                        .Type <IdType>()
                                        .Resolve("abc"))
                          .Create()
                          .GetType <IdType>("ID");
            var serialized = 123456;

            // act
            bool success = type.TryDeserialize(serialized, out object value);

            // assert
            Assert.True(success);
            Assert.Equal("123456", Assert.IsType <string>(value));
        }