Lucene.Net.Index.TestPositionBasedTermVectorMapper.Test C# (CSharp) Method

Test() private method

private Test ( ) : void
return void
		public virtual void  Test()
		{
			PositionBasedTermVectorMapper mapper = new PositionBasedTermVectorMapper();
			
			mapper.SetExpectations("test", tokens.Length, true, true);
			//Test single position
			for (int i = 0; i < tokens.Length; i++)
			{
				System.String token = tokens[i];
				mapper.Map(token, 1, null, thePositions[i]);
			}
			var map = mapper.FieldToTerms;
			Assert.IsTrue(map != null, "map is null and it shouldn't be");
			Assert.IsTrue(map.Count == 1, "map Size: " + map.Count + " is not: " + 1);
			var positions = map["test"];
			Assert.IsNotNull(positions, "thePositions is null and it shouldn't be");

            Assert.AreEqual(numPositions, positions.Count, "thePositions Size: " + positions.Count + " is not: " + numPositions);
			System.Collections.BitArray bits = new System.Collections.BitArray((numPositions % 64 == 0?numPositions / 64:numPositions / 64 + 1) * 64);
			for (var iterator = positions.GetEnumerator(); iterator.MoveNext(); )
			{
				var entry = iterator.Current;
				PositionBasedTermVectorMapper.TVPositionInfo info = entry.Value;
				Assert.IsTrue(info != null, "info is null and it shouldn't be");
				int pos = (int)entry.Key;
				bits.Set(pos, true);
				Assert.IsTrue(info.Position == pos, info.Position + " does not equal: " + pos);
				Assert.IsTrue(info.Offsets != null, "info.getOffsets() is null and it shouldn't be");
				if (pos == 0)
				{
					Assert.IsTrue(info.Terms.Count == 2, "info.getTerms() Size: " + info.Terms.Count + " is not: " + 2); //need a test for multiple terms at one pos
					Assert.IsTrue(info.Offsets.Count == 2, "info.getOffsets() Size: " + info.Offsets.Count + " is not: " + 2);
				}
				else
				{
					Assert.IsTrue(info.Terms.Count == 1, "info.getTerms() Size: " + info.Terms.Count + " is not: " + 1); //need a test for multiple terms at one pos
					Assert.IsTrue(info.Offsets.Count == 1, "info.getOffsets() Size: " + info.Offsets.Count + " is not: " + 1);
				}
			}
			Assert.IsTrue(BitSetSupport.Cardinality(bits) == numPositions, "Bits are not all on");
		}
    }
TestPositionBasedTermVectorMapper