Exemple #1
0
        private static void AssertQueueTaskCount(int expectedCount, OperationQueueStub queue)
        {
#if DotNetCoreClr
            // asnegi : RDBug 10087224 : Need to find why we need this higher timeout.
            int timeout = 15;
#else
            int timeout = 1;
#endif
            Assert.IsTrue(MiscUtility.WaitUntil(() => queue.DrainTasks.Count == expectedCount, TimeSpan.FromSeconds(timeout), 50));
        }
Exemple #2
0
        public void OperationQueueTest_ParallelDrain()
        {
            var operations = new List <IOperation> {
                new OperationStub(), new OperationStub(), null
            };

            var opList = new OperationList();

            foreach (var item in operations)
            {
                opList.AddOperation(item);
            }

            var processor = new TrackingOperationProcessor();

            var opQueue = new OperationFetcher.OperationQueue(() => opList, new OperationProcessorInfo
            {
                SupportsConcurrentProcessing = true,
                Callback = processor.Process
            });

            var task = opQueue.DrainAsync();

            for (int i = 0; i < operations.Count; i++)
            {
                // we are processing asynchronously
                // tell the list to provide an operation to the queue
                opList.CompleteOperation();

                if (i == operations.Count - 1)
                {
                    // the last null is not received
                    continue;
                }

                // the operation has been sent to the callback
                // the callback has not completed the task
                // the queue will continue (this loop will run)
                Assert.IsTrue(MiscUtility.WaitUntil(() => processor.GetOperations().Count == i + 1, TimeSpan.FromSeconds(1), 50));
                Assert.AreSame(operations[i], processor.GetOperations()[i].Item2);
            }

            // the task should be complete
            task.AssertWaitCompletes(500);
        }
Exemple #3
0
 private void WaitUntilHelper(Func <bool> func)
 {
     Assert.IsTrue(MiscUtility.WaitUntil(func, TimeSpan.FromSeconds(15), 50), "WaitUntilHelper");
 }