public void Creates_MasterQuery_Expression() { Expression <Func <JObject, IEnumerable <IssueModel> > > expected = data => (IEnumerable <IssueModel>)Rewritten.List.ToSubqueryList( Rewritten.List.Select( data["data"]["repository"]["issues"]["nodes"], issue => new IssueModel { Number = issue["number"].ToObject <int>(), Comments = Rewritten.List.ToSubqueryList( Rewritten.List.Select( issue["comments"]["nodes"], comment => new CommentModel { Id = comment["id"].ToString(), Body = comment["body"].ToObject <string>(), }), data.Annotation <ISubqueryRunner>(), SubqueryPlaceholder.placeholder) }), data.Annotation <ISubqueryRunner>(), SubqueryPlaceholder.placeholder); ExpressionRewriterAssertions.AssertCompiledQueryExpressionEqual(expected, TestMasterQuery, "SimpleSubquery<IEnumerable<CommentModel>>", "PagedSubquery<IEnumerable<IssueModel>>"); }
public void Creates_MasterQuery_Expression() { Expression <Func <JObject, IEnumerable <int> > > expected = data => (IEnumerable <int>)Rewritten.List.ToSubqueryList( Rewritten.List.Select( data["data"]["repository"]["issues"]["nodes"], issue => issue["number"].ToObject <int>()), data.Annotation <ISubqueryRunner>(), SubqueryPlaceholder.placeholder); ExpressionRewriterAssertions.AssertCompiledQueryExpressionEqual(expected, TestMasterQuery(10), "SimpleSubquery<IEnumerable<int>>"); }
public void Creates_MasterQuery_Expression() { Expression <Func <JObject, RepositoryModel> > expected = data => Rewritten.Value.Select( data["data"]["repository"], repository => new RepositoryModel { Name = repository["name"].ToObject <string>(), Issues = Rewritten.List.ToSubqueryList( Rewritten.List.Select( repository["issues"]["nodes"], issue => new IssueModel { Number = issue["number"].ToObject <int>(), }), data.Annotation <ISubqueryRunner>(), SubqueryPlaceholder.placeholder), }); ExpressionRewriterAssertions.AssertCompiledQueryExpressionEqual(expected, TestMasterQuery, "SimpleSubquery<IEnumerable<IssueModel>>"); }
public void Creates_MasterQuery_Expression() { Expression <Func <JObject, object> > expected = data => Rewritten.Value.Select( data["data"]["repository"], repository => new { IntList1 = Rewritten.List.ToSubqueryList( Rewritten.List.ToList <int>(Rewritten.List.Select(repository["intList1"]["nodes"], issue => issue["number"])), data.Annotation <ISubqueryRunner>(), SubqueryPlaceholder.placeholder), IntList2 = Rewritten.List.ToSubqueryList( Rewritten.List.ToList <int>(Rewritten.List.Select(repository["intList2"]["nodes"], issue => issue["number"])), data.Annotation <ISubqueryRunner>(), SubqueryPlaceholder.placeholder) }); var query = new Query() .Repository("foo", "bar") .Select(repository => new { IntList1 = repository.Issues(null, null, null, null, null) .AllPages() .Select(issue => issue.Number) .ToList(), IntList2 = repository.Issues(null, null, null, null, null) .AllPages() .Select(issue => issue.Number) .ToList() }).Compile(); var masterQuery = query.GetMasterQuery(); ExpressionRewriterAssertions.AssertCompiledQueryExpressionEqual(expected, masterQuery, "SimpleSubquery<IEnumerable<int>>", "SimpleSubquery<IEnumerable<int>>"); }