Пример #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Code to start the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif

            // Perform any additional setup after loading the view, typically from a nib.
            BlockButton.AccessibilityIdentifier = "myButton";
            BlockButton.TouchUpInside          += async delegate
            {
                _testBlocking = new TestThreads();
                await _testBlocking.RequestAccessAsync();

                Console.WriteLine("1");
            };

            PoolButton.TouchUpInside += async delegate
            {
                _testBlocking = new TestThreads();
                await _testBlocking.CallPool1Async();
            };

            ParallelButton.TouchUpInside += delegate
            {
                _testBlocking = new TestThreads();
                _testBlocking.CallParallel();
            };
        }
Пример #2
0
 public void DoTest()
 {
     _firstTestCounter = new CounterContainer();
     _errorTestCounter = new CounterContainer();
     var tt = new TestThreads(false, FirstTest, 1);
     tt.RunParallel(100);
     while (_firstTestCounter.Counter < 100)
     {
         Thread.Sleep(10);
     }
     Assert.AreEqual(100, _firstTestCounter.Counter);
     tt.Terminate();
 }
Пример #3
0
 public void DoTestMultiWithPar()
 {
     _firstTestCounter = new CounterContainer();
     _errorTestCounter = new CounterContainer();
     var tt = new TestThreads(false, SecondTest, 10);
     tt.RunParallel(1000, 2);
     while (_firstTestCounter.Counter < 1000 && _errorTestCounter.Counter==0)
     {
         Thread.Sleep(10);
     }
     Assert.AreEqual(0, _errorTestCounter.Counter);
     Assert.AreEqual(1000, _firstTestCounter.Counter);
     tt.Terminate();
 }
Пример #4
0
 public void DoTestMulti()
 {
     const int iterations = 10000;
     _firstTestCounter = new CounterContainer();
     _errorTestCounter = new CounterContainer();
     var tt = new TestThreads(false, FirstTest, 100);
     tt.RunParallel(iterations);
     while (_firstTestCounter.Counter < iterations)
     {
         Thread.Sleep(10);
     }
     Assert.AreEqual(iterations, _firstTestCounter.Counter);
     tt.Terminate();
 }
Пример #5
0
        public void DoTestMultiWithParAndReadingThread()
        {
            const int iterations = 10000;
            var lfq = new LockFreeQueue<int>();
            _sendCounter = new CounterContainer();
            _firstTestCounter = new CounterContainer();
            _errorTestCounter = new CounterContainer();
            var ttr = new TestThreads(false, ThirdTestReader, 5);
            ttr.RunParallel(iterations, lfq, true);

            var tts = new TestThreads(false, ThirdTestSender, 5);
            tts.RunParallel(iterations, lfq);
            while (_firstTestCounter.Counter < (iterations-1) && _errorTestCounter.Counter == 0)
            {
                Thread.Sleep(10);
            }
            Assert.AreEqual(0, _errorTestCounter.Counter);
            Assert.AreEqual(iterations, _sendCounter.Counter);
            Assert.AreEqual(iterations-1, _firstTestCounter.Counter);
            tts.Terminate();
            ttr.Terminate();
        }
Пример #6
0
 private void ThirdTestSender(object sender, TestThreads.TestThreadsEventArgs args)
 {
     var lfq = (LockFreeQueue<int>)args.Param;
     _sendCounter.Increment();
     lfq.Enqueue(args.CurrentCycle);
 }
Пример #7
0
 private void ThirdTestReader(object sender, TestThreads.TestThreadsEventArgs args)
 {
     var lfq = (LockFreeQueue<int>)args.Param;
     while (lfq.DequeueSingle()!=0)
     {
         _firstTestCounter.Increment();
     }
 }
Пример #8
0
 private void SecondTest(object sender, TestThreads.TestThreadsEventArgs args)
 {
     if (args.Param is int)
     {
         if ((int)args.Param == 2)
         {
             _firstTestCounter.Increment();
         }
     }
     else
     {
         _errorTestCounter.Increment();
     }
 }
Пример #9
0
 private void FirstTest(object sender, TestThreads.TestThreadsEventArgs args)
 {
     _firstTestCounter.Increment();
 }