Exemplo n.º 1
0
        public void TestDequeue()
        {
            var dictionary = new ConcurrentMultiValueDictionary <int, string>();

            dictionary.Enqueue(1, "a");
            dictionary.Enqueue(1, "b");
            dictionary.Enqueue(1, "c");

            String value;

            Assert.AreEqual(dictionary.GetValues(1).Count, 3);

            Assert.IsTrue(dictionary.TryDequeue(1, out value));
            Assert.AreEqual(value, "a");

            Assert.AreEqual(dictionary.GetValues(1).Count, 2);

            Assert.IsTrue(dictionary.TryDequeue(1, out value));
            Assert.AreEqual(value, "b");

            Assert.AreEqual(dictionary.GetValues(1).Count, 1);

            Assert.IsTrue(dictionary.TryDequeue(1, out value));
            Assert.AreEqual(value, "c");

            Assert.AreEqual(dictionary.GetValues(1).Count, 0);

            Assert.IsFalse(dictionary.TryDequeue(1, out value));
            Assert.IsNull(value);

            Assert.IsFalse(dictionary.TryDequeue(99, out value));
            Assert.IsNull(value);
        }
        public void TestDequeue()
        {
            var dictionary = new ConcurrentMultiValueDictionary<int, string>();

            dictionary.Enqueue(1, "a");
            dictionary.Enqueue(1, "b");
            dictionary.Enqueue(1, "c");

            String value;

            Assert.AreEqual(dictionary.GetValues(1).Count, 3);

            Assert.IsTrue(dictionary.TryDequeue(1, out value));
            Assert.AreEqual(value, "a");

            Assert.AreEqual(dictionary.GetValues(1).Count, 2);

            Assert.IsTrue(dictionary.TryDequeue(1, out value));
            Assert.AreEqual(value, "b");

            Assert.AreEqual(dictionary.GetValues(1).Count, 1);

            Assert.IsTrue(dictionary.TryDequeue(1, out value));
            Assert.AreEqual(value, "c");

            Assert.AreEqual(dictionary.GetValues(1).Count, 0);

            Assert.IsFalse(dictionary.TryDequeue(1, out value));
            Assert.IsNull(value);

            Assert.IsFalse(dictionary.TryDequeue(99, out value));
            Assert.IsNull(value);
        }
Exemplo n.º 3
0
        public void TestEmpty()
        {
            var    dictionary = new ConcurrentMultiValueDictionary <int, string>();
            String value;

            Assert.IsFalse(dictionary.TryDequeue(1, out value));
        }
 public void TestEmpty()
 {
     var dictionary = new ConcurrentMultiValueDictionary<int, string>();
     String value;
     Assert.IsFalse(dictionary.TryDequeue(1, out value));
 }