private void AssertListState(LruList<string, string> lruList, params LruListItem<string, string>[] items)
{
if (items.Length == 0)
{
Assert.IsNull(lruList.Head);
Assert.IsNull(lruList.Tail);
}
else
{
// check references on ends
Assert.IsNull(lruList.Head.Previous);
Assert.IsNull(lruList.Tail.Next);
// make sure head and tail are correct
Assert.AreEqual(items[0], lruList.Head);
Assert.AreEqual(items[items.Length - 1], lruList.Tail);
// make sure Next references are in the expected order
for (int i = 0; i < items.Length - 1; i++)
{
Assert.AreEqual(items[i].Next, items[i + 1]);
}
// make sure Previous references are in the expected order
for (int i = items.Length - 1; i > 0; i--)
{
Assert.AreEqual(items[i].Previous, items[i - 1]);
}
}
}