Пример #1
0
        public void StressDequeueTestCase()
        {
            /*ParallelTestHelper.Repeat (delegate {
             *      queue = new ConcurrentQueue<int> ();
             *      const int count = 10;
             *      const int threads = 5;
             *      const int delta = 5;
             *
             *      for (int i = 0; i < (count + delta) * threads; i++)
             *              queue.Enqueue (i);
             *
             *      bool state = true;
             *
             *      ParallelTestHelper.ParallelStressTest (queue, (q) => {
             *              int t;
             *              for (int i = 0; i < count; i++)
             *                      state &= queue.TryDequeue (out t);
             *      }, threads);
             *
             *      Assert.IsTrue (state, "#1");
             *      Assert.AreEqual (delta * threads, queue.Count, "#2");
             *
             *      string actual = string.Empty;
             *      int temp;
             *      while (queue.TryDequeue (out temp)) {
             *              actual += temp;
             *      }
             *      string expected = Enumerable.Range (count * threads, delta * threads)
             *              .Aggregate (string.Empty, (acc, v) => acc + v);
             *
             *      Assert.AreEqual (expected, actual, "#3");
             * });*/

            CollectionStressTestHelper.RemoveStressTest(new ConcurrentQueue <int> (), CheckOrderingType.InOrder);
        }
Пример #2
0
        public void StressEnqueueTestCase()
        {
            /*ParallelTestHelper.Repeat (delegate {
             *      queue = new ConcurrentQueue<int> ();
             *      int amount = -1;
             *      const int count = 10;
             *      const int threads = 5;
             *
             *      ParallelTestHelper.ParallelStressTest (queue, (q) => {
             *              int t = Interlocked.Increment (ref amount);
             *              for (int i = 0; i < count; i++)
             *                      queue.Enqueue (t);
             *      }, threads);
             *
             *      Assert.AreEqual (threads * count, queue.Count, "#-1");
             *      int[] values = new int[threads];
             *      int temp;
             *      while (queue.TryDequeue (out temp)) {
             *              values[temp]++;
             *      }
             *
             *      for (int i = 0; i < threads; i++)
             *              Assert.AreEqual (count, values[i], "#" + i);
             * });*/

            CollectionStressTestHelper.AddStressTest(new ConcurrentQueue <int> ());
        }
Пример #3
0
        public void StressPopTestCase()
        {
            /*ParallelTestHelper.Repeat (delegate {
             *      stack = new ConcurrentStack<int> ();
             *      const int count = 10;
             *      const int threads = 5;
             *      const int delta = 5;
             *
             *      for (int i = 0; i < (count + delta) * threads; i++)
             *              stack.Push (i);
             *
             *      bool state = true;
             *
             *      ParallelTestHelper.ParallelStressTest (stack, (q) => {
             *              int t;
             *              for (int i = 0; i < count; i++)
             *                      state &= stack.TryPop (out t);
             *      }, threads);
             *
             *      Assert.IsTrue (state, "#1");
             *      Assert.AreEqual (delta * threads, stack.Count, "#2");
             *
             *      string actual = string.Empty;
             *      int temp;
             *      while (stack.TryPop (out temp)) {
             *              actual += temp;
             *      }
             *      string expected = Enumerable.Range (0, delta * threads).Reverse()
             *              .Aggregate (string.Empty, (acc, v) => acc + v);
             *
             *      Assert.AreEqual (expected, actual, "#3");
             * });*/

            CollectionStressTestHelper.RemoveStressTest(new ConcurrentStack <int> (), CheckOrderingType.Reversed);
        }
Пример #4
0
 public void RemoveStressTest()
 {
     CollectionStressTestHelper.RemoveStressTest(bag, CheckOrderingType.DontCare);
 }
Пример #5
0
 public void AddStressTest()
 {
     CollectionStressTestHelper.AddStressTest(bag);
 }