public void Foreach_Should_Return_InOrder_MostRecentlyRequested_3()
        {
            var collection = LimitedMemoryCollectionInitializer.Create <string, int>(4);
            var random     = new Random();
            var records    = Enumerable.Range(65, 4)
                             .Select(i => new
            {
                Key   = ((char)i).ToString(),
                Value = random.Next(0, 100)
            })
                             .ToArray();

            var expectedOrder = new[] { records[1], records[3], records[2], records[0] };


            foreach (var record in records)
            {
                collection.Set(record.Key, record.Value);
            }

            collection.Get(records[2].Key);
            collection.Get(records[0].Key);

            int order = collection.Count - 1;

            foreach (var record in collection)
            {
                Assert.AreEqual(record.Key, expectedOrder[order].Key);
                Assert.AreEqual(record.Value, expectedOrder[order].Value);
                order--;
            }
        }
Ejemplo n.º 2
0
 public void TestInit()
 {
     this.collection = LimitedMemoryCollectionInitializer.Create <string, int>(this.Capacity);
 }