public void IsEquals_NonNullStringListToStringList_False()
        {
            // arrange
            var x = new NonNullType(new ListType(new StringType()));
            var y = new ListType(new StringType());

            // act
            bool result = x.IsEqualTo(y);

            // assert
            Assert.False(result);
        }
        public void IsEquals_TwoStringNonNullListTypes_True()
        {
            // arrange
            var x = new NonNullType(new ListType(new StringType()));
            var y = new NonNullType(new ListType(new StringType()));

            // act
            bool result = x.IsEqualTo(y);

            // assert
            Assert.True(result);
        }
Ejemplo n.º 3
0
        public void EnsureNativeTypeIsCorrectlyDetected()
        {
            // arrange
            var innerType = new NonNullType(new StringType());
            var type      = new ListType(innerType);

            // act
            Type clrType = type.RuntimeType;

            // assert
            Assert.Equal(typeof(List <string>), clrType);
        }
Ejemplo n.º 4
0
        public static void NamedType()
        {
            // arrange
            var type = new NonNullType(
                new ListType(
                    new NonNullType(
                        new StringType())));

            // act
            StringType stringType = type.NamedType() as StringType;

            // assert
            Assert.NotNull(stringType);
        }
Ejemplo n.º 5
0
        public void EnsureInstanceOfIsDelegatedToInnerType()
        {
            // arrange
            var innerType = new ListType(new StringType());

            var  type          = new NonNullType(innerType);
            bool shouldBeFalse = ((IInputType)type).IsInstanceOfType(
                new IntValueNode(123));
            bool shouldBeTrue = ((IInputType)type).IsInstanceOfType(
                new ListValueNode(new[] { new StringValueNode("foo") }));

            // assert
            Assert.False(shouldBeFalse);
            Assert.True(shouldBeTrue);
        }
        public void ParseNonNullScalar()
        {
            // arrange
            var          sourceType = new NonNullType(new IntType());
            var          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.º 7
0
        public void EnsureInstanceOfIsDelegatedToInnerType()
        {
            // arrange
            NonNullType innerType = new NonNullType(new StringType());

            // act
            ListType type          = new ListType(innerType);
            bool     shouldBeFalse = type.IsInstanceOfType(
                new ListValueNode(new[] { new NullValueNode() }));
            bool shouldBeTrue = type.IsInstanceOfType(
                new ListValueNode(new[] { new StringValueNode("foo") }));

            // assert
            Assert.False(shouldBeFalse);
            Assert.True(shouldBeTrue);
        }
Ejemplo n.º 8
0
        public void Parse_InputObject_NonNullViolation()
        {
            // arrange
            ISchema schema = SchemaBuilder.New()
                             .AddInputObjectType <Test3Input>()
                             .ModifyOptions(o => o.StrictValidation = false)
                             .Create();

            var type = new NonNullType(schema.GetType <InputObjectType>("Test3Input"));

            // act
            var parser = new InputParser();

            void Action()
            => parser.ParseLiteral(NullValueNode.Default, type, Path.Root.Append("root"));

            // assert
            Assert.Throws <SerializationException>(Action).MatchSnapshot();
        }