public virtual void TestEquals() { AutomatonQuery a1 = new AutomatonQuery(NewTerm("foobar"), BasicAutomata.MakeString("foobar")); // reference to a1 AutomatonQuery a2 = a1; // same as a1 (accepts the same language, same term) AutomatonQuery a3 = new AutomatonQuery(NewTerm("foobar"), BasicOperations.Concatenate(BasicAutomata.MakeString("foo"), BasicAutomata.MakeString("bar"))); // different than a1 (same term, but different language) AutomatonQuery a4 = new AutomatonQuery(NewTerm("foobar"), BasicAutomata.MakeString("different")); // different than a1 (different term, same language) AutomatonQuery a5 = new AutomatonQuery(NewTerm("blah"), BasicAutomata.MakeString("foobar")); Assert.AreEqual(a1.GetHashCode(), a2.GetHashCode()); Assert.AreEqual(a1, a2); Assert.AreEqual(a1.GetHashCode(), a3.GetHashCode()); Assert.AreEqual(a1, a3); // different class AutomatonQuery w1 = new WildcardQuery(NewTerm("foobar")); // different class AutomatonQuery w2 = new RegexpQuery(NewTerm("foobar")); Assert.IsFalse(a1.Equals(w1)); Assert.IsFalse(a1.Equals(w2)); Assert.IsFalse(w1.Equals(w2)); Assert.IsFalse(a1.Equals(a4)); Assert.IsFalse(a1.Equals(a5)); Assert.IsFalse(a1.Equals(null)); }