⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 liatestcase.cs

📁 DotLucentet,用来做撬
💻 CS
字号:
using System;
using Lucene.Net.Documents;
using Lucene.Net.Search;
using Lucene.Net.Store;
using NUnit.Framework;

namespace dotLucene.inAction.Common
{
	/// <summary>
	/// LiaBaseTest
	/// </summary>
	[TestFixture]
	public abstract class LiaTestCase
	{
		private String indexDir = "index";

		protected Directory directory;

		[SetUp]
		protected virtual void Init()
		{
			directory = FSDirectory.GetDirectory(indexDir, false);
		}

		[TearDown]
		protected void End()
		{
			directory.Close();
		}

		protected  void DumpHits(Hits hits)
		{
			if (hits.Length() == 0)
			{
				Console.Out.WriteLine("No hits");
			}

			for (int i = 0; i < hits.Length(); i++)
			{
				Document doc = hits.Doc(i);
				Console.Out.WriteLine(hits.Score(i) + ":" + doc.Get("title"));
			}
		}

		protected  void AssertHitsIncludeTitle(Hits hits, String title)
		{
			for (int i = 0; i < hits.Length(); i++)
			{
				Document doc = hits.Doc(i);
				if (title.Equals(doc.Get("title")))
				{
					Assert.IsTrue(true);
					return;
				}
			}

			Assert.Fail("title '" + title + "' not found");
		}

		//  protected  SupportClass.Date ParseDate(String s) 
		//  { 
		//      return new SimpleDateFormat("yyyy-MM-dd").parse(s);
		//  }
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -