public void AssertStoredFieldsEquals(string info, IndexReader leftReader, IndexReader rightReader)
{
Debug.Assert(leftReader.MaxDoc == rightReader.MaxDoc);
for (int i = 0; i < leftReader.MaxDoc; i++)
{
Document leftDoc = leftReader.Document(i);
Document rightDoc = rightReader.Document(i);
// TODO: I think this is bogus because we don't document what the order should be
// from these iterators, etc. I think the codec/IndexReader should be free to order this stuff
// in whatever way it wants (e.g. maybe it packs related fields together or something)
// To fix this, we sort the fields in both documents by name, but
// we still assume that all instances with same name are in order:
Comparison<IndexableField> comp = (a, b) => String.Compare(a.Name, b.Name, StringComparison.Ordinal);
leftDoc.Fields.Sort(comp);
rightDoc.Fields.Sort(comp);
var leftIterator = leftDoc.GetEnumerator();
var rightIterator = rightDoc.GetEnumerator();
while (leftIterator.MoveNext())
{
Assert.IsTrue(rightIterator.MoveNext(), info);
AssertStoredFieldEquals(info, leftIterator.Current, rightIterator.Current);
}
Assert.IsFalse(rightIterator.MoveNext(), info);
}
}