Exemplo n.º 1
0
        public void GetHashCodeUsesPatterns()
        {
            PatternGroup group1 = new PatternGroup();
            PatternGroup group2 = new PatternGroup();
            PatternGroup group3 = new PatternGroup();

            group1.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var")));
            group2.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var")));
            group3.AddPattern(new Pattern(new UriRef("http://example.com/other"), new UriRef("http://example.com/predicate"), new Variable("var")));

            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");
        }
Exemplo n.º 2
0
        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");
        }