Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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));
        }
Beispiel #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));
        }