示例#1
0
        public static void ManualStepWinForm(this ScenarioContext scenarioContext)
        {
            string disablePopup = Environment.GetEnvironmentVariable(DISABLE_POPUP_KEY);

            if (disablePopup != null && disablePopup.Equals("true", StringComparison.InvariantCultureIgnoreCase))
            {
                Assert.Inconclusive("Manual steps are disabled on this machine");
            }

            StringBuilder messageBoxText = new StringBuilder();

            messageBoxText.Append("Scenario: ");
            messageBoxText.AppendLine(scenarioContext.ScenarioInfo.Title);
            messageBoxText.AppendLine();

            // Because the previously appended lines
            int headerLineCount = messageBoxText.ToString().Count(c => c == '\n');

            int line = GetCurrentPositionText(messageBoxText) + headerLineCount;
            var form = new ManualStepForm
            {
                ManualStepText = messageBoxText.ToString(),
                CurrentLine    = line
            };

            form.ShowDialog();

            var result = form.DialogResult;

            switch (result)
            {
            case DialogResult.Yes:
                return;

            case DialogResult.No:
                Assert.Fail("Manual step failed");
                break;

            default:
                Assert.Inconclusive("Manual step cancelled");
                break;
            }
        }
        public static void ManualStepWinForm(this ScenarioContext scenarioContext)
        {
            string disablePopup = Environment.GetEnvironmentVariable(DISABLE_POPUP_KEY);
            if (disablePopup != null && disablePopup.Equals("true", StringComparison.InvariantCultureIgnoreCase))
                Assert.Inconclusive("Manual steps are disabled on this machine");

            StringBuilder messageBoxText = new StringBuilder();
            messageBoxText.Append("Scenario: ");
            messageBoxText.AppendLine(scenarioContext.ScenarioInfo.Title);
            messageBoxText.AppendLine();

            // Because the previously appended lines
            int headerLineCount = messageBoxText.ToString().Count(c => c == '\n');

            int line = GetCurrentPositionText(messageBoxText) + headerLineCount;
            var form = new ManualStepForm
                           {
                               ManualStepText = messageBoxText.ToString(),
                               CurrentLine = line
                           };

            form.ShowDialog();

            var result = form.DialogResult;

            switch (result)
            {
                case DialogResult.Yes:
                    return;
                case DialogResult.No:
                    Assert.Fail("Manual step failed");
                    break;
                default:
                    Assert.Inconclusive("Manual step cancelled");
                    break;
            }
        }