Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Binary file not shown.
13 changes: 11 additions & 2 deletions SpecFlowNullReference/NullReferenceSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ namespace SpecFlowNullReference
public class NullReferenceSteps
{
private const string Key = "SomeKey";
private const string IsNullKey = Key + "isNull";
private object value;

[Given(@"I set null value to ScenarioContext")]
public void GivenISetNullValueToScenarioContext()
{
ScenarioContext.Current.Set<object>(null, Key);
string theValue = null;
ScenarioContext.Current.Set<object>(theValue, Key);
ScenarioContext.Current.Set<object>(theValue==null, IsNullKey);
}

[When(@"I get value from ScenarioContext")]
public void WhenIGetValueFromScenarioContext()
{
value = ScenarioContext.Current.Get<object>(Key);
var keyIsnull = ScenarioContext.Current.Get<bool>(IsNullKey);

if (keyIsnull)
value = null;
else
value = ScenarioContext.Current.Get<object>(Key);

}

[Then(@"the value should be null")]
Expand Down