Beispiel #1
0
        public void DefaultName()
        {
            var map       = new Internal.ScalarTypeMap();
            var cache     = new Internal.GraphTypeCache(map);
            var graphType = new GraphTypeBuilder <Model>(map).BuildGraphType(cache, new ServiceCollection());

            graphType.Name.Should().Be(nameof(Model));
        }
Beispiel #2
0
        public void ThrowsForUnspecifiedPropSameType()
        {
            var map     = new Internal.ScalarTypeMap();
            var builder = new GraphTypeBuilder <Model>(map)
                          .ScalarField(x => x.Child1)
                          .ResolvesVia <ChildModel1.Resolver>();

            new Action(() => builder.BuildGraphType(new Internal.GraphTypeCache(map), new ServiceCollection()))
            .Should()
            .Throw <UnableToResolveException>()
            .WithMessage("Unable to resolve property Child1a on class Model");
        }
Beispiel #3
0
        public void BuildsSchema()
        {
            var map     = new Internal.ScalarTypeMap();
            var builder = new GraphTypeBuilder <Model>(map)
                          .ScalarField(x => x.Child1)
                          .ResolvesVia <ChildModel1.Resolver>()
                          .ScalarField(x => x.Child1a)
                          .ResolvesVia <ChildModel1.Resolver>()
                          .ScalarField(x => x.Child2)
                          .ResolvesVia <ChildModel2.Resolver>();

            builder.BuildGraphType(new Internal.GraphTypeCache(map), new ServiceCollection()).Should().NotBeNull();
        }
Beispiel #4
0
        public void OverrideToId()
        {
            var map       = new Internal.ScalarTypeMap();
            var graphType = new GraphTypeBuilder <Model>(map)
                            .ScalarField(x => x.StringVal)
                            .AsGraphType <IdGraphType>()
                            .BuildGraphType(new Internal.GraphTypeCache(map), new ServiceCollection());

            graphType.Fields
            .SingleOrDefault(x => x.Name == nameof(Model.StringVal))
            .Should()
            .BeEquivalentTo(new {
                Type = typeof(IdGraphType),
            });
        }