public void EqualsComparesConstraints() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); PatternGroup group3 = new PatternGroup(); group1.AddConstraint(new Constraint(new VariableExpression(new Variable("var")))); group2.AddConstraint(new Constraint(new VariableExpression(new Variable("var")))); group3.AddConstraint(new Constraint(new VariableExpression(new Variable("other")))); Assert.IsTrue(group1.Equals(group2), "PatternGroup1 should equal group2"); Assert.IsTrue(!group1.Equals(group3), "PatternGroup1 should not equal group3"); }
public void GetHashCodeUsesConstraints() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); PatternGroup group3 = new PatternGroup(); group1.AddConstraint(new Constraint(new VariableExpression(new Variable("var")))); group2.AddConstraint(new Constraint(new VariableExpression(new Variable("var")))); group3.AddConstraint(new Constraint(new VariableExpression(new Variable("other")))); Assert.IsTrue(group1.GetHashCode() == group2.GetHashCode(), "PatternGroup1 should have same hash code as group2"); Assert.IsTrue(group1.GetHashCode() != group3.GetHashCode(), "PatternGroup1 should not have same hash code as group3"); }
private void ParseFilter(QueryTokenizer tokenizer, PatternGroup group) { while (tokenizer.MoveNext()) { switch (tokenizer.Type) { case QueryTokenizer.TokenType.BeginGroup: break; case QueryTokenizer.TokenType.EndGroup: return; case QueryTokenizer.TokenType.Variable: Constraint constraint = new Constraint(new VariableExpression(new Variable(tokenizer.TokenText))); group.AddConstraint(constraint); break; } } }