Пример #1
0
        public void CreateValue()
        {
            // arrange
            string value = Guid.NewGuid().ToString();

            // act
            var result = ResolverResult <string> .CreateValue(value);

            // assert
            Assert.Equal(value, result.Value);
            Assert.False(result.IsError);
            Assert.Null(result.ErrorMessage);
        }
Пример #2
0
        private Schema CreateSchema(IServiceProvider services)
        {
            return(Schema.Create(@"
                type Query {
                    a: String
                    b(a: String!): String
                    x: String
                    y: String
                    xasync: String
                    yasync: String
                }
                ", c =>
            {
                c.RegisterServiceProvider(services);

                c.BindResolver(() => "hello world a")
                .To("Query", "a");
                c.BindResolver(
                    ctx => "hello world " + ctx.Argument <string>("a"))
                .To("Query", "b");
                c.BindResolver(
                    () => ResolverResult <string>
                    .CreateValue("hello world x"))
                .To("Query", "x");
                c.BindResolver(
                    () => ResolverResult <string>
                    .CreateError("hello world y"))
                .To("Query", "y");
                c.BindResolver(
                    async() => await Task.FromResult(
                        ResolverResult <string>
                        .CreateValue("hello world xasync")))
                .To("Query", "xasync");
                c.BindResolver(
                    async() => await Task.FromResult(
                        ResolverResult <string>
                        .CreateError("hello world yasync")))
                .To("Query", "yasync");
            }));
        }