示例#1
0
        public void SerializeSchemaWriter_SchemaIsNull_ArgumentNullException()
        {
            // arrange
            // act
            void Action() => SchemaSerializer.Serialize(null, new StringWriter());

            // assert
            Assert.Throws <ArgumentNullException>(Action);
        }
示例#2
0
        public void Serialize_SchemaIsNull_ArgumentNullException()
        {
            // arrange
            // act
            void Action() => SchemaSerializer.Serialize(null);

            // assert
            Assert.Throws <ArgumentNullException>(Action);
        }
示例#3
0
        public void SerializeSchemaWriter_WriterIsNull_ArgumentNullException()
        {
            // arrange
            ISchema schema = SchemaBuilder.New()
                             .AddDocumentFromString("type Query { foo: String }")
                             .AddResolver("Query", "foo", "bar")
                             .Create();

            // act
            void Action() => SchemaSerializer.Serialize(schema, null);

            // assert
            Assert.Throws <ArgumentNullException>(Action);
        }
示例#4
0
        public void SerializeSchemaWriter_Serialize()
        {
            // arrange
            ISchema schema = SchemaBuilder.New()
                             .AddDocumentFromString("type Query { foo: String }")
                             .AddResolver("Query", "foo", "bar")
                             .Create();
            var stringBuilder = new StringBuilder();

            // act
            SchemaSerializer.Serialize(schema, new StringWriter(stringBuilder));

            // assert
            stringBuilder.ToString().MatchSnapshot();
        }
示例#5
0
        public void SerializeSchemaWithMutationWithoutSubscription()
        {
            // arrange
            string source = FileResource.Open(
                "serialize_schema_with_mutation.graphql");
            ISchema schema = Schema.Create(
                source,
                c =>
            {
                c.Use(next => context => next(context));
            });

            var sb = new StringBuilder();
            var s  = new StringWriter(sb);

            // act
            SchemaSerializer.Serialize(schema, s);

            // assert
            sb.ToString().Snapshot();
        }
示例#6
0
        public void SerializeSchemaWithDirective()
        {
            // arrange
            string  source = FileResource.Open("serialize_schema.graphql");
            ISchema schema = Schema.Create(
                source,
                c =>
            {
                c.Use(next => context => next(context));
                c.RegisterDirective(new DirectiveType(t =>
                                                      t.Name("upper")
                                                      .Location(DirectiveLocation.FieldDefinition)));
            });

            var sb = new StringBuilder();
            var s  = new StringWriter(sb);

            // act
            SchemaSerializer.Serialize(schema, s);

            // assert
            sb.ToString().Snapshot();
        }
示例#7
0
 public string Print() => SchemaSerializer.Serialize(this);
示例#8
0
 public override string ToString()
 {
     return(SchemaSerializer.Serialize(this));
 }