コード例 #1
0
        public void TestUnicodeRanges(UnicodeRange range)
        {
            // ReSharper disable AccessToDisposedClosure
            using (var form = new UnicodeTestForm
            {
                Expected = range.Characters
            })
            {
                var ready    = false;
                var formTask = Task.Factory.StartNew(
                    () =>
                {
                    form.Shown += (x, y) => ready = true;
                    form.ShowDialog();
                }, TaskCreationOptions.LongRunning);

                var simTask = Task.Factory.StartNew(
                    () =>
                {
                    while (!ready)
                    {
                        Thread.Sleep(250);
                    }
                    var sim = new InputSimulator();
                    sim.Keyboard.TextEntry(range.Characters);
                    while (form.Recieved != form.Expected)
                    {
                        Thread.Sleep(500);
                    }
                    form.Close();
                }, TaskCreationOptions.LongRunning);

                Task.WaitAll(new[] { formTask, simTask }, TimeSpan.FromSeconds(60));
                Assert.That(form.Recieved, Is.EqualTo(form.Expected));
            }
            // ReSharper restore AccessToDisposedClosure
        }
コード例 #2
0
        public void TestUnicodeRanges(UnicodeRange range)
        {
            // ReSharper disable AccessToDisposedClosure
            using (var form = new UnicodeTestForm
                                  {
                                      Expected = range.Characters
                                  })
            {
                var ready = false;
                var formTask = Task.Factory.StartNew(
                    () =>
                        {
                            form.Shown += (x, y) => ready = true;
                            form.ShowDialog();
                        }, TaskCreationOptions.LongRunning);

                var simTask = Task.Factory.StartNew(
                    () =>
                        {
                            while (!ready)
                            {
                                Thread.Sleep(250);
                            }
                            var sim = new InputSimulator();
                            sim.Keyboard.TextEntry(range.Characters);
                            while (form.Recieved != form.Expected)
                            {
                                Thread.Sleep(500);
                            }
                            form.Close();
                        }, TaskCreationOptions.LongRunning);

                Task.WaitAll(new[] {formTask, simTask}, TimeSpan.FromSeconds(60));
                Assert.That(form.Recieved, Is.EqualTo(form.Expected));
            }
            // ReSharper restore AccessToDisposedClosure
        }
コード例 #3
0
        public void TestUnicodeRanges(UnicodeRange range)
        {
            //Need to retest Thai, CJK Unified Ideo Extension A&B

            // ReSharper disable AccessToDisposedClosure

            var form = default(UnicodeTestForm);

            var FormTask = Task.Factory.StartNew(() => {
                using (form = new UnicodeTestForm(range.Name, range.Characters)) {
                    form.ShowDialog();
                }
            }, TaskCreationOptions.LongRunning);


            var Last = "";

            var simTask = Task.Factory.StartNew(
                async() => {
                while (form?.Ready != true)
                {
                    Thread.Sleep(250);
                }

                form.BringToForeground();

                var Delay = 10;

                var Chars = range.Characters;


                var Sim = EventBuilder.Create()
                          .Click(Chars)
                ;

                await Sim.Invoke();


                var MaxDelay      = 5000;
                var KeepComparing = true;
                while (form.Recieved != form.Expected && KeepComparing)
                {
                    Last = form.Recieved;
                    for (int i = 0; i < MaxDelay / Delay; i++)
                    {
                        if (Last == form.Recieved)
                        {
                            Thread.Sleep(Delay);
                        }
                        else
                        {
                            KeepComparing = false;
                            break;
                        }
                    }
                }

                form.Invoke(new Action(() => {
                    form.Close();
                }));
            }, TaskCreationOptions.LongRunning);

            Task.WaitAll(new[] { FormTask, simTask });

            Assert.That(form.Recieved, Is.EqualTo(form.Expected));

            // ReSharper restore AccessToDisposedClosure
        }