Skip to content

Commit fbfeaa5

Browse files
author
Gurpreet Singh
committed
add step title factory tests
1 parent d07d2bd commit fbfeaa5

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

src/TestStack.BDDfy.Tests/Scanner/FluentScanner/UsingCustomStepTitleFactory.cs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,49 @@ public StepTitle Create(
2525
[Fact]
2626
public void ShouldUseCustomStepTitleFactoryWhenSet()
2727
{
28-
var scenario = new UsingCustomStepTitleFactory();
29-
var configurator = TestContext.GetContext(scenario).Configurator;
30-
configurator.StepTitleFactory = new CustomStepTitleFactory();
28+
Configurator.StepTitleFactory = new CustomStepTitleFactory();
3129

32-
var story = scenario
30+
try
31+
{
32+
var story = new UsingCustomStepTitleFactory()
3333
.Given(_ => SomeState())
3434
.When(_ => SomethingHappens())
3535
.Then(_ => SomeResult())
3636
.BDDfy();
3737

38-
story.Scenarios.Single().Steps.ElementAt(0).Title.ShouldBe("Custom Step Title");
39-
story.Scenarios.Single().Steps.ElementAt(1).Title.ShouldBe("Custom Step Title");
40-
story.Scenarios.Single().Steps.ElementAt(2).Title.ShouldBe("Custom Step Title");
38+
story.Scenarios.Single().Steps.ElementAt(0).Title.ShouldBe("Custom Step Title");
39+
story.Scenarios.Single().Steps.ElementAt(1).Title.ShouldBe("Custom Step Title");
40+
story.Scenarios.Single().Steps.ElementAt(2).Title.ShouldBe("Custom Step Title");
41+
}
42+
finally
43+
{
44+
Configurator.StepTitleFactory = new DefaultStepTitleFactory();
45+
}
46+
4147
}
4248

4349
[Fact]
4450
public void ShouldUseCustomStepTitleFactoryWhenSetWithStepTitles()
4551
{
46-
var scenario = new UsingCustomStepTitleFactory();
47-
var configurator = TestContext.GetContext(scenario).Configurator;
48-
configurator.StepTitleFactory = new CustomStepTitleFactory();
49-
var story = scenario
52+
Configurator.StepTitleFactory = new CustomStepTitleFactory();
53+
54+
try
55+
{
56+
var story = new UsingCustomStepTitleFactory()
5057
.Given(_ => SomeState(), "Not this")
5158
.When(_ => SomethingHappens(), "Or this")
5259
.Then(_ => SomeResult(), "should not appear")
5360
.BDDfy();
5461

55-
story.Scenarios.Single().Steps.ElementAt(0).Title.ShouldBe("Custom Step Title");
56-
story.Scenarios.Single().Steps.ElementAt(1).Title.ShouldBe("Custom Step Title");
57-
story.Scenarios.Single().Steps.ElementAt(2).Title.ShouldBe("Custom Step Title");
62+
story.Scenarios.Single().Steps.ElementAt(0).Title.ShouldBe("Custom Step Title");
63+
story.Scenarios.Single().Steps.ElementAt(1).Title.ShouldBe("Custom Step Title");
64+
story.Scenarios.Single().Steps.ElementAt(2).Title.ShouldBe("Custom Step Title");
65+
}
66+
finally
67+
{
68+
Configurator.StepTitleFactory = new DefaultStepTitleFactory();
69+
70+
}
5871
}
5972

6073
[StepTitle("given from attribute")]

0 commit comments

Comments
 (0)