Esempio n. 1
0
        public void TestDequeueByInsertion()
        {
            var test = new LurchTableTest <int, string>(LurchTableOrder.Insertion);

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

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

            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));
        }
Esempio n. 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));
        }