Пример #1
0
        public void BacgroundTransferingWorksNonOrdBcg()
        {
            MemoryQueue <int> high = new MemoryQueue <int>(10);
            MemoryQueue <int> low  = new MemoryQueue <int>(10);

            high.Add(1);
            while (low.TryAdd(low.Count + 2))
            {
                ;
            }

            using (var inst = new LevelingQueue <int>(high, low, LevelingQueueAddingMode.PreferLiveData, true))
            {
                Assert.AreEqual(1, inst.Take());

                TimingAssert.AreEqual(10000, 10, () => high.Count);
                Assert.AreEqual(0, low.Count);

                int item     = 0;
                int expected = 2;
                while (inst.TryTake(out item))
                {
                    Assert.AreEqual(expected++, item);
                }
            }
        }