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); }
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); }
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(" ", "")); } }