コード例 #1
0
        public void ProcessLine(string line)
        {
            // line = line.Trim();
            line = line.TrimStart();

            if (line.Length > 0 && line[0] == '-')
            {
                this.ExecuteCommand(line);
                return;
            }

            // adds Tags
            if (line.Length > 0 && line.TrimStart()[0] == '@')
            {
                Tags.Add(line.Trim().Substring(1));
                return;
            }

            ScenarioBuffer.AppendLine(line);
        }
コード例 #2
0
        public object ExecuteCommand(string command, params object[] parameters)
        {
            switch (command)
            {
            case Commands.ClearSteps:
                this.ScenarioBuffer.Clear();
                break;

            case Commands.SetScenarioContextValue:
                this.Runner.SetValueToScenarioContext((string)parameters[0], (string)parameters[1]);
                break;

            case Commands.GetScenarioContextValue:
                return(this.Runner.GetValueFromScenarioContext((string)parameters[0]));

                break;

            case Commands.ClearTags:
                this.Tags.Clear();
                this.Runner.InitAnonymousFeature(Tags);
                this.logger.Trace("Tags for anonymous scenario was cleared");
                break;

            case Commands.AutoClear:
                this.autoClearIsEnabled = (bool)parameters[0];
                this.logger.Trace("auto clear was change to " + autoClearIsEnabled);
                break;

            case Commands.Clear:
                Tags.Clear();
                logger.Trace("Tags for anonymous scenario was cleared");
                this.ClearSteps();
                logger.Trace("Anonymous scenario was cleared");
                break;

            case Commands.RunScenario:
                Runner.RunScenario((string)parameters[2], (string)parameters[1], (string)parameters[0]);
                break;

            case Commands.InitScenario:
                if (!parameters.Any())
                {
                    Runner.InitAnonymousScenario();
                }
                else
                {
                    Runner.InitScenario((string)parameters[0]);
                }

                break;

            case Commands.InitFeature:
                if (!parameters.Any())
                {
                    Runner.InitAnonymousFeature(Tags);
                }
                else
                {
                    Runner.InitFeature((string)parameters[0]);
                }

                break;

            case Commands.BeforeFeature:
                Runner.BeforeFeature();
                break;

            case Commands.BeforeScenario:
                Runner.BeforeScenario();
                break;

            case Commands.Run:
                Runner.UseLastOrInitAnonymousFeature(Tags);
                Runner.RunSteps(ScenarioBuffer.ToString());
                if (autoClearIsEnabled)
                {
                    ClearSteps();
                }

                break;

            case Commands.Release:
                Release();
                break;

            case Commands.SetNewChrome:
                Runner.SetNewChrome();
                break;

            case Commands.Load:
                Load((string)(parameters.Any() ? parameters[0] : null));
                break;

            case Commands.Rebuild:
                Release();
                if (Build(this.logger))
                {
                    this.logger.Success("Build succeed");
                    Load();
                    return(true);
                }
                else
                {
                    this.logger.Error("Build failed");
                    return(false);
                }
                break;

            case Commands.Build:
                if (Build(this.logger))
                {
                    this.logger.Success("Build succeed");
                    return(true);
                }
                else
                {
                    this.logger.Error("Build failed");
                    return(false);
                }
                break;

            default:
                logger.Trace("Unknown command: {0}", command);
                break;
            }
            return(null);
        }