Skip to content

Commit

Permalink
Add step parameters to the execution Context (#211)
Browse files Browse the repository at this point in the history
* Context has parameters info

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* Context params and table params

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* Context Step params and table params

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* StepFrom parameters update

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* Update to force pipeline

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* ShouldMapStepDetails fix

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* project file update

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* csproj update

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* Context params and table params

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* Context Step params and table params

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* StepFrom parameters update

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* Update to force pipeline

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* ShouldMapStepDetails fix

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* project file update

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* Version update

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

* Cosmetic updates

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>

---------

Signed-off-by: Piotr Nestorow <piotr.nestorow@systemverification.com>
  • Loading branch information
PiotrNestor authored Aug 19, 2024
1 parent 7eef3de commit f3ddbc8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ gauge run specs
#### Install specific version

```
gauge install dotnet --version 0.5.8
gauge install dotnet --version 0.6.0
```

#### Offline installation
Expand Down
30 changes: 28 additions & 2 deletions src/ExecutionInfoMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@


using System;
using System.Collections.Generic;
using System.Linq;
using Gauge.Dotnet.Wrappers;
using Gauge.Messages;
using Gauge.CSharp.Lib;
using Gauge.Dotnet.Processors;

namespace Gauge.Dotnet
{
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 @@ -61,10 +66,31 @@ private dynamic StepFrom(StepInfo currentStep)
if (currentStep == null || currentStep.Step == null)
return activatorWrapper.CreateInstance(executionContextStepType);

return activatorWrapper.CreateInstance(
var parameters = new List<List<string>>();
foreach (var parameter in currentStep.Step.Parameters) {
if (parameter.ParameterType == Parameter.Types.ParameterType.Static) {
parameters.Add(new List<string> { "Static", parameter.Name, parameter.Value });
}
else if (parameter.ParameterType == Parameter.Types.ParameterType.Dynamic) {
parameters.Add(new List<string> { "Dynamic", parameter.Name, parameter.Value });
}
else if (parameter.ParameterType == Parameter.Types.ParameterType.SpecialString) {
parameters.Add(new List<string> { "Special", parameter.Name, parameter.Value });
}
else if (parameter.ParameterType == Parameter.Types.ParameterType.SpecialTable ||
parameter.ParameterType == Parameter.Types.ParameterType.Table) {
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);
currentStep.StackTrace, currentStep.ErrorMessage,
parameters);

return inst;
}
}
}
4 changes: 2 additions & 2 deletions src/Gauge.Dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<PackageId>Runner.NetCore30</PackageId>
<Authors>The Gauge Team</Authors>
<Version>0.5.8</Version>
<Version>0.6.0</Version>
<Company>ThoughtWorks Inc.</Company>
<Product>Gauge</Product>
<Description>C# runner for Gauge. https://gauge.org</Description>
Expand All @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Gauge.CSharp.Lib" Version="0.10.2" />
<PackageReference Include="Gauge.CSharp.Lib" Version="0.10.3" />
<PackageReference Include="Grpc.Tools" Version="2.65.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/dotnet.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "dotnet",
"version": "0.5.8",
"version": "0.6.0",
"description": "C# support for gauge + .NET 6.0/7.0/8.0",
"run": {
"windows": [
Expand Down
3 changes: 2 additions & 1 deletion test/ExecutionInfoMapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Gauge.Dotnet.Wrappers;
using Gauge.CSharp.Lib;
using System.Linq;
using System.Collections.Generic;

namespace Gauge.Dotnet.UnitTests
{
Expand Down Expand Up @@ -77,7 +78,7 @@ public void ShouldMapStepDetails()
var mockActivatorWrapper = new Mock<IActivatorWrapper>();
mockActivatorWrapper.Setup(x => x.CreateInstance(typeof(ExecutionContext.StepDetails),
executionInfo.CurrentStep.Step.ActualStepText, executionInfo.CurrentStep.IsFailed,
executionInfo.CurrentStep.StackTrace, executionInfo.CurrentStep.ErrorMessage)).Verifiable();
executionInfo.CurrentStep.StackTrace, executionInfo.CurrentStep.ErrorMessage, new List<List<string>>())).Verifiable();
new ExecutionInfoMapper(mockAssemblyLoader.Object, mockActivatorWrapper.Object).ExecutionContextFrom(executionInfo);
mockActivatorWrapper.VerifyAll();
}
Expand Down

0 comments on commit f3ddbc8

Please sign in to comment.