public void result_is_false_when_no_parent() { var gameObject = new GameObject(); var mockSubQuery = new Mock <IQuery>(MockBehavior.Strict); var testObject = new ParentQuery(mockSubQuery.Object); Assert.False(testObject.Match(gameObject)); }
/// <summary> /// Parse a stack selector. /// </summary> public IQuery descendents_selector() { bool isRoot = tokenizer.Token == QueryTokens.Slash; if (isRoot) { tokenizer.Advance(); } var query = compound_selector(); if (isRoot) { var rootQuery = new RootQuery(); query = new AndQuery(query, rootQuery); } if (tokenizer.AtEnd) { // Exhausted tokens, return single filter. return(query); } do { if (tokenizer.Token == QueryTokens.Slash) { query = new ParentQuery(query); } else if (tokenizer.Token == QueryTokens.GreaterThan) { query = new AncestorQuery(query); } else { throw new ApplicationException("Unexpected token: " + tokenizer.TokenString); } tokenizer.Advance(); // Chew up the separator. var otherQuery = compound_selector(); query = new AndQuery(otherQuery, query); } while (!tokenizer.AtEnd); return(query); }
public void result_is_false_when_sub_query_doesnt_matches_parent() { var childGameObject = new GameObject(); var parentGameObject = new GameObject(); childGameObject.transform.parent = parentGameObject.transform; var mockSubQuery = new Mock <IQuery>(); mockSubQuery .Setup(m => m.Match(parentGameObject)) .Returns(false); var testObject = new ParentQuery(mockSubQuery.Object); Assert.False(testObject.Match(childGameObject)); }
public ParentQueryExecutor(ParentQuery query) : base(query) { this.parentQuery = query; }
private ParentQuery(ParentQuery other) : base(other) { }
private Query ProcessAxis(Axis root, Flags flags, out Props props) { Query result = null; if (root.Prefix.Length > 0) { _needContext = true; } _firstInput = null; Query qyInput; { if (root.Input != null) { Flags inputFlags = Flags.None; if ((flags & Flags.PosFilter) == 0) { Axis input = root.Input as Axis; if (input != null) { if ( root.TypeOfAxis == Axis.AxisType.Child && input.TypeOfAxis == Axis.AxisType.DescendantOrSelf && input.NodeType == XPathNodeType.All ) { Query qyGrandInput; if (input.Input != null) { qyGrandInput = ProcessNode(input.Input, Flags.SmartDesc, out props); } else { qyGrandInput = new ContextQuery(); props = Props.None; } result = new DescendantQuery(qyGrandInput, root.Name, root.Prefix, root.NodeType, false, input.AbbrAxis); if ((props & Props.NonFlat) != 0) { result = new DocumentOrderQuery(result); } props |= Props.NonFlat; return result; } } if (root.TypeOfAxis == Axis.AxisType.Descendant || root.TypeOfAxis == Axis.AxisType.DescendantOrSelf) { inputFlags |= Flags.SmartDesc; } } qyInput = ProcessNode(root.Input, inputFlags, out props); } else { qyInput = new ContextQuery(); props = Props.None; } } switch (root.TypeOfAxis) { case Axis.AxisType.Ancestor: result = new XPathAncestorQuery(qyInput, root.Name, root.Prefix, root.NodeType, false); props |= Props.NonFlat; break; case Axis.AxisType.AncestorOrSelf: result = new XPathAncestorQuery(qyInput, root.Name, root.Prefix, root.NodeType, true); props |= Props.NonFlat; break; case Axis.AxisType.Child: if ((props & Props.NonFlat) != 0) { result = new CacheChildrenQuery(qyInput, root.Name, root.Prefix, root.NodeType); } else { result = new ChildrenQuery(qyInput, root.Name, root.Prefix, root.NodeType); } break; case Axis.AxisType.Parent: result = new ParentQuery(qyInput, root.Name, root.Prefix, root.NodeType); break; case Axis.AxisType.Descendant: if ((flags & Flags.SmartDesc) != 0) { result = new DescendantOverDescendantQuery(qyInput, false, root.Name, root.Prefix, root.NodeType, /*abbrAxis:*/false); } else { result = new DescendantQuery(qyInput, root.Name, root.Prefix, root.NodeType, false, /*abbrAxis:*/false); if ((props & Props.NonFlat) != 0) { result = new DocumentOrderQuery(result); } } props |= Props.NonFlat; break; case Axis.AxisType.DescendantOrSelf: if ((flags & Flags.SmartDesc) != 0) { result = new DescendantOverDescendantQuery(qyInput, true, root.Name, root.Prefix, root.NodeType, root.AbbrAxis); } else { result = new DescendantQuery(qyInput, root.Name, root.Prefix, root.NodeType, true, root.AbbrAxis); if ((props & Props.NonFlat) != 0) { result = new DocumentOrderQuery(result); } } props |= Props.NonFlat; break; case Axis.AxisType.Preceding: result = new PrecedingQuery(qyInput, root.Name, root.Prefix, root.NodeType); props |= Props.NonFlat; break; case Axis.AxisType.Following: result = new FollowingQuery(qyInput, root.Name, root.Prefix, root.NodeType); props |= Props.NonFlat; break; case Axis.AxisType.FollowingSibling: result = new FollSiblingQuery(qyInput, root.Name, root.Prefix, root.NodeType); if ((props & Props.NonFlat) != 0) { result = new DocumentOrderQuery(result); } break; case Axis.AxisType.PrecedingSibling: result = new PreSiblingQuery(qyInput, root.Name, root.Prefix, root.NodeType); break; case Axis.AxisType.Attribute: result = new AttributeQuery(qyInput, root.Name, root.Prefix, root.NodeType); break; case Axis.AxisType.Self: result = new XPathSelfQuery(qyInput, root.Name, root.Prefix, root.NodeType); break; case Axis.AxisType.Namespace: if ((root.NodeType == XPathNodeType.All || root.NodeType == XPathNodeType.Element || root.NodeType == XPathNodeType.Attribute) && root.Prefix.Length == 0) { result = new NamespaceQuery(qyInput, root.Name, root.Prefix, root.NodeType); } else { result = new EmptyQuery(); } break; default: throw XPathException.Create(SR.Xp_NotSupported, _query); } return result; }
public ParentQueryExecutor(ParentQuery parentQuery) { this.ParentQuery = parentQuery; }
public CouchbaseParentQuery(ParentQuery contentQuery) : base(contentQuery) { this._parentQuery = contentQuery; }