当前位置: 首页>>代码示例>>C#>>正文


C# TermRangeQuery.Equals方法代码示例

本文整理汇总了C#中Lucene.Net.Search.TermRangeQuery.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# TermRangeQuery.Equals方法的具体用法?C# TermRangeQuery.Equals怎么用?C# TermRangeQuery.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Search.TermRangeQuery的用法示例。


在下文中一共展示了TermRangeQuery.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestEqualsHashcode

		public virtual void  TestEqualsHashcode()
		{
			Query query = new TermRangeQuery("content", "A", "C", true, true);
			
			query.SetBoost(1.0f);
			Query other = new TermRangeQuery("content", "A", "C", true, true);
			other.SetBoost(1.0f);
			
			Assert.AreEqual(query, query, "query equals itself is true");
			Assert.AreEqual(query, other, "equivalent queries are equal");
			Assert.AreEqual(query.GetHashCode(), other.GetHashCode(), "hashcode must return same value when equals is true");
			
			other.SetBoost(2.0f);
			Assert.IsFalse(query.Equals(other), "Different boost queries are not equal");
			
			other = new TermRangeQuery("notcontent", "A", "C", true, true);
			Assert.IsFalse(query.Equals(other), "Different fields are not equal");
			
			other = new TermRangeQuery("content", "X", "C", true, true);
			Assert.IsFalse(query.Equals(other), "Different lower terms are not equal");
			
			other = new TermRangeQuery("content", "A", "Z", true, true);
			Assert.IsFalse(query.Equals(other), "Different upper terms are not equal");
			
			query = new TermRangeQuery("content", null, "C", true, true);
			other = new TermRangeQuery("content", null, "C", true, true);
			Assert.AreEqual(query, other, "equivalent queries with null lowerterms are equal()");
			Assert.AreEqual(query.GetHashCode(), other.GetHashCode(), "hashcode must return same value when equals is true");
			
			query = new TermRangeQuery("content", "C", null, true, true);
			other = new TermRangeQuery("content", "C", null, true, true);
			Assert.AreEqual(query, other, "equivalent queries with null upperterms are equal()");
			Assert.AreEqual(query.GetHashCode(), other.GetHashCode(), "hashcode returns same value");
			
			query = new TermRangeQuery("content", null, "C", true, true);
			other = new TermRangeQuery("content", "C", null, true, true);
			Assert.IsFalse(query.Equals(other), "queries with different upper and lower terms are not equal");
			
			query = new TermRangeQuery("content", "A", "C", false, false);
			other = new TermRangeQuery("content", "A", "C", true, true);
			Assert.IsFalse(query.Equals(other), "queries with different inclusive are not equal");
			
			query = new TermRangeQuery("content", "A", "C", false, false);
			other = new TermRangeQuery("content", "A", "C", false, false, System.Globalization.CultureInfo.CurrentCulture.CompareInfo);
			Assert.IsFalse(query.Equals(other), "a query with a collator is not equal to one without");
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:46,代码来源:TestTermRangeQuery.cs


注:本文中的Lucene.Net.Search.TermRangeQuery.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。