Exemple #1
0
        public void TestDequeueByAccess()
        {
            var test = new LurchTableTest <int, string>(LurchTableOrder.Access);

            Assert.AreEqual(LurchTableOrder.Access, test.Ordering);
            var sample = GetSample();

            foreach (var item in sample)
            {
                test.Add(item.Key, item.Value);
            }

            Array.Reverse(sample);
            foreach (var item in sample)
            {
                Assert.AreEqual(item.Value, test[item.Key]);
            }

            KeyValuePair <int, string> value;

            foreach (var item in sample)
            {
                Assert.IsTrue(test.TryDequeue(out value));
                Assert.AreEqual(item.Key, value.Key);
                Assert.AreEqual(item.Value, value.Value);
            }

            Assert.IsFalse(test.Peek(out value));
            Assert.IsFalse(test.TryDequeue(out value));
        }
Exemple #2
0
        public void TestDequeueByModified()
        {
            var test = new LurchTableTest <int, string>(LurchTableOrder.Modified);

            Assert.AreEqual(LurchTableOrder.Modified, test.Ordering);
            var sample = GetSample();

            foreach (var item in sample)
            {
                test.Add(item.Key, item.Value);
            }

            Array.Reverse(sample);
            for (int i = 0; i < sample.Length; i++)
            {
                var item = new KeyValuePair <int, string>(sample[i].Key, sample[i].Value + "-2");
                test[item.Key] = item.Value;
                sample[i]      = item;
            }

            KeyValuePair <int, string> value;

            foreach (var item in sample)
            {
                Assert.IsTrue(test.Peek(out value));
                Assert.AreEqual(item.Key, value.Key);
                Assert.AreEqual(item.Value, value.Value);
                value = test.Dequeue();
                Assert.AreEqual(item.Key, value.Key);
                Assert.AreEqual(item.Value, value.Value);
            }

            Assert.IsFalse(test.Peek(out value));
            Assert.IsFalse(test.TryDequeue(out value));
        }