Skip to content

Commit 902c316

Browse files
authored
Merge pull request #114 from quantori/fix-complex-binding-builder
Fixed NullReferenceException when using ComplexBindingBuilder in hooks
2 parents ecc57d5 + 93cfa86 commit 902c316

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
[1.10.0] - 2022-05-16
7+
[1.10.2] - 2022-05-16
88
### Added
9-
- Added cells representation to the ITableRowWrapper interface.
9+
- Fixed NullReferenceException when using ComplexBindingBuilder in hooks

src/Behavioral.Automation/Behavioral.Automation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The whole automation code is divided into the following parts:
1616
- UI structure descriptive code
1717
- Supportive code</Description>
1818
<Copyright>Quantori Inc.</Copyright>
19-
<PackageVersion>1.10.1</PackageVersion>
19+
<PackageVersion>1.10.2</PackageVersion>
2020
<RepositoryUrl>https://github.com/quantori/Behavioral.Automation</RepositoryUrl>
2121
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2222
<IncludeSymbols>true</IncludeSymbols>

src/Behavioral.Automation/Services/ComplexBindingBuilder.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void BuildAction<T1, T2, T3, T4>(Action<T1, T2, T3, T4> method, params ob
7373

7474
private void BuildAction(object[] pars, IEnumerable<StepDefinitionBaseAttribute> attributes, string methodName)
7575
{
76-
var definitionType = _scenarioContext.StepContext.StepInfo.StepDefinitionType.ToString();
76+
var definitionType = GetStepDefinitionType().ToString();
7777
var attributeForCurrentStep = attributes.FirstOrDefault(a => a.GetType().Name.StartsWith(definitionType, StringComparison.OrdinalIgnoreCase));
7878
if (attributeForCurrentStep == null)
7979
{
@@ -99,7 +99,7 @@ private void BuildAction(object[] pars, IEnumerable<StepDefinitionBaseAttribute>
9999

100100
private void RunAction(string stepExpression)
101101
{
102-
switch (_scenarioContext.StepContext.StepInfo.StepDefinitionType)
102+
switch (GetStepDefinitionType())
103103
{
104104
case StepDefinitionType.Given:
105105
_runner.Given(stepExpression);
@@ -115,6 +115,18 @@ private void RunAction(string stepExpression)
115115
}
116116
}
117117

118+
private StepDefinitionType GetStepDefinitionType()
119+
{
120+
try
121+
{
122+
return _scenarioContext.StepContext.StepInfo.StepDefinitionType;
123+
}
124+
catch (NullReferenceException)
125+
{
126+
return StepDefinitionType.Given;
127+
}
128+
}
129+
118130
private void RunAction(string stepExpression, Table table)
119131
{
120132
switch (_scenarioContext.StepContext.StepInfo.StepDefinitionType)

0 commit comments

Comments
 (0)