示例#1
0
        public void FormProcessDisplay()
        {
            // Log
            using (var frm = new FormProcessDisplay("Test Logger", true, UnitTestInitializeCsv.Token))
            {
                frm.ShowInTaskbar = false;
                frm.Show();
                frm.Maximum = 100;
                var sentTime = new TimeSpan(0);
                frm.ProgressTime += (sender, time) => { sentTime = time.EstimatedTimeRemaining; };
                var end  = 50;
                var step = 5;
                var wait = .1;
                for (var c = 0; c < end && !frm.CancellationToken.IsCancellationRequested; c += step)
                {
                    frm.SetProcess($"This is a text\nLine {c}", c, true);
                    UnitTestWinFormHelper.WaitSomeTime(wait, UnitTestInitializeCsv.Token);
                }

                // Left should be roughly .1 * 50 = 5 seconds
                Assert.IsTrue(
                    (wait * (end / step)) - .5 < sentTime.TotalSeconds && sentTime.TotalSeconds < (wait * (end / step)) + .5,
                    $"Estimated time should be roughly {wait * (end / step)}s but is {sentTime.TotalSeconds}");
                frm.Close();
            }

            // marquee
            using (var frm = new FormProcessDisplay("Test Marquee", false, UnitTestInitializeCsv.Token))
            {
                frm.ShowInTaskbar = false;
                frm.Show();
                frm.Maximum = 0;
                for (var c = 0; c < 100 && !frm.CancellationToken.IsCancellationRequested; c += 5)
                {
                    frm.SetProcess($"This is a text\nLine {c}", c, true);
                    UnitTestWinFormHelper.WaitSomeTime(.1, frm.CancellationToken);
                }

                frm.Close();
            }

            // NoLog
            using (var frm = new FormProcessDisplay("Test", false, UnitTestInitializeCsv.Token))
            {
                frm.ShowInTaskbar = false;
                frm.Show();
                frm.Maximum = 100;
                for (var c = 0; c < 102 && !frm.CancellationToken.IsCancellationRequested; c += 4)
                {
                    frm.SetProcess($"This is a text\nLine {c}", c, true);
                    UnitTestWinFormHelper.WaitSomeTime(.1, frm.CancellationToken);
                }

                frm.Close();
            }
        }
 public void FrozenColumns()
 {
     using (var dt = UnitTestStatic.GetDataTable())
         using (var filteredDataGridView = new FilteredDataGridView())
         {
             filteredDataGridView.DataSource    = dt;
             filteredDataGridView.FrozenColumns = 2;
             UnitTestWinFormHelper.WaitSomeTime(.2, UnitTestInitializeCsv.Token);
         }
 }
示例#3
0
 public void FormProcessCancel()
 {
     using (var frm = new FormProcessDisplay("Test Logger", true, UnitTestInitializeCsv.Token))
     {
         frm.ShowInTaskbar = true;
         frm.Show();
         UnitTestWinFormHelper.WaitSomeTime(.2, UnitTestInitializeCsv.Token);
         frm.Close();
     }
 }
 public void HighlightText()
 {
     using (var dt = UnitTestStatic.GetDataTable())
         using (var filteredDataGridView = new FilteredDataGridView())
         {
             filteredDataGridView.DataSource    = dt;
             filteredDataGridView.HighlightText = "ag";
             UnitTestWinFormHelper.WaitSomeTime(.2, UnitTestInitializeCsv.Token);
             Assert.AreEqual("", filteredDataGridView.CurrentFilter);
         }
 }