public virtual void TestGet()
{
BytesRef @ref = new BytesRef();
BytesRef scratch = new BytesRef();
int num = AtLeast(2);
for (int j = 0; j < num; j++)
{
IDictionary<string, int?> strings = new Dictionary<string, int?>();
int uniqueCount = 0;
for (int i = 0; i < 797; i++)
{
string str;
do
{
str = TestUtil.RandomRealisticUnicodeString(Random(), 1000);
} while (str.Length == 0);
@ref.CopyChars(str);
int count = Hash.Size();
int key = Hash.Add(@ref);
if (key >= 0)
{
Assert.IsFalse(strings.ContainsKey(str));
strings[str] = Convert.ToInt32(key);
Assert.AreEqual(uniqueCount, key);
uniqueCount++;
Assert.AreEqual(Hash.Size(), count + 1);
}
else
{
Assert.IsTrue((-key) - 1 < count);
Assert.AreEqual(Hash.Size(), count);
}
}
foreach (KeyValuePair<string, int?> entry in strings)
{
@ref.CopyChars(entry.Key);
Assert.AreEqual(@ref, Hash.Get((int)entry.Value, scratch));
}
Hash.Clear();
Assert.AreEqual(0, Hash.Size());
Hash.Reinit();
}
}