Skip to content

Commit

Permalink
StepFrom parameters update
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Nestorow <[email protected]>
  • Loading branch information
PiotrNestor committed Jul 2, 2024
1 parent 16208f3 commit c99ce13
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions src/ExecutionInfoMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Gauge.Dotnet.Wrappers;
using Gauge.Messages;
using Gauge.CSharp.Lib;
using Gauge.Dotnet.Processors;
using System.Diagnostics.Tracing;
using Microsoft.VisualBasic;

Expand All @@ -20,11 +21,13 @@ public class ExecutionInfoMapper : IExecutionInfoMapper
{
private Type _executionContextType;
private readonly IActivatorWrapper activatorWrapper;
private readonly ITableFormatter tableFormatter;

public ExecutionInfoMapper(IAssemblyLoader assemblyLoader, IActivatorWrapper activatorWrapper)
{
_executionContextType = assemblyLoader.GetLibType(LibType.ExecutionContext);
this.activatorWrapper = activatorWrapper;
tableFormatter = new TableFormatter(assemblyLoader, activatorWrapper);
}

public dynamic ExecutionContextFrom(ExecutionInfo currentExecutionInfo)
Expand Down Expand Up @@ -66,40 +69,28 @@ private dynamic StepFrom(StepInfo currentStep)
return activatorWrapper.CreateInstance(executionContextStepType);

var parameters = new List<List<string>>();
Table parametersTbl = null;
foreach (var parameter in currentStep.Step.Parameters) {
if (parameter.ParameterType == Parameter.Types.ParameterType.Static)
if (parameter.ParameterType == Parameter.Types.ParameterType.Static) {
parameters.Add(new List<string> { "Static", parameter.Name, parameter.Value });

if (parameter.ParameterType == Parameter.Types.ParameterType.Dynamic)
}
else if (parameter.ParameterType == Parameter.Types.ParameterType.Dynamic) {
parameters.Add(new List<string> { "Dynamic", parameter.Name, parameter.Value });

if (parameter.ParameterType == Parameter.Types.ParameterType.SpecialString)
}
else if (parameter.ParameterType == Parameter.Types.ParameterType.SpecialString) {
parameters.Add(new List<string> { "Special", parameter.Name, parameter.Value });
if (parameter.ParameterType == Parameter.Types.ParameterType.SpecialTable ||
}
else if (parameter.ParameterType == Parameter.Types.ParameterType.SpecialTable ||
parameter.ParameterType == Parameter.Types.ParameterType.Table) {
parameters.Add(new List<string> { "Table", parameter.Name, parameter.Value });

List<string> headers = new List<string>();
foreach (var header in parameter.Table.Headers.Cells)
headers.Add(header);
parametersTbl = new Table(headers);

foreach (var currentRow in parameter.Table.Rows) {
List<string> row = new List<string>();
foreach (var item in currentRow.Cells)
row.Add(item);
parametersTbl.AddRow(row);
}
var asJSon = tableFormatter.GetJSON(parameter.Table);
parameters.Add(new List<string> { "Table", parameter.Name, asJSon });
}
}

var inst = activatorWrapper.CreateInstance(
executionContextStepType,
currentStep.Step.ActualStepText, currentStep.IsFailed,
currentStep.StackTrace, currentStep.ErrorMessage,
parameters, parametersTbl);
parameters);

return inst;
}
Expand Down

0 comments on commit c99ce13

Please sign in to comment.