예제 #1
0
        internal static void RunOutputTest(int sleepms, int max_operations, int operations_until_failure = 0, bool testsuccess = false)
        {
            Form.SetStage(Form.StageEnum.Output);
            Form.mainForm.PageManager.SelectedTab = Form.mainForm.Tab_Output;
            new Thread(() =>
            {
                int currentoperation = 1;
                for (currentoperation = 1; currentoperation <= max_operations; currentoperation++)
                {
                    if (Form.IsClosing)
                    {
                        break;
                    }
                    Form.SetOutputCurrentPercentage(0);
                    int totalpercentage = (100 / max_operations) * (currentoperation - 1);
                    Form.SetOutputTotalPercentage(totalpercentage);
                    if ((operations_until_failure != 0) &&
                        (currentoperation == operations_until_failure))
                    {
                        if (!Form.IsClosing)
                        {
                            Form.Invoke(() => Form.SetStage(Form.StageEnum.Output_Failure));
                        }
                        Program.CreateMessageBox($"Test Operation {currentoperation} ERROR", MessageBoxIcon.Error, MessageBoxButtons.OK);
                        break;
                    }
                    for (int currentpercentage = 0; currentpercentage <= 100; currentpercentage++)
                    {
                        if (Form.IsClosing)
                        {
                            break;
                        }
                        Form.Invoke(() =>
                        {
                            Form.SetOutputCurrentOperation($"Test Operation {currentoperation}", Theme.GetOutputOperationColor());
                            Form.SetOutputCurrentPercentage(currentpercentage);
                            Form.SetOutputTotalPercentage(totalpercentage + (int)(25 * (currentpercentage * 0.01)));
                        });
                        Thread.Sleep(sleepms);
                    }
                }
                if (!Form.IsClosing)
                {
                    Form.Invoke(() => Form.SetStage(Form.StageEnum.Output_Success));
                }
                if ((operations_until_failure == 0) && testsuccess)
                {
                    Program.CreateMessageBox($"Test SUCCESS", MessageBoxIcon.Asterisk, MessageBoxButtons.OK);
                }
                if (!Form.IsClosing)
                {
                    Form.Invoke(() =>
                    {
                        Form.SetStage(Form.StageEnum.Output);
                        Form.SetOutputCurrentPercentage(100);
                        Form.SetOutputTotalPercentage(100);

                        int i = Form.mainForm.Debug_AutomatedState.SelectedIndex;
                        Form.SetStage(Form.StageEnum.Debug);
                        Form.mainForm.Debug_AutomatedState.SelectedIndex = i;
                    });
                }
            }).Start();
        }