GetHashCode() публичный Метод

Returns a hash code value for this object.
public GetHashCode ( ) : int
Результат int
Пример #1
0
        public virtual void TestHashCodeAndEquals()
        {
            MultiPhraseQuery query1 = new MultiPhraseQuery();
            MultiPhraseQuery query2 = new MultiPhraseQuery();

            Assert.AreEqual(query1.GetHashCode(), query2.GetHashCode());
            Assert.IsTrue(query1.Equals(query2));
            Assert.AreEqual(query1, query2);

            Term term1 = new Term("someField", "someText");

            query1.Add(term1);
            query2.Add(term1);

            Assert.AreEqual(query1.GetHashCode(), query2.GetHashCode());
            Assert.AreEqual(query1, query2);

            Term term2 = new Term("someField", "someMoreText");

            query1.Add(term2);

            Assert.IsFalse(query1.GetHashCode() == query2.GetHashCode());
            Assert.IsFalse(query1.Equals(query2));

            query2.Add(term2);

            Assert.AreEqual(query1.GetHashCode(), query2.GetHashCode());
            Assert.AreEqual(query1, query2);
        }
Пример #2
0
		public virtual void  TestHashCodeAndEquals()
		{
			MultiPhraseQuery query1 = new MultiPhraseQuery();
			MultiPhraseQuery query2 = new MultiPhraseQuery();
			
			Assert.AreEqual(query1.GetHashCode(), query2.GetHashCode());
			Assert.AreEqual(query1, query2);
			
			Term term1 = new Term("someField", "someText");
			
			query1.Add(term1);
			query2.Add(term1);
			
			Assert.AreEqual(query1.GetHashCode(), query2.GetHashCode());
			Assert.AreEqual(query1, query2);
			
			Term term2 = new Term("someField", "someMoreText");
			
			query1.Add(term2);
			
			Assert.IsFalse(query1.GetHashCode() == query2.GetHashCode());
			Assert.IsFalse(query1.Equals(query2));
			
			query2.Add(term2);
			
			Assert.AreEqual(query1.GetHashCode(), query2.GetHashCode());
			Assert.AreEqual(query1, query2);
		}