diff --git a/integration-test/ExecuteStepProcessorTests.cs b/integration-test/ExecuteStepProcessorTests.cs
index 0009623..5a8367a 100644
--- a/integration-test/ExecuteStepProcessorTests.cs
+++ b/integration-test/ExecuteStepProcessorTests.cs
@@ -6,6 +6,7 @@
using System.Threading;
+using System.Threading.Tasks;
using Gauge.Dotnet.Models;
using Gauge.Dotnet.Processors;
using Gauge.Dotnet.Wrappers;
@@ -18,7 +19,7 @@ namespace Gauge.Dotnet.IntegrationTests
public class ExecuteStepProcessorTests : IntegrationTestsBase
{
[Test]
- public void ShouldExecuteMethodFromRequest()
+ public async Task ShouldExecuteMethodFromRequest()
{
const string parameterizedStepText = "Step that takes a table {}";
const string stepText = "Step that takes a table
";
@@ -64,7 +65,7 @@ public void ShouldExecuteMethodFromRequest()
}
}
};
- var result = executeStepProcessor.Process(message);
+ var result = await executeStepProcessor.Process(message);
var protoExecutionResult = result.ExecutionResult;
ClassicAssert.IsNotNull(protoExecutionResult);
@@ -72,7 +73,7 @@ public void ShouldExecuteMethodFromRequest()
}
[Test]
- public void ShouldCaptureScreenshotOnFailure()
+ public async Task ShouldCaptureScreenshotOnFailure()
{
const string stepText = "I throw a serializable exception";
var reflectionWrapper = new ReflectionWrapper();
@@ -96,7 +97,7 @@ public void ShouldCaptureScreenshotOnFailure()
ActualStepText = stepText
};
- var result = executeStepProcessor.Process(message);
+ var result = await executeStepProcessor.Process(message);
var protoExecutionResult = result.ExecutionResult;
ClassicAssert.IsNotNull(protoExecutionResult);
diff --git a/integration-test/ExecutionOrchestratorTests.cs b/integration-test/ExecutionOrchestratorTests.cs
index 4516c27..0c7b93d 100644
--- a/integration-test/ExecutionOrchestratorTests.cs
+++ b/integration-test/ExecutionOrchestratorTests.cs
@@ -5,9 +5,9 @@
*----------------------------------------------------------------*/
-using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using Gauge.CSharp.Lib;
using Gauge.Dotnet.Models;
using Gauge.Dotnet.Wrappers;
@@ -20,7 +20,7 @@ namespace Gauge.Dotnet.IntegrationTests
public class ExecutionOrchestratorTests : IntegrationTestsBase
{
[Test]
- public void RecoverableIsTrueOnExceptionThrownWhenContinueOnFailure()
+ public async Task RecoverableIsTrueOnExceptionThrownWhenContinueOnFailure()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
@@ -34,13 +34,13 @@ public void RecoverableIsTrueOnExceptionThrownWhenContinueOnFailure()
new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager));
var gaugeMethod = assemblyLoader.GetStepRegistry()
.MethodFor("I throw a serializable exception and continue");
- var executionResult = orchestrator.ExecuteStep(gaugeMethod);
+ var executionResult = await orchestrator.ExecuteStep(gaugeMethod);
ClassicAssert.IsTrue(executionResult.Failed);
ClassicAssert.IsTrue(executionResult.RecoverableError);
}
[Test]
- public void ShouldCreateTableFromTargetType()
+ public async Task ShouldCreateTableFromTargetType()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
@@ -57,12 +57,12 @@ public void ShouldCreateTableFromTargetType()
table.AddRow(new List { "foorow1", "barrow1" });
table.AddRow(new List { "foorow2", "barrow2" });
- var executionResult = orchestrator.ExecuteStep(gaugeMethod, SerializeTable(table));
+ var executionResult = await orchestrator.ExecuteStep(gaugeMethod, SerializeTable(table));
ClassicAssert.False(executionResult.Failed);
}
[Test]
- public void ShouldExecuteMethodAndReturnResult()
+ public async Task ShouldExecuteMethodAndReturnResult()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
@@ -77,12 +77,12 @@ public void ShouldExecuteMethodAndReturnResult()
var gaugeMethod = assemblyLoader.GetStepRegistry()
.MethodFor("A context step which gets executed before every scenario");
- var executionResult = orchestrator.ExecuteStep(gaugeMethod);
+ var executionResult = await orchestrator.ExecuteStep(gaugeMethod);
ClassicAssert.False(executionResult.Failed);
}
[Test]
- public void ShouldGetPendingMessages()
+ public async Task ShouldGetPendingMessages()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
@@ -97,14 +97,14 @@ public void ShouldGetPendingMessages()
var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("Say {} to {}");
- var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod, "hello", "world");
+ var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod, "hello", "world");
ClassicAssert.False(executionResult.Failed);
ClassicAssert.Contains("hello, world!", executionResult.Message);
}
[Test]
- public void ShouldExecuteAsyncStepImplementation()
+ public async Task ShouldExecuteAsyncStepImplementation()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
@@ -119,14 +119,14 @@ public void ShouldExecuteAsyncStepImplementation()
var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("Say {} to {} async");
- var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod, "hello", "async world");
+ var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod, "hello", "async world");
Assert.That(executionResult.Failed, Is.False, executionResult.ErrorMessage);
StringAssert.Contains("hello, async world!", executionResult.Message.ToString());
}
[Test]
- public void ShouldGetStacktraceForAggregateException()
+ public async Task ShouldGetStacktraceForAggregateException()
{
var reflectionWrapper = new ReflectionWrapper();
var activatorWrapper = new ActivatorWrapper();
@@ -140,7 +140,7 @@ public void ShouldGetStacktraceForAggregateException()
new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager));
var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw an AggregateException");
- var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod);
+ var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod);
ClassicAssert.True(executionResult.Failed);
ClassicAssert.True(executionResult.StackTrace.Contains("First Exception"));
@@ -163,7 +163,7 @@ public void ShouldGetStepTextsForMethod()
}
[Test]
- public void SuccessIsFalseOnSerializableExceptionThrown()
+ public async Task SuccessIsFalseOnSerializableExceptionThrown()
{
const string expectedMessage = "I am a custom serializable exception";
var reflectionWrapper = new ReflectionWrapper();
@@ -178,7 +178,7 @@ public void SuccessIsFalseOnSerializableExceptionThrown()
new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager));
var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw a serializable exception");
- var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod);
+ var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod);
ClassicAssert.True(executionResult.Failed);
ClassicAssert.AreEqual(expectedMessage, executionResult.ErrorMessage);
@@ -187,7 +187,7 @@ public void SuccessIsFalseOnSerializableExceptionThrown()
}
[Test]
- public void SuccessIsFalseOnUnserializableExceptionThrown()
+ public async Task SuccessIsFalseOnUnserializableExceptionThrown()
{
const string expectedMessage = "I am a custom exception";
var reflectionWrapper = new ReflectionWrapper();
@@ -202,7 +202,7 @@ public void SuccessIsFalseOnUnserializableExceptionThrown()
new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager));
var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw an unserializable exception");
- var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod);
+ var executionResult = await executionOrchestrator.ExecuteStep(gaugeMethod);
ClassicAssert.True(executionResult.Failed);
ClassicAssert.AreEqual(expectedMessage, executionResult.ErrorMessage);
StringAssert.Contains("IntegrationTestSample.StepImplementation.ThrowUnserializableException",
diff --git a/integration-test/ExternalReferenceTests.cs b/integration-test/ExternalReferenceTests.cs
index d7df069..d20d5ab 100644
--- a/integration-test/ExternalReferenceTests.cs
+++ b/integration-test/ExternalReferenceTests.cs
@@ -7,6 +7,7 @@
using System;
using System.Threading;
+using System.Threading.Tasks;
using Gauge.Dotnet.Models;
using Gauge.Dotnet.Processors;
using Gauge.Dotnet.Wrappers;
@@ -43,7 +44,7 @@ public void ShouldGetStepsFromReference(string referenceType, string stepText, s
[Test]
[TestCase("ProjectReference", "Take Screenshot in reference Project", "ReferenceProject-IDoNotExist.png")]
[TestCase("DllReference", "Take Screenshot in reference DLL", "ReferenceDll-IDoNotExist.png")]
- public void ShouldRegisterScreenshotWriterFromReference(string referenceType, string stepText, string expected)
+ public async Task ShouldRegisterScreenshotWriterFromReference(string referenceType, string stepText, string expected)
{
Environment.SetEnvironmentVariable("GAUGE_PROJECT_ROOT", TestUtils.GetIntegrationTestSampleDirectory(referenceType));
var reflectionWrapper = new ReflectionWrapper();
@@ -66,7 +67,7 @@ public void ShouldRegisterScreenshotWriterFromReference(string referenceType, st
ActualStepText = stepText
};
- var result = executeStepProcessor.Process(message);
+ var result = await executeStepProcessor.Process(message);
var protoExecutionResult = result.ExecutionResult;
ClassicAssert.IsNotNull(protoExecutionResult);
diff --git a/src/ExecutableRunnerServiceHandler.cs b/src/ExecutableRunnerServiceHandler.cs
index 830d519..5319ddd 100644
--- a/src/ExecutableRunnerServiceHandler.cs
+++ b/src/ExecutableRunnerServiceHandler.cs
@@ -38,54 +38,54 @@ public ExecutableRunnerServiceHandler(IActivatorWrapper activationWrapper, IRefl
IAssemblyLoader assemblyLoader, IStaticLoader loader, ExecutorPool pool, IHostApplicationLifetime lifetime)
: base(loader, pool, lifetime)
{
- this._activatorWrapper = activationWrapper;
- this._reflectionWrapper = reflectionWrapper;
- this._assemblyLoader = assemblyLoader;
+ _activatorWrapper = activationWrapper;
+ _reflectionWrapper = reflectionWrapper;
+ _assemblyLoader = assemblyLoader;
_stepRegistry = assemblyLoader.GetStepRegistry();
InitializeExecutionMessageHandlers();
}
public override Task InitializeSuiteDataStore(SuiteDataStoreInitRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.suiteDataStoreInitProcessor.Process());
+ return _pool.Execute(GetStream(request.Stream), () => suiteDataStoreInitProcessor.Process());
}
public override Task ExecuteStep(ExecuteStepRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.executeStepProcessor.Process(request));
+ return _pool.Execute(GetStream(request.Stream), async () => await executeStepProcessor.Process(request));
}
public override Task FinishExecution(ExecutionEndingRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.executionEndingProcessor.Process(request));
+ return _pool.Execute(GetStream(request.Stream), async () => await executionEndingProcessor.Process(request));
}
public override Task FinishScenarioExecution(ScenarioExecutionEndingRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.scenarioExecutionEndingProcessor.Process(request));
+ return _pool.Execute(GetStream(request.Stream), async () => await scenarioExecutionEndingProcessor.Process(request));
}
public override Task FinishSpecExecution(SpecExecutionEndingRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.specExecutionEndingProcessor.Process(request));
+ return _pool.Execute(GetStream(request.Stream), async () => await specExecutionEndingProcessor.Process(request));
}
public override Task FinishStepExecution(StepExecutionEndingRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.stepExecutionEndingProcessor.Process(request));
+ return _pool.Execute(GetStream(request.Stream), async () => await stepExecutionEndingProcessor.Process(request));
}
public override Task InitializeScenarioDataStore(ScenarioDataStoreInitRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.scenarioDataStoreInitProcessor.Process());
+ return _pool.Execute(GetStream(request.Stream), () => scenarioDataStoreInitProcessor.Process());
}
public override Task InitializeSpecDataStore(SpecDataStoreInitRequest request, ServerCallContext context)
{
try
{
- return _pool.Execute(getStream(request.Stream), () => this.specDataStoreInitProcessor.Process());
+ return _pool.Execute(GetStream(request.Stream), () => specDataStoreInitProcessor.Process());
}
- catch (System.Exception e)
+ catch (Exception e)
{
Console.WriteLine(e);
Environment.Exit(1);
@@ -95,58 +95,51 @@ public override Task InitializeSpecDataStore(SpecDataSt
public override Task StartExecution(ExecutionStartingRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.executionStartingProcessor.Process(request));
+ return _pool.Execute(GetStream(request.Stream), async () => await executionStartingProcessor.Process(request));
}
public override Task StartScenarioExecution(ScenarioExecutionStartingRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.scenarioExecutionStartingProcessor.Process(request));
+ return _pool.Execute(GetStream(request.Stream), async () => await scenarioExecutionStartingProcessor.Process(request));
}
public override Task StartSpecExecution(SpecExecutionStartingRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.specExecutionStartingProcessor.Process(request));
+ return _pool.Execute(GetStream(request.Stream), async () => await specExecutionStartingProcessor.Process(request));
}
public override Task StartStepExecution(StepExecutionStartingRequest request, ServerCallContext context)
{
- return _pool.Execute(getStream(request.Stream), () => this.stepExecutionStartingProcessor.Process(request));
+ return _pool.Execute(GetStream(request.Stream), async () => await stepExecutionStartingProcessor.Process(request));
}
private void InitializeExecutionMessageHandlers()
{
- var tableFormatter = new TableFormatter(this._assemblyLoader, this._activatorWrapper);
- var classInstanceManager = new ThreadLocal