Пример #1
0
        [Test] public void Initialization()
        {
            var hashedPriorityQueue1 = new HashedCircularConcurrentQueue <int>(4);

            try
            {
                var hashedPriorityQueue2 = new HashedCircularConcurrentQueue <double>(-5);
            }
            catch (ArgumentException)
            {
                hashedPriorityQueue1.Add(1, 0);

                Assert.IsTrue(hashedPriorityQueue1.Count == 1);
                Assert.IsTrue(hashedPriorityQueue1.Capacity == 4);

                hashedPriorityQueue1.Add(2, 4);

                Assert.IsTrue(hashedPriorityQueue1.Count == 2);
                Assert.IsTrue(hashedPriorityQueue1.Capacity == 5);
            }

            try
            {
                hashedPriorityQueue1.Add(4, -3);
            }
            catch (ArgumentException)
            {
                Assert.IsTrue(hashedPriorityQueue1.Count == 2);
                Assert.IsTrue(hashedPriorityQueue1.Capacity == 5);
            }
        }
Пример #2
0
        /// <summary>
        /// {1, 3, 4, 2}
        /// </summary>
        private HashedCircularConcurrentQueue <int> GetSimpleObject()
        {
            var hashedPriorityQueue = new HashedCircularConcurrentQueue <int>(4);

            hashedPriorityQueue.Add(1, 0);

            hashedPriorityQueue.Add(3, 0);

            hashedPriorityQueue.Add(2, 4);

            hashedPriorityQueue.Add(4, 3);

            return(hashedPriorityQueue);
        }