diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bfba6024..f3b3761e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 outputs: semver: ${{ steps.gitversion.outputs.semVer }} fullsemver: ${{ steps.gitversion.outputs.fullSemVer }} @@ -34,12 +34,12 @@ jobs: fetch-depth: 0 # Required for GitVersion - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v4.1.0 + uses: gittools/actions/gitversion/setup@v4.5.0 with: - versionSpec: '6.x' + versionSpec: '6.7.x' - name: Determine Version - uses: gittools/actions/gitversion/execute@v4.1.0 + uses: gittools/actions/gitversion/execute@v4.5.0 id: gitversion - name: Format NuGet version diff --git a/readme.md b/readme.md index 8bfe45ed..5370208a 100644 --- a/readme.md +++ b/readme.md @@ -122,7 +122,7 @@ If you prefer to use the official `JetBrains.Annotations` NuGet package instead This is only the tip of iceberg. Absolutely everything you do with BDDfy is extensible and customizable. -You might see full documentation of BDDfy on the [TestStack documentation website](http://bddfy.teststack.net/). +You might see full documentation of BDDfy on the [Read The Docs](https://teststackbddfy.readthedocs.io). Oh and while you are there don't forget to checkout other cool projects from [TestStack](http://www.teststack.net/). ## Authors diff --git a/src/Samples/TestStack.BDDfy.Samples/BuyingTrainFareWithExamples.cs b/src/Samples/TestStack.BDDfy.Samples/BuyingTrainFareWithExamples.cs index 9a0a9c4c..9af74060 100644 --- a/src/Samples/TestStack.BDDfy.Samples/BuyingTrainFareWithExamples.cs +++ b/src/Samples/TestStack.BDDfy.Samples/BuyingTrainFareWithExamples.cs @@ -7,8 +7,8 @@ public class BuyingTrainFareWithExamples { #pragma warning disable 649 // ReSharper disable once InconsistentNaming - private Fare fare; - private BuyerCategory _buyerCategory; + private readonly Fare fare; + private readonly BuyerCategory _buyerCategory; #pragma warning restore 649 Money Price { get; set; } diff --git a/src/Samples/TestStack.BDDfy.Samples/CanRunAsyncSteps.cs b/src/Samples/TestStack.BDDfy.Samples/CanRunAsyncVoidSteps.cs similarity index 91% rename from src/Samples/TestStack.BDDfy.Samples/CanRunAsyncSteps.cs rename to src/Samples/TestStack.BDDfy.Samples/CanRunAsyncVoidSteps.cs index 194c27ca..06654da4 100644 --- a/src/Samples/TestStack.BDDfy.Samples/CanRunAsyncSteps.cs +++ b/src/Samples/TestStack.BDDfy.Samples/CanRunAsyncVoidSteps.cs @@ -5,7 +5,7 @@ namespace TestStack.BDDfy.Samples { - public class CanRunAsyncSteps + public class CanRunAsyncVoidSteps { private object _sut; @@ -32,7 +32,7 @@ private static async Task CreateSut() } [Fact] - public void Run() + public void RunTestWithAsyncVoidSteps() { var engine = this.LazyBDDfy(); var exception = Should.Throw(engine.Run); diff --git a/src/Samples/TestStack.BDDfy.Samples/CanWorkWithoutAStory.cs b/src/Samples/TestStack.BDDfy.Samples/CanWorkWithoutAStory.cs index ac41d335..3446942b 100644 --- a/src/Samples/TestStack.BDDfy.Samples/CanWorkWithoutAStory.cs +++ b/src/Samples/TestStack.BDDfy.Samples/CanWorkWithoutAStory.cs @@ -17,7 +17,7 @@ internal void Then_the_namespace_is_used_in_the_report() } [Fact] - public void Execute() + public void RunTestWithoutAStory() { this.BDDfy(); } diff --git a/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForGiven.cs b/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForGiven.cs index cc6bb5a8..395f57fd 100644 --- a/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForGiven.cs +++ b/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForGiven.cs @@ -6,9 +6,9 @@ namespace TestStack.BDDfy.Tests.Arguments { public class ArgumentsProvidedForGiven { - private readonly List _andGivenInput1 = new(); - private List _andGivenInput2 = new(); - private List _andGivenInput3 = new(); + private readonly List _andGivenInput1 = []; + private readonly List _andGivenInput2 = []; + private readonly List _andGivenInput3 = []; private int _givenInput3; private int _givenInput2; @@ -54,7 +54,7 @@ void ThenSeveralSetsOfArgumentsArePassedInProperly() } [Fact] - public void Execute() + public void RunTestWithArgumentsProvidedForGiven() { this.BDDfy(); } diff --git a/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForThen.cs b/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForThen.cs index 3cbe11b1..f355cdc3 100644 --- a/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForThen.cs +++ b/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForThen.cs @@ -17,7 +17,7 @@ void ThenArgumentsAreSentToThenPart(int argument1, string argument2) } [Fact] - public void Execute() + public void RunTestWithArgumentsProvidedForThen() { this.BDDfy(); } diff --git a/src/TestStack.BDDfy.Tests/Arguments/MultipleArgumentsProvidedForTheSameStep.cs b/src/TestStack.BDDfy.Tests/Arguments/MultipleArgumentsProvidedForTheSameStep.cs index 893b13c9..14430d8b 100644 --- a/src/TestStack.BDDfy.Tests/Arguments/MultipleArgumentsProvidedForTheSameStep.cs +++ b/src/TestStack.BDDfy.Tests/Arguments/MultipleArgumentsProvidedForTheSameStep.cs @@ -6,7 +6,7 @@ namespace TestStack.BDDfy.Tests.Arguments { public class MultipleArgumentsProvidedForTheSameStep { - private readonly List _inputs = new(); + private readonly List _inputs = []; [RunStepWithArgs(1)] [RunStepWithArgs(2)] @@ -25,7 +25,7 @@ void ThenTheMethodIsCalledOncePerArgument() } [Fact] - public void Execute() + public void RunTestWithMultipleArgumentsProvidedForTheSameStep() { this.BDDfy(); } diff --git a/src/TestStack.BDDfy.Tests/Exceptions/WhenAnInconclusiveTestIsRun.cs b/src/TestStack.BDDfy.Tests/Exceptions/WhenAnInconclusiveTestIsRun.cs index 67a2e548..65125ebf 100644 --- a/src/TestStack.BDDfy.Tests/Exceptions/WhenAnInconclusiveTestIsRun.cs +++ b/src/TestStack.BDDfy.Tests/Exceptions/WhenAnInconclusiveTestIsRun.cs @@ -28,8 +28,8 @@ public void TearDownThis() } } - Engine _engine; - private Scenario _scenario; + readonly Engine _engine; + private readonly Scenario _scenario; Step GivenStep { diff --git a/src/TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs b/src/TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs index 85b32b7f..5f98ba33 100644 --- a/src/TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs +++ b/src/TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs @@ -23,9 +23,9 @@ public void InitializesScenarioWithExampleBeforeRunning() var sut = new TestRunner(); Func action = o => actualValue = ExampleValue; - var steps = new List { new(action, new StepTitle("A Step"), true, ExecutionOrder.Initialize, true, new List()) }; + var steps = new List { new(action, new StepTitle("A Step"), true, ExecutionOrder.Initialize, true, []) }; - var scenarioWithExample = new Scenario("id", this, steps, "Scenario Text", exampleTable, new List()); + var scenarioWithExample = new Scenario("id", this, steps, "Scenario Text", exampleTable, []); var story = new Story(new StoryMetadata(typeof(TestRunnerTests), new StoryNarrativeAttribute()), scenarioWithExample); sut.Process(story); diff --git a/src/TestStack.BDDfy.Tests/Reporters/Html/HtmlReporterTests.cs b/src/TestStack.BDDfy.Tests/Reporters/Html/HtmlReporterTests.cs index bfa0b4ca..e54258f6 100644 --- a/src/TestStack.BDDfy.Tests/Reporters/Html/HtmlReporterTests.cs +++ b/src/TestStack.BDDfy.Tests/Reporters/Html/HtmlReporterTests.cs @@ -10,7 +10,7 @@ namespace TestStack.BDDfy.Tests.Reporters.Html { public class HtmlReporterTests { - private TestableHtmlReporter _sut; + private readonly TestableHtmlReporter _sut; private const string OutputPath = @"C:\Reports"; private const string ReportData = "Report Data"; private const string CustomStylesheet = "some custom css in here!"; diff --git a/src/TestStack.BDDfy.Tests/Reporters/ReportModelMapperTests.cs b/src/TestStack.BDDfy.Tests/Reporters/ReportModelMapperTests.cs index 93f815a2..7d4fecc6 100644 --- a/src/TestStack.BDDfy.Tests/Reporters/ReportModelMapperTests.cs +++ b/src/TestStack.BDDfy.Tests/Reporters/ReportModelMapperTests.cs @@ -9,7 +9,7 @@ namespace TestStack.BDDfy.Tests.Reporters public class ReportModelMapperTests { - private List _stories; + private readonly List _stories; public ReportModelMapperTests() { diff --git a/src/TestStack.BDDfy.Tests/Reporters/ReportTestData.cs b/src/TestStack.BDDfy.Tests/Reporters/ReportTestData.cs index d6da41d4..4047e738 100644 --- a/src/TestStack.BDDfy.Tests/Reporters/ReportTestData.cs +++ b/src/TestStack.BDDfy.Tests/Reporters/ReportTestData.cs @@ -49,14 +49,14 @@ public IEnumerable CreateMixContainingEachTypeOfOutcomeWithOneScenarioPer var stories = new List { - new(storyMetadata1, new Scenario(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario [for Happiness]", new List())), - new(storyMetadata1, new Scenario(typeof(SadPathScenario), GetFailingExecutionSteps(), "Sad Path Scenario [for Happiness]", new List())), - new(storyMetadata1, new Scenario(typeof(SadPathScenario), GetInconclusiveExecutionSteps(), "Inconclusive Scenario [for Happiness]", new List())), - new(storyMetadata1, new Scenario(typeof(SadPathScenario), GetNotImplementedExecutionSteps(), "Not Implemented Scenario [for Happiness]", new List())), - new(testThatReportWorksWithNoStory, new Scenario(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario [with no story]", new List())), - new(testThatReportWorksWithNoStory, new Scenario(typeof(SadPathScenario), GetFailingExecutionSteps(), "Sad Path Scenario [with no story]", new List())), - new(testThatReportWorksWithNoStory, new Scenario(typeof(SadPathScenario), GetInconclusiveExecutionSteps(), "Inconclusive Scenario [with no story]", new List())), - new(testThatReportWorksWithNoStory, new Scenario(typeof(SadPathScenario), GetNotImplementedExecutionSteps(), "Not Implemented Scenario [with no story]", new List())), + new(storyMetadata1, new Scenario(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario [for Happiness]", [])), + new(storyMetadata1, new Scenario(typeof(SadPathScenario), GetFailingExecutionSteps(), "Sad Path Scenario [for Happiness]", [])), + new(storyMetadata1, new Scenario(typeof(SadPathScenario), GetInconclusiveExecutionSteps(), "Inconclusive Scenario [for Happiness]", [])), + new(storyMetadata1, new Scenario(typeof(SadPathScenario), GetNotImplementedExecutionSteps(), "Not Implemented Scenario [for Happiness]", [])), + new(testThatReportWorksWithNoStory, new Scenario(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario [with no story]", [])), + new(testThatReportWorksWithNoStory, new Scenario(typeof(SadPathScenario), GetFailingExecutionSteps(), "Sad Path Scenario [with no story]", [])), + new(testThatReportWorksWithNoStory, new Scenario(typeof(SadPathScenario), GetInconclusiveExecutionSteps(), "Inconclusive Scenario [with no story]", [])), + new(testThatReportWorksWithNoStory, new Scenario(typeof(SadPathScenario), GetNotImplementedExecutionSteps(), "Not Implemented Scenario [with no story]", [])), new(storyMetadata2, GetScenarios(true, true)), new(storyMetadata3, GetScenarios(false, true)), }; @@ -118,15 +118,15 @@ private Scenario[] GetScenarios(bool includeFailingScenario, bool includeExample } return new List { - new(exampleId, typeof(ExampleScenario), GetExampleExecutionSteps(), "Example Scenario", exampleTable.ElementAt(0), new List()), - new(exampleId, typeof(ExampleScenario), exampleExecutionSteps, "Example Scenario", exampleTable.ElementAt(1), new List()) + new(exampleId, typeof(ExampleScenario), GetExampleExecutionSteps(), "Example Scenario", exampleTable.ElementAt(0), []), + new(exampleId, typeof(ExampleScenario), exampleExecutionSteps, "Example Scenario", exampleTable.ElementAt(1), []) }.ToArray(); } return new List { - new(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario", new List()), - new(typeof(SadPathScenario), sadExecutionSteps, "Sad Path Scenario", new List()) + new(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario", []), + new(typeof(SadPathScenario), sadExecutionSteps, "Sad Path Scenario", []) }.ToArray(); } @@ -134,10 +134,10 @@ private Scenario[] GetOneOfEachScenarioResult() { var scenarios = new List { - new(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario", new List()), - new(typeof(SadPathScenario), GetSadExecutionSteps(), "Sad Path Scenario", new List()), - new(typeof(SadPathScenario), GetInconclusiveExecutionSteps(), "Inconclusive Scenario", new List()), - new(typeof(SadPathScenario), GetNotImplementedExecutionSteps(), "Not Implemented Scenario", new List()) + new(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario", []), + new(typeof(SadPathScenario), GetSadExecutionSteps(), "Sad Path Scenario", []), + new(typeof(SadPathScenario), GetInconclusiveExecutionSteps(), "Inconclusive Scenario", []), + new(typeof(SadPathScenario), GetNotImplementedExecutionSteps(), "Not Implemented Scenario", []) }; // override specific step results - ideally this class could be refactored to provide objectmother/builder interface @@ -162,9 +162,9 @@ private List GetHappyExecutionSteps() { var steps = new List { - new(null, new StepTitle("Given a positive account balance"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, - new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, - new(null, new StepTitle("Then money is dispensed"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, + new(null, new StepTitle("Given a positive account balance"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, + new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, + new(null, new StepTitle("Then money is dispensed"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, }; return steps; } @@ -173,9 +173,9 @@ private List GetExampleExecutionSteps() { var steps = new List { - new(null, new StepTitle("Given a account balance"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, - new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, - new(null, new StepTitle("Then money dispensed"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, + new(null, new StepTitle("Given a account balance"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, + new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, + new(null, new StepTitle("Then money dispensed"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, }; return steps; } @@ -184,9 +184,9 @@ private List GetSadExecutionSteps() { var steps = new List { - new(null, new StepTitle("Given a negative account balance"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, - new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, - new(null, new StepTitle("Then no money is dispensed"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, + new(null, new StepTitle("Given a negative account balance"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, + new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, + new(null, new StepTitle("Then no money is dispensed"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5), Result = Result.Passed}, }; return steps; } @@ -195,9 +195,9 @@ private List GetFailingExecutionSteps() { var steps = new List { - new(null, new StepTitle("Given a negative account balance"), true, ExecutionOrder.Assertion, true, new List()), - new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, new List()), - new(null, new StepTitle("Then no money is dispensed"), true, ExecutionOrder.Assertion, true, new List()), + new(null, new StepTitle("Given a negative account balance"), true, ExecutionOrder.Assertion, true, []), + new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, []), + new(null, new StepTitle("Then no money is dispensed"), true, ExecutionOrder.Assertion, true, []), }; SetAllStepResults(steps, Result.Passed); @@ -220,9 +220,9 @@ private List GetInconclusiveExecutionSteps() { var steps = new List { - new(null, new StepTitle("Given a negative account balance"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, - new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, - new(null, new StepTitle("Then no money is dispensed"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, + new(null, new StepTitle("Given a negative account balance"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, + new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, + new(null, new StepTitle("Then no money is dispensed"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, }; SetAllStepResults(steps, Result.Passed); @@ -237,9 +237,9 @@ private List GetNotImplementedExecutionSteps() { var steps = new List { - new(null, new StepTitle("Given a negative account balance"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, - new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, - new(null, new StepTitle("Then no money is dispensed"), true, ExecutionOrder.Assertion, true, new List()) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, + new(null, new StepTitle("Given a negative account balance"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, + new(null, new StepTitle("When the account holder requests money"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, + new(null, new StepTitle("Then no money is dispensed"), true, ExecutionOrder.Assertion, true, []) {Duration = new TimeSpan(0, 0, 0, 0, 5)}, }; SetAllStepResults(steps, Result.Passed); diff --git a/src/TestStack.BDDfy.Tests/Scanner/Examples/FluentWithExamples.cs b/src/TestStack.BDDfy.Tests/Scanner/Examples/FluentWithExamples.cs index 2b7efd13..fe4f884e 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/Examples/FluentWithExamples.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/Examples/FluentWithExamples.cs @@ -101,8 +101,8 @@ private void MethodTaking__ExampleInt__(int exampleInt) public int WrongType { get; set; } public int Prop1 { get; set; } - private string _prop2 = null; - private string multiWordHeading = null; + private readonly string _prop2 = null; + private readonly string multiWordHeading = null; public ExecutionOrder Prop_3 { get; set; } } } \ No newline at end of file diff --git a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/AmbiguousHeaderMatchTests.cs b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/AmbiguousHeaderMatchTests.cs index b606b761..93b287b2 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/AmbiguousHeaderMatchTests.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/AmbiguousHeaderMatchTests.cs @@ -6,7 +6,7 @@ namespace TestStack.BDDfy.Tests.Scanner.FluentScanner { public class AmbiguousHeaderMatchTests { - private int _count = 0; + private readonly int _count = 0; [Fact] public void ThrowsWhenMultipleHeadersMatchParameterName() diff --git a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/BDDfyUsingFluentApi.cs b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/BDDfyUsingFluentApi.cs index cbca64c6..434ecbd1 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/BDDfyUsingFluentApi.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/BDDfyUsingFluentApi.cs @@ -84,21 +84,21 @@ internal void ThenTheArgumentsArePassedInProperlyAndStoredOnTheSameObjectInstanc _arrayInput2.ShouldBe(expectedInput2); } - string _primitiveInput1Field = "1"; - int _primitiveInput2Field = 2; + readonly string _primitiveInput1Field = "1"; + readonly int _primitiveInput2Field = 2; - SomeEnumForTesting _enumInputField = SomeEnumForTesting.Value2; + readonly SomeEnumForTesting _enumInputField = SomeEnumForTesting.Value2; public string PrimitiveInput1Property { get { return _primitiveInput1Field; } } public int PrimitiveInput2Property { get { return _primitiveInput2Field; } } public SomeEnumForTesting EnumInputProperty { get { return _enumInputField; } } - string[] _arrayInput1Field = new[] { "1", "2" }; - int[] _arrayInput2Field = new[] { 3, 4 }; + readonly string[] _arrayInput1Field = new[] { "1", "2" }; + readonly int[] _arrayInput2Field = new[] { 3, 4 }; - private IEnumerable EnumerableString = new[] {"1", null, "2"}; - private IEnumerable EnumerableInt = new[] {1, 2}; + private readonly IEnumerable EnumerableString = new[] {"1", null, "2"}; + private readonly IEnumerable EnumerableInt = new[] {1, 2}; public string[] ArrayInput1Property { get { return _arrayInput1Field; } } public int[] ArrayInput2Property { get { return _arrayInput2Field; } } diff --git a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/DoesNotConflictWithnSubstitute.cs b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/DoesNotConflictWithnSubstitute.cs index 23a3e325..23dc2e0c 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/DoesNotConflictWithnSubstitute.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/DoesNotConflictWithnSubstitute.cs @@ -24,7 +24,7 @@ private void ThenICanStillUseNSubsitute() private void WhenSomethingHappens() { - _exampleTable = new ExampleTable(); + _exampleTable = []; _subsitute.Examples = _exampleTable; } diff --git a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/ExpressionExtensionsTests.cs b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/ExpressionExtensionsTests.cs index f58b2a25..045e658f 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/ExpressionExtensionsTests.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/ExpressionExtensionsTests.cs @@ -92,11 +92,11 @@ List GetArguments(Expression> action, Class return action.ExtractArguments(instance).ToList(); } - int _input1 = 1; - string _input2 = "2"; + readonly int _input1 = 1; + readonly string _input2 = "2"; const string ConstInput2 = "2"; - int[] _arrayInput1 = { 1, 2 }; + readonly int[] _arrayInput1 = { 1, 2 }; public string[] _arrayInput2 = { "3", "4" }; public int[] ArrayInput1 @@ -129,7 +129,7 @@ string GetInput2(string someInput) return someInput + " Input 2"; } - ContainerType container = new(); + readonly ContainerType container = new(); [Fact] public void NoArguments() diff --git a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/WhenStepsAreScannedUsingFluentScanner.cs b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/WhenStepsAreScannedUsingFluentScanner.cs index 032dda2a..1815ce5b 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/WhenStepsAreScannedUsingFluentScanner.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/FluentScanner/WhenStepsAreScannedUsingFluentScanner.cs @@ -9,7 +9,7 @@ namespace TestStack.BDDfy.Tests.Scanner.FluentScanner [Collection(TestCollectionName.ModifiesConfigurator)] public class WhenStepsAreScannedUsingFluentScanner { - private IEnumerable _steps; + private readonly IEnumerable _steps; public WhenStepsAreScannedUsingFluentScanner() { diff --git a/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/ExecutableAttributeOrderOrdersTheStepsCorrectly.cs b/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/ExecutableAttributeOrderOrdersTheStepsCorrectly.cs index a3f45317..14169a9a 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/ExecutableAttributeOrderOrdersTheStepsCorrectly.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/ExecutableAttributeOrderOrdersTheStepsCorrectly.cs @@ -8,7 +8,7 @@ namespace TestStack.BDDfy.Tests.Scanner.ReflectiveScanner { public class ExecutableAttributeOrderOrdersTheStepsCorrectly { - private List _steps; + private readonly List _steps; private class TypeWithOrderedAttribute { diff --git a/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenCombinationOfExecutableAttributeAndMethodNamingConventionIsUsed.cs b/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenCombinationOfExecutableAttributeAndMethodNamingConventionIsUsed.cs index 2d80844e..7f2279d5 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenCombinationOfExecutableAttributeAndMethodNamingConventionIsUsed.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenCombinationOfExecutableAttributeAndMethodNamingConventionIsUsed.cs @@ -9,8 +9,8 @@ namespace TestStack.BDDfy.Tests.Scanner.ReflectiveScanner { public class WhenCombinationOfExecutableAttributeAndMethodNamingConventionIsUsed { - private Scenario _scenario; - private ScenarioWithMixedSteps _sut; + private readonly Scenario _scenario; + private readonly ScenarioWithMixedSteps _sut; private class ScenarioWithMixedSteps { diff --git a/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenMethodNamesFollowNamingConventionsOtherThanGivenWhenThen.cs b/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenMethodNamesFollowNamingConventionsOtherThanGivenWhenThen.cs index 9693ecad..680a3838 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenMethodNamesFollowNamingConventionsOtherThanGivenWhenThen.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenMethodNamesFollowNamingConventionsOtherThanGivenWhenThen.cs @@ -10,8 +10,8 @@ namespace TestStack.BDDfy.Tests.Scanner.ReflectiveScanner { public class WhenMethodNamesFollowNamingConventionsOtherThanGivenWhenThen { - private List _steps; - ScenarioClass _scenario; + private readonly List _steps; + readonly ScenarioClass _scenario; public WhenMethodNamesFollowNamingConventionsOtherThanGivenWhenThen() { diff --git a/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenTestClassUsesExecutableAttributes.cs b/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenTestClassUsesExecutableAttributes.cs index 12a8c0fc..5d47e522 100644 --- a/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenTestClassUsesExecutableAttributes.cs +++ b/src/TestStack.BDDfy.Tests/Scanner/ReflectiveScanner/WhenTestClassUsesExecutableAttributes.cs @@ -10,8 +10,8 @@ namespace TestStack.BDDfy.Tests.Scanner.ReflectiveScanner { public class WhenTestClassUsesExecutableAttributes { - private TypeWithAttribute _typeWithAttribute; - private List _steps; + private readonly TypeWithAttribute _typeWithAttribute; + private readonly List _steps; private class TypeWithAttribute { diff --git a/src/TestStack.BDDfy.Tests/Stories/StoryClassAndScenarioClassAreTheSame.cs b/src/TestStack.BDDfy.Tests/Stories/StoryClassAndScenarioClassAreTheSame.cs index e105b2c2..e183f51f 100644 --- a/src/TestStack.BDDfy.Tests/Stories/StoryClassAndScenarioClassAreTheSame.cs +++ b/src/TestStack.BDDfy.Tests/Stories/StoryClassAndScenarioClassAreTheSame.cs @@ -48,7 +48,7 @@ void andTheNarrativeIsReturnedAsExpected() } [Fact] - public void Execute() + public void RunTestWithStoryClassAndScenarioClassAreTheSame() { try { diff --git a/src/TestStack.BDDfy/Processors/StoryCache.cs b/src/TestStack.BDDfy/Processors/StoryCache.cs index 0b0892ed..20437f5d 100644 --- a/src/TestStack.BDDfy/Processors/StoryCache.cs +++ b/src/TestStack.BDDfy/Processors/StoryCache.cs @@ -4,7 +4,7 @@ namespace TestStack.BDDfy.Processors { public class StoryCache : IProcessor { - private static readonly IList Cache = new List(); + private static readonly IList Cache = []; public ProcessType ProcessType { diff --git a/src/TestStack.BDDfy/Reporters/ReportModel.cs b/src/TestStack.BDDfy/Reporters/ReportModel.cs index 833514df..1bc3c1ea 100644 --- a/src/TestStack.BDDfy/Reporters/ReportModel.cs +++ b/src/TestStack.BDDfy/Reporters/ReportModel.cs @@ -10,14 +10,14 @@ public class ReportModel public ReportModel() { - Stories = new List(); + Stories = []; } public class Story { public Story() { - Scenarios = new List(); + Scenarios = []; } public string Namespace { get; set; } @@ -42,8 +42,8 @@ public class Scenario { public Scenario() { - Tags = new List(); - Steps = new List(); + Tags = []; + Steps = []; } public string Id { get; set; } diff --git a/src/TestStack.BDDfy/Reporters/Serializers/JsonFormatter.cs b/src/TestStack.BDDfy/Reporters/Serializers/JsonFormatter.cs index 2fa425f7..4e2e7f78 100644 --- a/src/TestStack.BDDfy/Reporters/Serializers/JsonFormatter.cs +++ b/src/TestStack.BDDfy/Reporters/Serializers/JsonFormatter.cs @@ -5,9 +5,9 @@ namespace TestStack.BDDfy.Reporters.Serializers // http://www.limilabs.com/blog/json-net-formatter public class JsonFormatter { - StringWalker _walker; - IndentWriter _writer = new(); - StringBuilder _currentLine = new(); + readonly StringWalker _walker; + readonly IndentWriter _writer = new(); + readonly StringBuilder _currentLine = new(); bool _quoted; public JsonFormatter(string json) @@ -102,7 +102,7 @@ private void WriteCurrentLine() public class IndentWriter { - StringBuilder _sb = new(); + readonly StringBuilder _sb = new(); int _indent; public void Indent() @@ -137,7 +137,7 @@ public override string ToString() public class StringWalker(string s) { - string _s = s; + readonly string _s = s; public int Index { get; set; } = -1; public bool MoveNext() diff --git a/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs b/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs index 2345b493..113227f6 100644 --- a/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs +++ b/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs @@ -8,7 +8,7 @@ namespace TestStack.BDDfy { public class ExampleTable(params string[] headers): ICollection { - private readonly List _rows = new(); + private readonly List _rows = []; public string[] Headers { get; private set; } = headers; diff --git a/src/TestStack.BDDfy/Scanners/StepScanners/MethodName/DefaultMethodNameStepScanner.cs b/src/TestStack.BDDfy/Scanners/StepScanners/MethodName/DefaultMethodNameStepScanner.cs index 7aab44b9..81724951 100644 --- a/src/TestStack.BDDfy/Scanners/StepScanners/MethodName/DefaultMethodNameStepScanner.cs +++ b/src/TestStack.BDDfy/Scanners/StepScanners/MethodName/DefaultMethodNameStepScanner.cs @@ -7,8 +7,6 @@ public class DefaultMethodNameStepScanner : MethodNameStepScanner public DefaultMethodNameStepScanner() : base(CleanupTheStepText) { - AddMatcher(new MethodNameMatcher(s => s.EndsWith("Context", StringComparison.OrdinalIgnoreCase), ExecutionOrder.Initialize) { ShouldReport = false }); - AddMatcher(new MethodNameMatcher(s => s.Equals("Setup", StringComparison.OrdinalIgnoreCase), ExecutionOrder.Initialize) { ShouldReport = false }); AddMatcher(new MethodNameMatcher(s => s.StartsWith("Given", StringComparison.OrdinalIgnoreCase), ExecutionOrder.SetupState)); AddMatcher(new MethodNameMatcher(s => s.StartsWith("AndGiven", StringComparison.OrdinalIgnoreCase), ExecutionOrder.ConsecutiveSetupState)); AddMatcher(new MethodNameMatcher(s => s.StartsWith("And_Given_", StringComparison.OrdinalIgnoreCase), ExecutionOrder.ConsecutiveSetupState)); @@ -26,6 +24,8 @@ public DefaultMethodNameStepScanner() AddMatcher(new MethodNameMatcher(s => s.StartsWith("But", StringComparison.OrdinalIgnoreCase), ExecutionOrder.ConsecutiveAssertion) { Asserts = true }); AddMatcher(new MethodNameMatcher(s => s.StartsWith("But_Then_", StringComparison.OrdinalIgnoreCase), ExecutionOrder.ConsecutiveAssertion) { Asserts = true }); AddMatcher(new MethodNameMatcher(s => s.StartsWith("ButThen", StringComparison.OrdinalIgnoreCase), ExecutionOrder.ConsecutiveAssertion) { Asserts = true }); + AddMatcher(new MethodNameMatcher(s => s.EndsWith("Context", StringComparison.OrdinalIgnoreCase), ExecutionOrder.Initialize) { ShouldReport = false }); + AddMatcher(new MethodNameMatcher(s => s.Equals("Setup", StringComparison.OrdinalIgnoreCase), ExecutionOrder.Initialize) { ShouldReport = false }); AddMatcher(new MethodNameMatcher(s => s.StartsWith("TearDown", StringComparison.OrdinalIgnoreCase), ExecutionOrder.TearDown) { ShouldReport = false }); } diff --git a/src/TestStack.BDDfy/Scanners/StepScanners/MethodName/MethodNameStepScanner.cs b/src/TestStack.BDDfy/Scanners/StepScanners/MethodName/MethodNameStepScanner.cs index 88546e38..e1a21e50 100644 --- a/src/TestStack.BDDfy/Scanners/StepScanners/MethodName/MethodNameStepScanner.cs +++ b/src/TestStack.BDDfy/Scanners/StepScanners/MethodName/MethodNameStepScanner.cs @@ -49,7 +49,7 @@ public MethodNameStepScanner(Func stepTextTransformer, params Me public MethodNameStepScanner(Func stepTextTransformer) { _stepTextTransformer = stepTextTransformer; - _matchers = new List(); + _matchers = []; } protected void AddMatcher(MethodNameMatcher matcher) @@ -113,14 +113,14 @@ private Step GetStep(object testObject, MethodNameMatcher matcher, MethodInfo me } var stepAction = GetStepAction(method, inputs.ToArray(), returnsItsText); - return new Step(stepAction, new StepTitle(stepMethodName), matcher.Asserts, matcher.ExecutionOrder, matcher.ShouldReport, new List()); + return new Step(stepAction, new StepTitle(stepMethodName), matcher.Asserts, matcher.ExecutionOrder, matcher.ShouldReport, []); } private Step GetStep(object testObject, MethodNameMatcher matcher, MethodInfo method, bool returnsItsText, object[] inputs = null, RunStepWithArgsAttribute argAttribute = null) { var stepMethodName = GetStepTitle(method, testObject, argAttribute, returnsItsText); var stepAction = GetStepAction(method, inputs, returnsItsText); - return new Step(stepAction, new StepTitle(stepMethodName), matcher.Asserts, matcher.ExecutionOrder, matcher.ShouldReport, new List()); + return new Step(stepAction, new StepTitle(stepMethodName), matcher.Asserts, matcher.ExecutionOrder, matcher.ShouldReport, []); } private string GetStepTitle(MethodInfo method, object testObject, RunStepWithArgsAttribute argAttribute, bool returnsItsText) diff --git a/src/TestStack.BDDfy/StepTitle.cs b/src/TestStack.BDDfy/StepTitle.cs index 64250e57..f2ea54f6 100644 --- a/src/TestStack.BDDfy/StepTitle.cs +++ b/src/TestStack.BDDfy/StepTitle.cs @@ -18,9 +18,6 @@ public static implicit operator string(StepTitle title) return title.ToString(); } - public override string ToString() - { - return _createTitle(); - } + public override string ToString() => _createTitle(); } } \ No newline at end of file diff --git a/src/TestStack.BDDfy/TestContext.cs b/src/TestStack.BDDfy/TestContext.cs index 4c9c6e37..ee8dfc5e 100644 --- a/src/TestStack.BDDfy/TestContext.cs +++ b/src/TestStack.BDDfy/TestContext.cs @@ -4,13 +4,13 @@ namespace TestStack.BDDfy { public class TestContext : ITestContext { - private static readonly Dictionary ContextLookup = new(); - private static object _dictionaryLock = new(); + private static readonly Dictionary ContextLookup = []; + private static readonly object _dictionaryLock = new(); private TestContext(object testObject) { TestObject = testObject; - Tags = new List(); + Tags = []; } public static void SetContext(object testObject, ITestContext context)