/*
		private void assertReaderOpen(IndexReader reader) {
		reader.ensureOpen();
		
		if (reader instanceof DirectoryReader) {
		IndexReader[] subReaders = reader.getSequentialSubReaders();
		for (int i = 0; i < subReaders.length; i++) {
		assertReaderOpen(subReaders[i]);
		}
		}
		}
		*/
		
		private void  AssertRefCountEquals(int refCount, IndexReader reader)
		{
			Assert.AreEqual(refCount, reader.GetRefCount(), "Reader has wrong refCount value.");
		}
		private void  AssertReaderClosed(IndexReader reader, bool checkSubReaders, bool checkNormsClosed)
		{
			Assert.AreEqual(0, reader.GetRefCount());
			
			if (checkNormsClosed && reader is SegmentReader)
			{
				Assert.IsTrue(((SegmentReader) reader).NormsClosed());
			}
			
			if (checkSubReaders)
			{
				if (reader is DirectoryReader)
				{
					IndexReader[] subReaders = reader.GetSequentialSubReaders();
					for (int i = 0; i < subReaders.Length; i++)
					{
						AssertReaderClosed(subReaders[i], checkSubReaders, checkNormsClosed);
					}
				}
				
				if (reader is MultiReader)
				{
					IndexReader[] subReaders = reader.GetSequentialSubReaders();
					for (int i = 0; i < subReaders.Length; i++)
					{
						AssertReaderClosed(subReaders[i], checkSubReaders, checkNormsClosed);
					}
				}
				
				if (reader is ParallelReader)
				{
					IndexReader[] subReaders = ((ParallelReader) reader).GetSubReaders();
					for (int i = 0; i < subReaders.Length; i++)
					{
						AssertReaderClosed(subReaders[i], checkSubReaders, checkNormsClosed);
					}
				}
			}
		}