예제 #1
0
        public void Query_Create_IsCorrect()
        {
            var query = GraphQuery.Query <GraphQueryTests>("queryName");

            Assert.Null(query.LastNode);
            Assert.Null(query.Node.Value);
            Assert.Empty(query.Node.Childs);
        }
예제 #2
0
        static void Main(string[] args)
        {
            string queryName = "qname";

            var query = GraphQuery.Query <User>(queryName, user => user.FirstName == "FIRSTNAME")
                        .Include(x => x.Friends).ThenInclude(x => x.Department)
                        .Include(x => x.FirstName)
                        .Include(x => x.Department.Id)
                        .Include(x => x.Department.Name)
                        .Include(x => x.Friends).ThenInclude(x => x.Department.Parent.Id)
                        .Include(x => x.Friends).ThenInclude(x => x.Department.Parent.Name)
                        .Include(x => x.Friends).ThenInclude(x => x.Department.Parent.Parent)
                        .Render();

            Console.WriteLine(query);
        }
예제 #3
0
        public void Query_Render_IsCorrect()
        {
            var renderedQuery = GraphQuery.Query <TestUser>("queryName", user => user.FirstName == "FIRSTNAME")
                                .Include(x => x.Friends).ThenInclude(x => x.Department)
                                .Include(x => x.FirstName)
                                .Include(x => x.Department.Id)
                                .Include(x => x.Department.Name)
                                .Include(x => x.Friends).ThenInclude(x => x.Department.Parent.Id)
                                .Include(x => x.Friends).ThenInclude(x => x.Department.Parent.Name)
                                .Include(x => x.Friends).ThenInclude(x => x.Department.Parent.Parent)
                                .Render();

            string correctQuery = @"query {
                                     queryName (firstName : ""FIRSTNAME"") {
                                            friends {
                                                  department {
                                                      parent {
                                                          id,
                                                          name,
                                                          parent
                                                      }
                                                  }
                                            },
                                            firstName,
                                            department {
                                                 id,
                                                 name
                                            }
                                       }
                                    }";


            Assert.Equal(ClearQuery(correctQuery), ClearQuery(renderedQuery));

            string ClearQuery(string query)
            {
                return(query.Replace("\r\n", "").Replace(" ", ""));
            }
        }