public void HasPatternsExaminesAlternatePatternGroups() { PatternGroup group1 = new PatternGroup(); PatternGroup group1a = new PatternGroup(); PatternGroup group2 = new PatternGroup(); group1a.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new Variable("var"), new UriRef("http://example.com/object"))); group1.AddAlternateGroup(group1a); Assert.AreEqual(true, group1.HasPatterns, "Group should have patterns"); Assert.AreEqual(false, group2.HasPatterns, "Group should not have patterns"); }
public void GetMentionedVariablesExaminesAlternatePatternGroups() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); group2.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new Variable("var"), new UriRef("http://example.com/object"))); group1.AddAlternateGroup(group2); IList variables = group1.GetMentionedVariables(); Assert.AreEqual(1, variables.Count, "Should be one variable"); Assert.AreEqual(((Variable)variables[0]).Name, "var", "Variable is called var"); }
public void EqualsComparesAlternateGroupCount() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); PatternGroup group3 = new PatternGroup(); PatternGroup group1a = new PatternGroup(); PatternGroup group2a = new PatternGroup(); PatternGroup group3a = new PatternGroup(); PatternGroup group3b = new PatternGroup(); group1a.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var"))); group2a.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var"))); group3a.AddPattern(new Pattern(new UriRef("http://example.com/other"), new UriRef("http://example.com/predicate"), new Variable("var"))); group3b.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var"))); group1.AddAlternateGroup(group1a); group2.AddAlternateGroup(group2a); group3.AddAlternateGroup(group3a); group3.AddAlternateGroup(group3b); Assert.IsTrue(group1.Equals(group2), "PatternGroup1 should equal group2"); Assert.IsTrue(!group1.Equals(group3), "PatternGroup1 should not equal group3"); }
public void GetHashCodeUsesAlternateGroups() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); PatternGroup group3 = new PatternGroup(); PatternGroup group1a = new PatternGroup(); PatternGroup group2a = new PatternGroup(); PatternGroup group3a = new PatternGroup(); group1a.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var"))); group2a.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var"))); group3a.AddPattern(new Pattern(new UriRef("http://example.com/other"), new UriRef("http://example.com/predicate"), new Variable("var"))); group1.AddAlternateGroup(group1a); group2.AddAlternateGroup(group2a); group3.AddAlternateGroup(group3a); 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 group2"); }