示例#1
0
        public void SqlJoin_WithJoinDelegate_AddsJoinDelegateToMetadata()
        {
            void Join(JoinBuilder join, IReadOnlyDictionary <string, object> arguments,
                      IResolveFieldContext context, Node sqlAstNode) => join.On("id", "parentId");

            var fieldConfig = new FieldConfig("name");

            fieldConfig.SqlJoin(Join);

            fieldConfig.GetMetadata <JoinDelegate>(nameof(JoinDelegate))
            .Should()
            .Be((JoinDelegate)Join);
        }
示例#2
0
        public void SqlOrder_WithOrderByDelegate_AddsOrderByDelegateToMetadata()
        {
            void OrderBy(OrderByBuilder order, IReadOnlyDictionary <string, object> arguments,
                         IResolveFieldContext context, SqlTable sqlTable) => order.By("name");

            var fieldConfig = new FieldConfig("name");

            fieldConfig.SqlOrder(OrderBy);

            fieldConfig.GetMetadata <OrderByDelegate>(nameof(OrderByDelegate))
            .Should()
            .Be((OrderByDelegate)OrderBy);
        }
示例#3
0
        public void SqlWhere_WithWhereDelegate_AddsWhereDelegateToMetadata()
        {
            void Where(WhereBuilder where, IReadOnlyDictionary <string, object> arguments,
                       IResolveFieldContext context, SqlTable sqlAStNode) => where.Column("id", 3);

            var fieldConfig = new FieldConfig("name");

            fieldConfig.SqlWhere(Where);

            fieldConfig.GetMetadata <WhereDelegate>(nameof(WhereDelegate))
            .Should()
            .Be((WhereDelegate)Where);
        }