Skip to content

Commit 9e7e1e4

Browse files
author
Gurpreet Singh
committed
remove run settings
1 parent eb2873a commit 9e7e1e4

File tree

10 files changed

+46
-86
lines changed

10 files changed

+46
-86
lines changed

src/TestStack.BDDfy.Tests/Concurrency/TestCollectionName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
{
33
internal static class TestCollectionName {
44
public const string ModifiesConfigurator = "ModifiesConfigurator";
5-
public const string Approvals = "Approvals";
5+
public const string Approvals = nameof(Approvals);
66
}
77
}

src/TestStack.BDDfy.Tests/Reporters/Html/ClassicReportBuilderTests.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
using System.Runtime.CompilerServices;
33
using TestStack.BDDfy.Reporters;
44
using TestStack.BDDfy.Reporters.Html;
5-
using TestStack.BDDfy.Tests.Concurrency;
65
using Xunit;
76

87
namespace TestStack.BDDfy.Tests.Reporters.Html
98
{
10-
[Trait("Category", TestCollectionName.Approvals)]
119
public class ClassicReportBuilderTests
1210
{
1311
[Fact]
1412
[MethodImpl(MethodImplOptions.NoInlining)]
1513
public void ShouldProduceExpectedHtml()
1614
{
17-
var model =
18-
new HtmlReportModel(new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMilliseconds()
19-
.ToReportModel())
15+
var reportModel = new ReportTestData()
16+
.CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMilliseconds()
17+
.ToReportModel();
18+
19+
var model = new HtmlReportModel(reportModel)
2020
{
2121
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
2222
};
@@ -29,8 +29,11 @@ public void ShouldProduceExpectedHtml()
2929
[MethodImpl(MethodImplOptions.NoInlining)]
3030
public void ShouldProduceExpectedHtmlWithExamples()
3131
{
32-
var reportData = new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMillisecondsAndEachHasTwoExamples().ToReportModel();
33-
var model = new HtmlReportModel(reportData)
32+
var reportModel = new ReportTestData()
33+
.CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMillisecondsAndEachHasTwoExamples()
34+
.ToReportModel();
35+
36+
var model = new HtmlReportModel(reportModel)
3437
{
3538
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
3639
};

src/TestStack.BDDfy.Tests/Scanner/Examples/ExampleActionTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using Shouldly;
22
using TestStack.BDDfy.Reporters;
3-
using TestStack.BDDfy.Tests.Concurrency;
43
using Xunit;
54

65
namespace TestStack.BDDfy.Tests.Scanner.Examples
76
{
8-
[Trait("Category", TestCollectionName.Approvals)]
97
public class ExampleActionTests
108
{
119
private int _value;

src/TestStack.BDDfy.Tests/Scanner/Examples/FluentWithExamples.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using System.Runtime.CompilerServices;
22
using Shouldly;
33
using TestStack.BDDfy.Reporters;
4-
using TestStack.BDDfy.Tests.Concurrency;
54
using Xunit;
65

76
namespace TestStack.BDDfy.Tests.Scanner.Examples
87
{
9-
[Trait("Category", TestCollectionName.Approvals)]
108
public class FluentWithExamples
119
{
1210
[Fact]

src/TestStack.BDDfy.Tests/Scanner/Examples/FluentWithExamplesAtEnd.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using Shouldly;
22
using TestStack.BDDfy.Reporters;
3-
using TestStack.BDDfy.Tests.Concurrency;
43
using Xunit;
54

65
namespace TestStack.BDDfy.Tests.Scanner.Examples
76
{
8-
[Trait("Category", TestCollectionName.Approvals)]
97
public class FluentWithExamplesAtEnd
108
{
119
[Fact]

src/TestStack.BDDfy.Tests/Scanner/Examples/ReflectiveWithExamples.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
using Shouldly;
22
using TestStack.BDDfy.Reporters;
3-
using TestStack.BDDfy.Tests.Concurrency;
43
using Xunit;
54

65
namespace TestStack.BDDfy.Tests.Scanner.Examples
76
{
8-
[Trait("Category", TestCollectionName.Approvals)]
97
public class ReflectiveWithExamples
108
{
11-
public string SecondExample { get; set; }
9+
private readonly Story _story;
1210

11+
public string SecondExample { get; set; }
12+
public ReflectiveWithExamples()
13+
{
14+
_story = this
15+
.WithExamples(new ExampleTable("First Example", "Second Example")
16+
{
17+
{1, "foo"},
18+
{2, "bar"}
19+
})
20+
.BDDfy();
21+
}
1322
public void GivenStepWith__FirstExample__PassedAsParameter(int firstExample)
1423
{
1524
firstExample.ShouldBeOneOf(1, 2);
@@ -23,16 +32,8 @@ public void AndGivenStepWith__SecondExample__AccessedViaProperty()
2332
[Fact]
2433
public void Run()
2534
{
26-
var story = this
27-
.WithExamples(new ExampleTable("First Example", "Second Example")
28-
{
29-
{1, "foo"},
30-
{2, "bar"}
31-
})
32-
.BDDfy();
33-
3435
var reporter = new TextReporter();
35-
reporter.Process(story);
36+
reporter.Process(_story);
3637
reporter.ToString().ShouldMatchApproved();
3738
}
3839
}

src/TestStack.BDDfy.Tests/TagsTests.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
using TestStack.BDDfy.Reporters.MarkDown;
77
using TestStack.BDDfy.Tests.Reporters;
88
using Xunit;
9-
using TestStack.BDDfy.Tests.Concurrency;
109

1110
namespace TestStack.BDDfy.Tests
1211
{
13-
[Trait("Category", TestCollectionName.Approvals)]
1412
public class TagsTests
1513
{
1614
[Fact]
@@ -31,7 +29,7 @@ public void TagsAreReportedInTextReport()
3129
[MethodImpl(MethodImplOptions.NoInlining)]
3230
public void TagsAreReportedInHtmlReport()
3331
{
34-
var model = new HtmlReportModel(this.CreateReportModel()) {
32+
var model = new HtmlReportModel(CreateReportModel(x=>x.BDDfy())) {
3533
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
3634
};
3735

@@ -43,7 +41,7 @@ public void TagsAreReportedInHtmlReport()
4341
[MethodImpl(MethodImplOptions.NoInlining)]
4442
public void TagsAreReportedInMetroHtmlReport()
4543
{
46-
var reportModel = this.CreateReportModel();
44+
var reportModel = CreateReportModel(x=>x.BDDfy());
4745
var model = new HtmlReportModel(reportModel)
4846
{
4947
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
@@ -57,7 +55,7 @@ public void TagsAreReportedInMetroHtmlReport()
5755
[MethodImpl(MethodImplOptions.NoInlining)]
5856
public void TagsAreReportedInMarkdownReport()
5957
{
60-
var reportModel = this.CreateReportModel();
58+
var reportModel = CreateReportModel(x=>x.BDDfy());
6159
var model = new FileReportModel(reportModel);
6260
var sut = new MarkDownReportBuilder();
6361
ReportApprover.Approve(model, sut);
@@ -68,11 +66,12 @@ private void GivenAStep()
6866

6967
}
7068

71-
private ReportModel CreateReportModel()
69+
private ReportModel CreateReportModel(Func<IFluentStepBuilder<TagsTests>, Story> bddfy)
7270
{
73-
var story = this.Given(_ => GivenAStep())
74-
.WithTags("Tag1", "Tag 2")
75-
.BDDfy();
71+
var stepBuilder = this.Given(_ => GivenAStep())
72+
.WithTags("Tag1", "Tag 2");
73+
var story = bddfy(stepBuilder);
74+
7675
var reportModel = new[] { story }.ToReportModel();
7776
return reportModel;
7877
}

src/TestStack.BDDfy.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1111
..\appveyor.yml = ..\appveyor.yml
1212
..\build.cake = ..\build.cake
1313
..\build.ps1 = ..\build.ps1
14-
default.runsettings = default.runsettings
1514
..\deploy.cake = ..\deploy.cake
1615
..\deploy.ps1 = ..\deploy.ps1
1716
Directory.build.props = Directory.build.props

src/TestStack.BDDfy/BDDfyExtensions.cs

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,6 @@ namespace TestStack.BDDfy
66
{
77
public static class BDDfyExtensions
88
{
9-
#if STACKTRACE
10-
/// <summary>
11-
/// Extension method to BDDfy an object instance.
12-
/// </summary>
13-
/// <param name="testObject">The test object representing a scenario.</param>
14-
/// <param name="scenarioTitle">Overrides the default scenario title and is displayed in the reports.</param>
15-
/// <returns></returns>
16-
public static Story BDDfy(this object testObject, string scenarioTitle = null)
17-
{
18-
return testObject.LazyBDDfy(scenarioTitle).Run();
19-
}
20-
21-
public static Engine LazyBDDfy(this object testObject, string scenarioTitle = null)
22-
{
23-
return InternalLazyBDDfy(testObject, scenarioTitle);
24-
}
25-
26-
/// <summary>
27-
/// Extension method to BDDfy an object instance.
28-
/// </summary>
29-
/// <typeparam name="TStory">The type representing the story.</typeparam>
30-
/// <param name="testObject">The test object representing a scenario.</param>
31-
/// <param name="scenarioTitle">Overrides the default scenario title and is displayed in the reports.</param>
32-
/// <param name="caller">Caller (populated by [CallerMemberName])</param>
33-
/// <returns></returns>
34-
public static Story BDDfy<TStory>(this object testObject, string scenarioTitle = null)
35-
where TStory : class
36-
{
37-
return InternalLazyBDDfy(testObject, scenarioTitle, typeof(TStory)).Run();
38-
}
39-
40-
public static Engine LazyBDDfy<TStory>(this object testObject, string scenarioTitle = null)
41-
where TStory : class
42-
{
43-
return InternalLazyBDDfy(testObject, scenarioTitle, typeof(TStory));
44-
}
45-
#else
469
/// <summary>
4710
/// Extension method to BDDfy an object instance.
4811
/// </summary>
@@ -56,7 +19,8 @@ public static Story BDDfy(
5619
[System.Runtime.CompilerServices.CallerMemberName]
5720
string caller = null)
5821
{
59-
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(caller)).Run();
22+
var callerName = testObject.GetActualCallerName(caller);
23+
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(callerName)).Run();
6024
}
6125

6226
public static Engine LazyBDDfy(
@@ -65,7 +29,8 @@ public static Engine LazyBDDfy(
6529
[System.Runtime.CompilerServices.CallerMemberName]
6630
string caller = null)
6731
{
68-
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(caller));
32+
var callerName = testObject.GetActualCallerName(caller);
33+
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(callerName));
6934
}
7035

7136
/// <summary>
@@ -83,7 +48,8 @@ public static Story BDDfy<TStory>(
8348
string caller = null)
8449
where TStory : class
8550
{
86-
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(caller), typeof(TStory)).Run();
51+
var callerName = testObject.GetActualCallerName(caller);
52+
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(callerName), typeof(TStory)).Run();
8753
}
8854

8955
public static Engine LazyBDDfy<TStory>(
@@ -93,9 +59,9 @@ public static Engine LazyBDDfy<TStory>(
9359
string caller = null)
9460
where TStory : class
9561
{
96-
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(caller), typeof(TStory));
62+
var callerName = testObject.GetActualCallerName(caller);
63+
return InternalLazyBDDfy(testObject, scenarioTitle ?? Configurator.Humanizer.Humanize(callerName), typeof(TStory));
9764
}
98-
#endif
9965

10066
static Engine InternalLazyBDDfy(
10167
object testObject,
@@ -108,15 +74,18 @@ static Engine InternalLazyBDDfy(
10874
testContext.FluentScanner.GetScanner(scenarioTitle, explicitStoryType) :
10975
GetReflectiveScanner(testContext, scenarioTitle, explicitStoryType);
11076

111-
return new Engine(storyScanner);
77+
return new (storyScanner);
11278
}
11379

114-
static IScanner GetReflectiveScanner(ITestContext testContext, string scenarioTitle = null, Type explicitStoryType = null)
80+
static DefaultScanner GetReflectiveScanner(ITestContext testContext, string scenarioTitle = null, Type explicitStoryType = null)
11581
{
11682
var stepScanners = Configurator.Scanners.GetStepScanners(testContext).ToArray();
11783
var reflectiveScenarioScanner = new ReflectiveScenarioScanner(scenarioTitle, stepScanners);
11884

119-
return new DefaultScanner(testContext, reflectiveScenarioScanner, explicitStoryType);
85+
return new (testContext, reflectiveScenarioScanner, explicitStoryType);
12086
}
87+
88+
static string GetActualCallerName(this object testObject, string inferedCallerName)
89+
=> inferedCallerName == ".ctor" ? testObject.GetType().Name : inferedCallerName;
12190
}
12291
}

src/default.runsettings

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)