private static StepArgument CreatePickleArguments(StepArgument argument, Dictionary <string, string> parameters)
 {
     if (argument == null)
     {
         return(null);
     }
     if (argument is DataTable)
     {
         DataTable t       = (DataTable)argument;
         var       rows    = t.Rows;
         var       newRows = new List <TableRow>(rows.Count());
         foreach (var row in rows)
         {
             var cells    = row.Cells;
             var newCells = new List <TableCell>();
             foreach (var cell in cells)
             {
                 newCells.Add(new TableCell(cell.Location, Interpolate(cell.Value, parameters)));
             }
             newRows.Add(new TableRow(row.Location, newCells.ToArray()));
         }
         return(new DataTable(newRows.ToArray()));
     }
     if (argument is DocString)
     {
         DocString ds = (DocString)argument;
         return(new DocString(
                    ds.Location,
                    ds.ContentType,
                    Interpolate(ds.Content, parameters)
                    ));
     }
     throw new InvalidOperationException("Unexpected argument type: " + argument);
 }
Пример #2
0
 public Step(Location location, string keyword, string text, StepArgument argument)
 {
     Location = location;
     Keyword = keyword;
     Text = text;
     Argument = argument;
 }
 public ParameterMatch(MatchedStepTextParameter[] stepTextParameters, StepArgument stepArgument, string[] parameterTypes, string error = null)
 {
     StepTextParameters = stepTextParameters ?? throw new ArgumentNullException(nameof(stepTextParameters));
     StepArgument       = stepArgument;
     ParameterTypes     = parameterTypes ?? throw new ArgumentNullException(nameof(parameterTypes));
     Error = error;
 }
Пример #4
0
 public Step(Location location, string keyword, string text, StepArgument argument)
 {
     Location = location;
     Keyword  = keyword;
     Text     = text;
     Argument = argument;
 }
Пример #5
0
 public ReportStep(Location location, string keyword, string text, StepArgument argument, Parser.StepKeyword stepKeyword, Parser.ScenarioBlock scenarioBlock)
 {
     //Location = location;
     Keyword = keyword;
     Text = text;
     Argument = argument;
     ScenarioBlock = scenarioBlock;
     StepKeyword = stepKeyword;
 }
Пример #6
0
 public ReportStep(Location location, string keyword, string text, StepArgument argument, Parser.StepKeyword stepKeyword, Parser.ScenarioBlock scenarioBlock)
 {
     //Location = location;
     Keyword       = keyword;
     Text          = text;
     Argument      = argument;
     ScenarioBlock = scenarioBlock;
     StepKeyword   = stepKeyword;
 }
Пример #7
0
        public override void DigestScenarioStepValues(string[] argumentValues, StepArgument gherkinStepArgument)
        {
            if (argumentValues.Length <= _index)
            {
                throw new InvalidOperationException($"Cannot extract value for parameter `{_parameterInfo.Name}` at index {_index}; only {argumentValues.Length} parameters were provided. Method `{_parameterInfo.Member.Name}`.");
            }

            Value = Convert.ChangeType(argumentValues[_index], _parameterInfo.ParameterType);
        }
        public override void DigestScenarioStepValues(string[] argumentValues, StepArgument gherkinStepArgument)
        {
            if (!(gherkinStepArgument is DataTable dataTable))
            {
                throw new InvalidOperationException("DataTable cannot be extracted from Gherkin.");
            }

            Value = dataTable;
        }
Пример #9
0
        private static string CreateDataTable(StepArgument stepArgument, bool isScenarioOutline)
        {
            if (!(stepArgument is DataTable))
            {
                return("");
            }

            var          dataTable                  = (DataTable)stepArgument;
            var          htmlBulder                 = new StringBuilder();
            const string TABLE_START_ELEMENT        = @"<Table style='border:1px;'>";
            const string TABLE_END_ELEMENT          = "</Table>";
            const string TABLE_ROW_START_ELEMENT    = "<Tr>";
            const string TABLE_ROW_END_ELEMENT      = "</Tr>";
            const string TABLE_HEADER_START_ELEMENT = "<Th>";
            const string TABLE_HEADER_END_ELEMENT   = "</Th>";
            const string TABLE_COLUMN_START_ELEMENT = "<Td>";
            const string TABLE_COLUMN_END_ELEMENT   = "</Td>";
            const string TAG_BOLD_START             = "<b>";
            const string TAG_BOLD_END               = "</b>";

            htmlBulder.Append(TABLE_START_ELEMENT);
            var rowList = dataTable.Rows.ToList();

            htmlBulder.Append(TABLE_ROW_START_ELEMENT);
            foreach (var tableCell in rowList[0].Cells)
            {
                htmlBulder.Append($"{TAG_BOLD_START}{TABLE_HEADER_START_ELEMENT}{tableCell.Value}{TABLE_HEADER_END_ELEMENT}{TAG_BOLD_END}");
            }

            htmlBulder.Append(TABLE_ROW_END_ELEMENT);

            for (var rowIndex = 1; rowIndex < rowList.Count; rowIndex++)
            {
                var dataTableRow = rowList[rowIndex];
                htmlBulder.Append(TABLE_ROW_START_ELEMENT);
                htmlBulder = dataTableRow.Cells.Aggregate(
                    htmlBulder,
                    (current, tableCell) =>
                {
                    var cellValue = tableCell.Value;
                    if (isScenarioOutline)
                    {
                        cellValue = TransformParameters(cellValue);
                    }

                    cellValue = HttpUtility.HtmlEncode(cellValue);
                    return(htmlBulder.Append($"{TABLE_COLUMN_START_ELEMENT}{cellValue}{TABLE_COLUMN_END_ELEMENT}"));
                });
                htmlBulder.Append(TABLE_ROW_END_ELEMENT);
            }

            htmlBulder.Append(TABLE_END_ELEMENT);
            return(htmlBulder.ToString());
        }
Пример #10
0
        protected virtual List <Argument> CreatePickleArguments(StepArgument argument, IEnumerable <TableCell> variableCells, IEnumerable <TableCell> valueCells)
        {
            var result = new List <Argument>();

            if (argument == null)
            {
                return(result);
            }
            if (argument is DataTable)
            {
                DataTable t       = (DataTable)argument;
                var       rows    = t.Rows;
                var       newRows = new List <PickleRow>(rows.Count());
                foreach (var row in rows)
                {
                    var cells    = row.Cells;
                    var newCells = new List <PickleCell>();
                    foreach (var cell in cells)
                    {
                        newCells.Add(
                            new PickleCell(
                                PickleLocation(cell.Location),
                                Interpolate(cell.Value, variableCells, valueCells)
                                )
                            );
                    }
                    newRows.Add(new PickleRow(newCells));
                }
                result.Add(new PickleTable(newRows));
            }
            else if (argument is DocString)
            {
                DocString ds = (DocString)argument;
                result.Add(
                    new PickleString(
                        PickleLocation(ds.Location),
                        Interpolate(ds.Content, variableCells, valueCells),
                        ds.ContentType == null ? null : Interpolate(ds.ContentType, variableCells, valueCells)
                        )
                    );
            }
            else
            {
                throw new InvalidOperationException("Unexpected argument type: " + argument);
            }
            return(result);
        }
Пример #11
0
        private ReportStepArgument ConvertArgument(StepArgument argument)
        {
            if (argument == null)
            {
                return(null);
            }

            if (argument is DocString)
            {
                DocString arg = (DocString)argument;

                return(new DocStringArgument(arg.ContentType, arg.Content));
            }

            if (argument is DataTable)
            {
                DataTable arg = (DataTable)argument;

                return(new TableArgument(arg.Rows.Select(r => new ReportTableRow(r.Cells.Select(c => new ReportTableCell(c.Value)).ToList())).ToList()));
            }

            return(null);
        }
Пример #12
0
 internal PcapUnpackPreprocessingStep(
     Preprocessing.IStepsFactory preprocessingStepsFactory,
     ITShark tshark,
     PreprocessingStepParams srcFile,
     PreprocessingStepParams[] keyFiles)
 {
     this.preprocessingStepsFactory = preprocessingStepsFactory;
     this.sourceFile = srcFile;
     this.tshark     = tshark;
     if (keyFiles != null)
     {
         this.getKeyFiles = (IPreprocessingStepCallback _) => Task.FromResult(keyFiles);
     }
     else if (srcFile?.Argument != null)
     {
         this.getKeyFiles = (IPreprocessingStepCallback callback) =>
                            Task.WhenAll(StepArgument.Parse(srcFile.Argument).Select(history => callback.ReplayHistory(history)));
     }
     else
     {
         this.getKeyFiles = (IPreprocessingStepCallback _) => Task.FromResult(new PreprocessingStepParams[0]);
     }
 }
 public DeveroomGherkinStep(Location location, string keyword, string text, StepArgument argument, StepKeyword stepKeyword, ScenarioBlock scenarioBlock) : base(location, keyword, text, argument)
 {
     StepKeyword   = stepKeyword;
     ScenarioBlock = scenarioBlock;
 }
Пример #14
0
 protected virtual Step CreateStep(Ast.Location location, string keyword, string text, StepArgument argument, AstNode node)
 {
     return(new Step(location, keyword, text, argument));
 }
Пример #15
0
 public abstract void DigestScenarioStepValues(string[] argumentValues, StepArgument gherkinStepArgument);
Пример #16
0
        async Task <PreprocessingStepParams> ExecuteInternal(IPreprocessingStepCallback callback, PreprocessingStepParams[] keyFiles)
        {
            await callback.BecomeLongRunning();

            callback.TempFilesCleanupList.Add(sourceFile.Location);
            callback.SetStepDescription("scanning...");

            string tmpFileName = callback.TempFilesManager.GenerateNewName();

            await Converters.PcapToPdmp(sourceFile.Location, keyFiles.Select(f => f.Location).ToArray(),
                                        tmpFileName, tshark, callback.Cancellation, callback.SetStepDescription, callback.Trace);

            return(new PreprocessingStepParams(
                       tmpFileName,
                       $"{sourceFile.FullPath}\\as_pdml",
                       sourceFile.PreprocessingHistory.Add(new PreprocessingHistoryItem(stepName, StepArgument.ToString(keyFiles))),
                       $"{sourceFile.FullPath} (converted to PDML)"
                       ));
        }
        private ReportStepArgument ConvertArgument(StepArgument argument)
        {
            if (argument == null)
                return null;

            if (argument is DocString)
            {
                DocString arg = (DocString) argument;

                return new DocStringArgument(arg.ContentType, arg.Content);
            }

            if (argument is DataTable)
            {
                DataTable arg = (DataTable) argument;

                return new TableArgument(arg.Rows.Select(r => new ReportTableRow(r.Cells.Select(c => new ReportTableCell(c.Value)).ToList())).ToList());
            }

            return null;
        }
Пример #18
0
 private SpecFlowStep Clone(SpecFlowStep step, StepArgument stepArgument)
 {
     return(new SpecFlowStep(step.Location, step.Keyword, step.Text, stepArgument, step.StepKeyword, step.ScenarioBlock));
 }
Пример #19
0
            protected override Step CreateStep(Location location, string keyword, string text, StepArgument argument, AstNode node)
            {
                var token       = node.GetToken(TokenType.StepLine);
                var stepKeyword = GetStepKeyword(token.MatchedGherkinDialect, keyword);

                scenarioBlock = stepKeyword.ToScenarioBlock() ?? scenarioBlock;

                return(new SpecFlowStep(location, keyword, text, argument, stepKeyword, scenarioBlock));
            }
Пример #20
0
 public SpecFlowStep(Location location, string keyword, string text, StepArgument argument, StepKeyword stepKeyword, ScenarioBlock scenarioBlock) : base(location, keyword, text, argument)
 {
     StepKeyword = stepKeyword;
     ScenarioBlock = scenarioBlock;
 }
Пример #21
0
        protected virtual List <Argument> CreatePickleArguments(StepArgument argument)
        {
            var noCells = Enumerable.Empty <TableCell>();

            return(CreatePickleArguments(argument, noCells, noCells));
        }
 private SpecFlowStep Clone(SpecFlowStep step, StepArgument stepArgument)
 {
     return new SpecFlowStep(step.Location, step.Keyword, step.Text, stepArgument, step.StepKeyword, step.ScenarioBlock);
 }
 protected Step CreateStep(StepKeyword stepKeyword = StepKeyword.Given, string text = "my step", StepArgument stepArgument = null)
 {
     return(new DeveroomGherkinStep(null, stepKeyword + " ", text, stepArgument, stepKeyword, (ScenarioBlock)stepKeyword));
 }
Пример #24
0
 public GherkinStepBuilder And(string step, StepArgument stepArgument)
 {
     _steps.Add(new Step(null, "And", step, stepArgument));
     return(this);
 }
Пример #25
0
 private SpecFlowStep Clone(SpecFlowStep step, StepArgument stepArgument, Dictionary <string, string> paramSubst)
 {
     return(new SpecFlowStep(step.Location, step.Keyword, GetReplacedText(step.Text, paramSubst), stepArgument, step.StepKeyword, step.ScenarioBlock));
 }
Пример #26
0
 public SpecFlowStep(Location location, string keyword, string text, StepArgument argument, StepKeyword stepKeyword, ScenarioBlock scenarioBlock) : base(location, keyword, text, argument)
 {
     StepKeyword   = stepKeyword;
     ScenarioBlock = scenarioBlock;
 }