Skip to content

Instantly share code, notes, and snippets.

@kkozmic
Created August 4, 2010 12:44
Show Gist options
  • Save kkozmic/508073 to your computer and use it in GitHub Desktop.
Save kkozmic/508073 to your computer and use it in GitHub Desktop.
[Test]
public void Dictionary_enumerates_from_oldest_to_latest()
{
var expected1 = new[] { 1, 2, 4, 3 };
var dictionary1 = new Dictionary<int, object>();
foreach (var key in expected1)
{
dictionary1[key] = new object();
}
var index = 0;
foreach (KeyValuePair<int, object> keyValuePair in dictionary1)
{
Assert.AreEqual(expected1[index], keyValuePair.Key);
index++;
}
var expected2 = new[] { 4, 1, 2, 3 };
var dictionary2 = new Dictionary<int, object>();
foreach (var key in expected2)
{
dictionary2[key] = new object();
}
index = 0;
foreach (KeyValuePair<int, object> keyValuePair in dictionary2)
{
Assert.AreEqual(expected2[index], keyValuePair.Key);
index++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment