Exemplo n.º 1
0
        public void Introspected_ListType_PropertyCheck()
        {
            var serverBuilder = new TestServerBuilder();
            var server        = serverBuilder.AddGraphType <string>()
                                .Build();

            var schema = new IntrospectedSchema(server.Schema);

            schema.Rebuild();

            var scalar = GraphQLProviders.ScalarProvider.RetrieveScalar(typeof(string));

            var spected = schema.FindIntrospectedType(scalar);

            var wrapped = Introspection.WrapBaseTypeWithModifiers(spected, MetaGraphTypes.IsList);

            Assert.AreEqual(TypeKind.LIST, wrapped.Kind);

            Assert.IsNull(wrapped.Fields);
            Assert.IsNull(wrapped.Interfaces);
            Assert.IsNull(wrapped.PossibleTypes);
            Assert.IsNull(wrapped.EnumValues);
            Assert.IsNull(wrapped.InputFields);
            Assert.IsNull(wrapped.Name);
            Assert.IsNull(wrapped.Description);
            Assert.AreEqual(spected, wrapped.OfType);
        }
Exemplo n.º 2
0
        public void Introspected_ListType_NotNullType_NotNullList_PropertyCheck()
        {
            var serverBuilder = new TestServerBuilder();
            var server        = serverBuilder.AddGraphType <string>()
                                .Build();

            var schema = new IntrospectedSchema(server.Schema);

            schema.Rebuild();

            var scalar = GraphQLProviders.ScalarProvider.RetrieveScalar(typeof(string));

            var spected = schema.FindIntrospectedType(scalar);

            var wrapped = Introspection.WrapBaseTypeWithModifiers(spected, GraphTypeExpression.RequiredListRequiredItem);

            Assert.AreEqual(TypeKind.NON_NULL, wrapped.Kind);

            var unwrappedList = wrapped.OfType;

            Assert.AreEqual(TypeKind.LIST, unwrappedList.Kind);

            var unwrappedItemType = unwrappedList.OfType;

            Assert.AreEqual(TypeKind.NON_NULL, unwrappedItemType.Kind);

            var itemType = unwrappedItemType.OfType;

            Assert.AreEqual(spected, itemType);
        }
Exemplo n.º 3
0
        public void Introspected_NotNullType_WhenSuppliedANotNullType_ThrowsException()
        {
            var serverBuilder = new TestServerBuilder();
            var server        = serverBuilder.AddGraphType <string>()
                                .Build();

            var schema = new IntrospectedSchema(server.Schema);

            schema.Rebuild();

            var scalar = GraphQLProviders.ScalarProvider.RetrieveScalar(typeof(string));

            var spected = schema.FindIntrospectedType(scalar);

            var wrapped = Introspection.WrapBaseTypeWithModifiers(spected, MetaGraphTypes.IsNotNull);

            Assert.Throws <GraphTypeDeclarationException>(() =>
            {
                var _ = new IntrospectedType(wrapped, TypeKind.NON_NULL);
            });
        }