diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 00000000..440746e9
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,209 @@
+name: Build and Test
+on:
+ push:
+ pull_request:
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ outputs:
+ semver: ${{ steps.gitversion.outputs.semVer }}
+ fullsemver: ${{ steps.gitversion.outputs.fullSemVer }}
+ nugetversion: ${{ steps.gitversion.outputs.fullSemVer }}
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v5
+ with:
+ fetch-depth: 0 # Required for GitVersion
+
+ - name: Install GitVersion
+ uses: gittools/actions/gitversion/setup@v4.1.0
+ with:
+ versionSpec: '6.x'
+
+ - name: Determine Version
+ uses: gittools/actions/gitversion/execute@v4.1.0
+ id: gitversion
+
+ - name: Display GitVersion outputs
+ run: |
+ echo "Version: ${{ steps.gitversion.outputs.semVer }}"
+ echo "AssemblyVersion: ${{ steps.gitversion.outputs.assemblySemVer }}"
+ echo "FileVersion: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
+ echo "NuGet Version: ${{ steps.gitversion.outputs.fullSemVer }}"
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v5
+ with:
+ dotnet-version: '8.0.x'
+
+ - name: Build project
+ working-directory: src
+ run: dotnet build --configuration Release /p:Version=${{ steps.gitversion.outputs.assemblySemVer }} /p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemVer }} /p:FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} /p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }}
+
+ - name: Run tests with coverage
+ working-directory: src
+ run: dotnet test --configuration Release --collect:"XPlat Code Coverage" --results-directory ../coverage
+
+ - name: Generate coverage report
+ uses: danielpalme/ReportGenerator-GitHub-Action@5.4.16
+ with:
+ reports: 'coverage/**/coverage.cobertura.xml'
+ targetdir: 'coverage-report'
+ reporttypes: 'Html;Cobertura;TextSummary'
+
+ - name: Display Code Coverage Summary
+ run: |
+ echo "## 📊 Code Coverage Summary" >> $GITHUB_STEP_SUMMARY
+ if [ -f "coverage-report/Summary.txt" ]; then
+ echo '```' >> $GITHUB_STEP_SUMMARY
+ cat coverage-report/Summary.txt >> $GITHUB_STEP_SUMMARY
+ echo '```' >> $GITHUB_STEP_SUMMARY
+ echo "### Build Log Coverage Summary:"
+ cat coverage-report/Summary.txt
+ else
+ echo "⚠️ Coverage summary file not found"
+ echo "⚠️ Coverage summary file not found" >> $GITHUB_STEP_SUMMARY
+ fi
+
+ - name: Generate Rich Release Notes
+ id: release_notes
+ uses: mikepenz/release-changelog-builder-action@v5.4.1
+ with:
+ configuration: |
+ {
+ "template": "## 🚀 Release ${{ steps.gitversion.outputs.semVer }}\n\n### 📅 Release Information\n- **Version**: ${{ steps.gitversion.outputs.semVer }}\n- **NuGet Version**: ${{ steps.gitversion.outputs.fullSemVer }}\n- **Build Date**: $(date -u +'%Y-%m-%d %H:%M:%S UTC')\n- **Commit**: ${{ github.sha }}\n\n#{{CHANGELOG}}\n\n### 📊 Statistics\n- **Total Changes**: #{{UNCATEGORIZED_COUNT}} commits\n- **Contributors**: #{{CONTRIBUTORS}}\n\n---\n*Generated automatically by GitHub Actions*",
+ "categories": [
+ {
+ "title": "## 🚀 Features",
+ "labels": ["feature", "enhancement", "feat"]
+ },
+ {
+ "title": "## 🐛 Bug Fixes",
+ "labels": ["bug", "fix", "bugfix"]
+ },
+ {
+ "title": "## 📚 Documentation",
+ "labels": ["documentation", "docs"]
+ },
+ {
+ "title": "## 🔧 Maintenance",
+ "labels": ["maintenance", "chore", "refactor"]
+ },
+ {
+ "title": "## ⚠️ Breaking Changes",
+ "labels": ["breaking", "breaking-change"]
+ }
+ ],
+ "pr_template": "- #{{TITLE}} (#{{NUMBER}}) by @#{{AUTHOR}}",
+ "empty_template": "- #{{TITLE}} (#{{HASH}}) by @#{{AUTHOR}}",
+ "max_pull_requests": 200,
+ "max_back_track_time_days": 365
+ }
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Save Release Notes to File
+ run: echo "${{ steps.release_notes.outputs.changelog }}" > release-notes.md
+
+ - name: Upload Release Notes as artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: release-notes
+ path: release-notes.md
+
+ - name: Create NuGet package
+ working-directory: src
+ run: dotnet pack --configuration Release --no-build /p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }} --output ../packages
+
+ - name: Upload NuGet package as artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: nuget-package
+ path: packages/*.nupkg
+
+ - name: Publish coverage report as artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: coverage-report
+ path: coverage-report/
+
+ publish-nuget:
+ runs-on: ubuntu-latest
+ needs: build
+ if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch
+ environment:
+ name: Publish
+ url: https://www.nuget.org/packages/TestStack.BDDfy/
+
+ steps:
+ - name: Download NuGet package
+ uses: actions/download-artifact@v5
+ with:
+ name: nuget-package
+ path: packages
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v5
+ with:
+ dotnet-version: '8.0.x'
+
+ - name: Publish to NuGet
+ run: dotnet nuget push packages/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
+
+ create-release-tag:
+ runs-on: ubuntu-latest
+ needs: [build, publish-nuget]
+ if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch
+ permissions:
+ contents: write
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v5
+ with:
+ fetch-depth: 0
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Check if tag already exists
+ id: check_tag
+ run: |
+ TAG="v${{ needs.build.outputs.semver }}"
+ if git rev-parse "$TAG" >/dev/null 2>&1; then
+ echo "Tag $TAG already exists"
+ echo "tag_exists=true" >> $GITHUB_OUTPUT
+ else
+ echo "Creating new tag: $TAG"
+ echo "tag_exists=false" >> $GITHUB_OUTPUT
+ echo "new_tag=$TAG" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Download Release Notes
+ if: steps.check_tag.outputs.tag_exists == 'false'
+ uses: actions/download-artifact@v5
+ with:
+ name: release-notes
+ path: .
+
+ - name: Create Git Tag and GitHub Release
+ if: steps.check_tag.outputs.tag_exists == 'false'
+ run: |
+ TAG="${{ steps.check_tag.outputs.new_tag }}"
+
+ # Configure git
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+
+ # Create and push tag
+ git tag -a "$TAG" -m "Release $TAG"
+ git push origin "$TAG"
+
+ # Create GitHub release
+ gh release create "$TAG" \
+ --title "Release $TAG" \
+ --notes-file release-notes.md \
+ --generate-notes
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index afcc04ff..ad4aa3cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,5 @@ tools/Cake/
tools/GitReleaseNotes/
tools/gitversion.commandline/
artifacts/
+*.code-workspace
+**/coverage
diff --git a/GitVersion.yml b/GitVersion.yml
index 79ece618..246c3435 100644
--- a/GitVersion.yml
+++ b/GitVersion.yml
@@ -1,5 +1,5 @@
mode: ContinuousDelivery
-next-version: 4.1.0
+next-version: 8.0.0
branches: {}
ignore:
sha: []
diff --git a/src/.editorconfig b/src/.editorconfig
new file mode 100644
index 00000000..dd2b5504
--- /dev/null
+++ b/src/.editorconfig
@@ -0,0 +1,4 @@
+[*.cs]
+
+# Default severity for analyzer diagnostics with category 'Style'
+dotnet_analyzer_diagnostic.category-Style.severity = none
diff --git a/src/Directory.build.props b/src/Directory.build.props
new file mode 100644
index 00000000..19bc63e5
--- /dev/null
+++ b/src/Directory.build.props
@@ -0,0 +1,5 @@
+
+
+ net8.0
+
+
\ No newline at end of file
diff --git a/src/NuGet.config b/src/NuGet.config
deleted file mode 100644
index 5e4d98d7..00000000
--- a/src/NuGet.config
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Samples/TestStack.BDDfy.Samples/AssemblySetupFixture.cs b/src/Samples/TestStack.BDDfy.Samples/AssemblySetupFixture.cs
index 5e375cf7..8c3c8d61 100644
--- a/src/Samples/TestStack.BDDfy.Samples/AssemblySetupFixture.cs
+++ b/src/Samples/TestStack.BDDfy.Samples/AssemblySetupFixture.cs
@@ -33,55 +33,36 @@ public AssemblySetupFixture()
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
- public class AssemblyFixtureAttribute : Attribute
+ public class AssemblyFixtureAttribute(Type fixtureType): Attribute
{
- public AssemblyFixtureAttribute(Type fixtureType)
- {
- FixtureType = fixtureType;
- }
-
- public Type FixtureType { get; private set; }
+ public Type FixtureType { get; private set; } = fixtureType;
}
- public class XunitTestFrameworkWithAssemblyFixture : XunitTestFramework
+ public class XunitTestFrameworkWithAssemblyFixture(IMessageSink messageSink): XunitTestFramework(messageSink)
{
- public XunitTestFrameworkWithAssemblyFixture(IMessageSink messageSink)
- : base(messageSink)
- { }
-
protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyName)
=> new XunitTestFrameworkExecutorWithAssemblyFixture(assemblyName, SourceInformationProvider, DiagnosticMessageSink);
}
- public class XunitTestFrameworkExecutorWithAssemblyFixture : XunitTestFrameworkExecutor
+ public class XunitTestFrameworkExecutorWithAssemblyFixture(AssemblyName assemblyName,
+ ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink): XunitTestFrameworkExecutor(assemblyName, sourceInformationProvider, diagnosticMessageSink)
{
- public XunitTestFrameworkExecutorWithAssemblyFixture(AssemblyName assemblyName,
- ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink)
- : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
- {
- }
-
protected override async void RunTestCases(IEnumerable testCases,
IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
{
- using (
- var assemblyRunner = new XunitTestAssemblyRunnerWithAssemblyFixture(TestAssembly, testCases,
- DiagnosticMessageSink, executionMessageSink, executionOptions))
- await assemblyRunner.RunAsync();
+ using var assemblyRunner = new XunitTestAssemblyRunnerWithAssemblyFixture(TestAssembly, testCases,
+ DiagnosticMessageSink, executionMessageSink, executionOptions);
+ await assemblyRunner.RunAsync();
}
}
- public class XunitTestAssemblyRunnerWithAssemblyFixture : XunitTestAssemblyRunner
+ public class XunitTestAssemblyRunnerWithAssemblyFixture(ITestAssembly testAssembly,
+ IEnumerable testCases,
+ IMessageSink diagnosticMessageSink,
+ IMessageSink executionMessageSink,
+ ITestFrameworkExecutionOptions executionOptions): XunitTestAssemblyRunner(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions)
{
- readonly Dictionary assemblyFixtureMappings = new Dictionary();
-
- public XunitTestAssemblyRunnerWithAssemblyFixture(ITestAssembly testAssembly,
- IEnumerable testCases,
- IMessageSink diagnosticMessageSink,
- IMessageSink executionMessageSink,
- ITestFrameworkExecutionOptions executionOptions)
- : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions)
- { }
+ readonly Dictionary assemblyFixtureMappings = new();
protected override async Task AfterTestAssemblyStartingAsync()
{
@@ -118,24 +99,17 @@ protected override Task RunTestCollectionAsync(IMessageBus messageBu
=> new XunitTestCollectionRunnerWithAssemblyFixture(assemblyFixtureMappings, testCollection, testCases, DiagnosticMessageSink, messageBus, TestCaseOrderer, new ExceptionAggregator(Aggregator), cancellationTokenSource).RunAsync();
}
- public class XunitTestCollectionRunnerWithAssemblyFixture : XunitTestCollectionRunner
+ public class XunitTestCollectionRunnerWithAssemblyFixture(Dictionary assemblyFixtureMappings,
+ ITestCollection testCollection,
+ IEnumerable testCases,
+ IMessageSink diagnosticMessageSink,
+ IMessageBus messageBus,
+ ITestCaseOrderer testCaseOrderer,
+ ExceptionAggregator aggregator,
+ CancellationTokenSource cancellationTokenSource): XunitTestCollectionRunner(testCollection, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource)
{
- readonly Dictionary assemblyFixtureMappings;
- readonly IMessageSink diagnosticMessageSink;
-
- public XunitTestCollectionRunnerWithAssemblyFixture(Dictionary assemblyFixtureMappings,
- ITestCollection testCollection,
- IEnumerable testCases,
- IMessageSink diagnosticMessageSink,
- IMessageBus messageBus,
- ITestCaseOrderer testCaseOrderer,
- ExceptionAggregator aggregator,
- CancellationTokenSource cancellationTokenSource)
- : base(testCollection, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource)
- {
- this.assemblyFixtureMappings = assemblyFixtureMappings;
- this.diagnosticMessageSink = diagnosticMessageSink;
- }
+ readonly Dictionary assemblyFixtureMappings = assemblyFixtureMappings;
+ readonly IMessageSink diagnosticMessageSink = diagnosticMessageSink;
protected override Task RunTestClassAsync(ITestClass testClass, IReflectionTypeInfo @class, IEnumerable testCases)
{
diff --git a/src/Samples/TestStack.BDDfy.Samples/Atm/AccountHolderWithdrawsCash.cs b/src/Samples/TestStack.BDDfy.Samples/Atm/AccountHolderWithdrawsCash.cs
index 894b012e..a31fb495 100644
--- a/src/Samples/TestStack.BDDfy.Samples/Atm/AccountHolderWithdrawsCash.cs
+++ b/src/Samples/TestStack.BDDfy.Samples/Atm/AccountHolderWithdrawsCash.cs
@@ -19,47 +19,47 @@ public class AccountHolderWithdrawsCash
private Card _card;
private Atm _atm;
- public void Given_the_Account_Balance_is(int balance)
+ internal void Given_the_Account_Balance_is(int balance)
{
_card = new Card(true, balance);
}
- public void Given_the_Card_is_disabled()
+ internal void Given_the_Card_is_disabled()
{
_card = new Card(false, 100);
_atm = new Atm(100);
}
- public void And_the_Card_is_valid()
+ internal void And_the_Card_is_valid()
{
}
- public void And_the_machine_contains(int atmBalance)
+ internal void And_the_machine_contains(int atmBalance)
{
_atm = new Atm(atmBalance);
}
- public void When_the_Account_Holder_requests(int moneyRequest)
+ internal void When_the_Account_Holder_requests(int moneyRequest)
{
_atm.RequestMoney(_card, moneyRequest);
}
- public void The_ATM_should_dispense(int dispensedMoney)
+ internal void The_ATM_should_dispense(int dispensedMoney)
{
_atm.DispenseValue.ShouldBe(dispensedMoney);
}
- public void And_the_Account_Balance_should_be(int balance)
+ internal void And_the_Account_Balance_should_be(int balance)
{
_card.AccountBalance.ShouldBe(balance);
}
- public void Then_Card_is_retained(bool cardIsRetained)
+ internal void Then_Card_is_retained(bool cardIsRetained)
{
_atm.CardIsRetained.ShouldBe(cardIsRetained);
}
- void And_the_ATM_should_say_the_Card_has_been_retained()
+ internal void And_the_ATM_should_say_the_Card_has_been_retained()
{
_atm.Message.ShouldBe(DisplayMessage.CardIsRetained);
}
diff --git a/src/Samples/TestStack.BDDfy.Samples/Atm/Atm.cs b/src/Samples/TestStack.BDDfy.Samples/Atm/Atm.cs
index cfc509e9..ede74525 100644
--- a/src/Samples/TestStack.BDDfy.Samples/Atm/Atm.cs
+++ b/src/Samples/TestStack.BDDfy.Samples/Atm/Atm.cs
@@ -1,13 +1,8 @@
namespace TestStack.BDDfy.Samples.Atm
{
- public class Atm
+ public class Atm(int existingCash)
{
- public int ExistingCash { get; private set; }
-
- public Atm(int existingCash)
- {
- ExistingCash = existingCash;
- }
+ public int ExistingCash { get; private set; } = existingCash;
public void RequestMoney(Card card, int request)
{
@@ -35,16 +30,10 @@ public void RequestMoney(Card card, int request)
public DisplayMessage Message { get; private set; }
}
- public class Card
+ public class Card(bool enabled, int accountBalance)
{
- public int AccountBalance { get; set; }
- private readonly bool _enabled;
-
- public Card(bool enabled, int accountBalance)
- {
- AccountBalance = accountBalance;
- _enabled = enabled;
- }
+ public int AccountBalance { get; set; } = accountBalance;
+ private readonly bool _enabled = enabled;
public bool Enabled
{
diff --git a/src/Samples/TestStack.BDDfy.Samples/BuyingTrainFares/Money.cs b/src/Samples/TestStack.BDDfy.Samples/BuyingTrainFares/Money.cs
index 2ec30b57..b032fa3d 100644
--- a/src/Samples/TestStack.BDDfy.Samples/BuyingTrainFares/Money.cs
+++ b/src/Samples/TestStack.BDDfy.Samples/BuyingTrainFares/Money.cs
@@ -2,14 +2,9 @@
namespace TestStack.BDDfy.Samples.BuyingTrainFares
{
- class Money
+ class Money(decimal amount)
{
- public Money(decimal amount)
- {
- Amount = amount;
- }
-
- public decimal Amount { get; set; }
+ public decimal Amount { get; set; } = amount;
protected bool Equals(Money other)
{
diff --git a/src/Samples/TestStack.BDDfy.Samples/CanRunAsyncSteps.cs b/src/Samples/TestStack.BDDfy.Samples/CanRunAsyncSteps.cs
index 4efbdb8f..1025b3a3 100644
--- a/src/Samples/TestStack.BDDfy.Samples/CanRunAsyncSteps.cs
+++ b/src/Samples/TestStack.BDDfy.Samples/CanRunAsyncSteps.cs
@@ -9,17 +9,17 @@ public class CanRunAsyncSteps
{
private Sut _sut;
- public async void GivenSomeAsyncSetup()
+ internal async void GivenSomeAsyncSetup()
{
_sut = await CreateSut();
}
- public void ThenBddfyHasWaitedForThatSetupToCompleteBeforeContinuing()
+ internal void ThenBddfyHasWaitedForThatSetupToCompleteBeforeContinuing()
{
_sut.ShouldNotBe(null);
}
- public async Task AndThenBddfyShouldCaptureExceptionsThrownInAsyncMethod()
+ internal async Task AndThenBddfyShouldCaptureExceptionsThrownInAsyncMethod()
{
await Task.Yield();
throw new Exception("Exception in async void method!!");
diff --git a/src/Samples/TestStack.BDDfy.Samples/CanWorkWithoutAStory.cs b/src/Samples/TestStack.BDDfy.Samples/CanWorkWithoutAStory.cs
index e2194be2..ac41d335 100644
--- a/src/Samples/TestStack.BDDfy.Samples/CanWorkWithoutAStory.cs
+++ b/src/Samples/TestStack.BDDfy.Samples/CanWorkWithoutAStory.cs
@@ -4,15 +4,15 @@ namespace TestStack.BDDfy.Samples
{
public class CanWorkWithoutAStory
{
- public void Given_no_story_is_provided()
+ internal void Given_no_story_is_provided()
{
}
- public void When_we_BDDfy_the_class()
+ internal void When_we_BDDfy_the_class()
{
}
- public void Then_the_namespace_is_used_in_the_report()
+ internal void Then_the_namespace_is_used_in_the_report()
{
}
diff --git a/src/Samples/TestStack.BDDfy.Samples/CustomTextReporter.cs b/src/Samples/TestStack.BDDfy.Samples/CustomTextReporter.cs
index 152d28d1..5293448a 100644
--- a/src/Samples/TestStack.BDDfy.Samples/CustomTextReporter.cs
+++ b/src/Samples/TestStack.BDDfy.Samples/CustomTextReporter.cs
@@ -18,10 +18,8 @@ private static string OutputDirectory
{
get
{
- string codeBase = typeof(CustomTextReporter).GetTypeInfo().Assembly.CodeBase;
- var uri = new UriBuilder(codeBase);
- string path = Uri.UnescapeDataString(uri.Path);
- return System.IO.Path.GetDirectoryName(path);
+ string codeBase = typeof(CustomTextReporter).GetTypeInfo().Assembly.Location;
+ return System.IO.Path.GetDirectoryName(codeBase);
}
}
diff --git a/src/Samples/TestStack.BDDfy.Samples/TestStack.BDDfy.Samples.csproj b/src/Samples/TestStack.BDDfy.Samples/TestStack.BDDfy.Samples.csproj
index 95c86b17..8a150d91 100644
--- a/src/Samples/TestStack.BDDfy.Samples/TestStack.BDDfy.Samples.csproj
+++ b/src/Samples/TestStack.BDDfy.Samples/TestStack.BDDfy.Samples.csproj
@@ -1,11 +1,10 @@
-
+
- netcoreapp2.0
+ net8.0
TestStack.BDDfy.Samples
TestStack.BDDfy.Samples
true
- win10-x64
false
false
false
@@ -16,24 +15,17 @@
-
-
-
-
-
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
-
-
-
-
-
-
- $(DefineConstants);Approvals;Culture;NSubstitute
-
-
-
-
-
-
-
diff --git a/src/Samples/TestStack.BDDfy.Samples/TicTacToe/TicTacToe.cs b/src/Samples/TestStack.BDDfy.Samples/TicTacToe/TicTacToe.cs
index ff6759f2..726295a3 100644
--- a/src/Samples/TestStack.BDDfy.Samples/TicTacToe/TicTacToe.cs
+++ b/src/Samples/TestStack.BDDfy.Samples/TicTacToe/TicTacToe.cs
@@ -10,16 +10,10 @@ namespace TestStack.BDDfy.Samples.TicTacToe
SoThat = "So that I can waste some time!")]
public class TicTacToe : NewGame
{
- class Cell
+ class Cell(int row, int col)
{
- public Cell(int row, int col)
- {
- Row = row;
- Col = col;
- }
-
- public int Row { get; set; }
- public int Col { get; set; }
+ public int Row { get; set; } = row;
+ public int Col { get; set; } = col;
public override string ToString()
{
diff --git a/src/Samples/TestStack.BDDfy.Samples/TicTacToe/WinnerGame.cs b/src/Samples/TestStack.BDDfy.Samples/TicTacToe/WinnerGame.cs
index 452865be..43e363eb 100644
--- a/src/Samples/TestStack.BDDfy.Samples/TicTacToe/WinnerGame.cs
+++ b/src/Samples/TestStack.BDDfy.Samples/TicTacToe/WinnerGame.cs
@@ -4,20 +4,12 @@
namespace TestStack.BDDfy.Samples.TicTacToe
{
- public class WinnerGame : GameUnderTest
+ public class WinnerGame(string[] firstRow, string[] secondRow, string[] thirdRow, string expectedWinner): GameUnderTest
{
- private readonly string[] _firstRow;
- private readonly string[] _secondRow;
- private readonly string[] _thirdRow;
- private readonly string _expectedWinner;
-
- public WinnerGame(string[] firstRow, string[] secondRow, string[] thirdRow, string expectedWinner)
- {
- _firstRow = firstRow;
- _secondRow = secondRow;
- _thirdRow = thirdRow;
- _expectedWinner = expectedWinner;
- }
+ private readonly string[] _firstRow = firstRow;
+ private readonly string[] _secondRow = secondRow;
+ private readonly string[] _thirdRow = thirdRow;
+ private readonly string _expectedWinner = expectedWinner;
// Note: This method returns IEnumerable
// this is done to allow the method to return its title.
diff --git a/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForGiven.cs b/src/TestStack.BDDfy.Tests/Arguments/ArgumentsProvidedForGiven.cs
index 94814322..cc6bb5a8 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 List();
- private List _andGivenInput2 = new List();
- private List _andGivenInput3 = new List();
+ private readonly List _andGivenInput1 = new();
+ private List _andGivenInput2 = new();
+ private List _andGivenInput3 = new();
private int _givenInput3;
private int _givenInput2;
diff --git a/src/TestStack.BDDfy.Tests/Arguments/MultipleArgumentsProvidedForTheSameStep.cs b/src/TestStack.BDDfy.Tests/Arguments/MultipleArgumentsProvidedForTheSameStep.cs
index ffcae947..893b13c9 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 List();
+ private readonly List _inputs = new();
[RunStepWithArgs(1)]
[RunStepWithArgs(2)]
diff --git a/src/TestStack.BDDfy.Tests/Configuration/ProcessorPipelineTests.cs b/src/TestStack.BDDfy.Tests/Configuration/ProcessorPipelineTests.cs
index 56db7bfc..3ca8a1ab 100644
--- a/src/TestStack.BDDfy.Tests/Configuration/ProcessorPipelineTests.cs
+++ b/src/TestStack.BDDfy.Tests/Configuration/ProcessorPipelineTests.cs
@@ -7,6 +7,7 @@
namespace TestStack.BDDfy.Tests.Configuration
{
+ [Collection("ExclusiveAccessToConfigurator")]
public class ProcessorPipelineTests
{
[Fact]
diff --git a/src/TestStack.BDDfy.Tests/Configuration/StepExecutorTests.cs b/src/TestStack.BDDfy.Tests/Configuration/StepExecutorTests.cs
index 27369c30..8d9e1916 100644
--- a/src/TestStack.BDDfy.Tests/Configuration/StepExecutorTests.cs
+++ b/src/TestStack.BDDfy.Tests/Configuration/StepExecutorTests.cs
@@ -5,11 +5,12 @@
namespace TestStack.BDDfy.Tests.Configuration
{
+ [Collection("ExclusiveAccessToConfigurator")]
public class StepExecutorTests
{
private class TestStepExecutor : StepExecutor
{
- readonly StringBuilder _builder = new StringBuilder();
+ readonly StringBuilder _builder = new();
public string Results
{
diff --git a/src/TestStack.BDDfy.Tests/Configuration/TestRunnerTests.cs b/src/TestStack.BDDfy.Tests/Configuration/TestRunnerTests.cs
index 0dd9b950..f89aece7 100644
--- a/src/TestStack.BDDfy.Tests/Configuration/TestRunnerTests.cs
+++ b/src/TestStack.BDDfy.Tests/Configuration/TestRunnerTests.cs
@@ -1,12 +1,12 @@
using System;
using System.Linq;
-using NUnit.Framework;
using Shouldly;
using TestStack.BDDfy.Configuration;
using Xunit;
namespace TestStack.BDDfy.Tests.Configuration
{
+ [Collection("ExclusiveAccessToConfigurator")]
public class TestRunnerTests
{
public class ScenarioWithFailingThen
@@ -104,6 +104,8 @@ public void FailingThenDoesNotStopThePipelineWithReflectiveAPI()
[Fact]
public void FailingThenDoesNotStopThePipelineWithFluentAPI()
{
+ Configurator.Processors.TestRunner.StopExecutionOnFailingThen = false;
+
var testRun = new ScenarioWithFailingThen()
.Given(x => x.PassingGiven())
.When(x => x.PassingWhen())
diff --git a/src/TestStack.BDDfy.Tests/Disposer/DisposingScenarios.cs b/src/TestStack.BDDfy.Tests/Disposer/DisposingScenarios.cs
index ca061630..a47ad897 100644
--- a/src/TestStack.BDDfy.Tests/Disposer/DisposingScenarios.cs
+++ b/src/TestStack.BDDfy.Tests/Disposer/DisposingScenarios.cs
@@ -9,18 +9,11 @@ namespace TestStack.BDDfy.Tests.Disposer
{
public class DisposingScenarios
{
- class DisposableScenario : IDisposable
+ class DisposableScenario(ThrowingMethods throwingMethods): IDisposable
{
- private readonly bool _givenThrows;
- private readonly bool _whenThrows;
- private readonly bool _thenThrows;
-
- public DisposableScenario(ThrowingMethods throwingMethods)
- {
- _givenThrows = (throwingMethods & ThrowingMethods.Given) > 0;
- _whenThrows = (throwingMethods & ThrowingMethods.When) > 0;
- _thenThrows = (throwingMethods & ThrowingMethods.Then) > 0;
- }
+ private readonly bool _givenThrows = (throwingMethods & ThrowingMethods.Given) > 0;
+ private readonly bool _whenThrows = (throwingMethods & ThrowingMethods.When) > 0;
+ private readonly bool _thenThrows = (throwingMethods & ThrowingMethods.Then) > 0;
public void Given()
{
diff --git a/src/TestStack.BDDfy.Tests/Exceptions/ExceptionThrowingTest.cs b/src/TestStack.BDDfy.Tests/Exceptions/ExceptionThrowingTest.cs
index a9fb85a4..1ca455cd 100644
--- a/src/TestStack.BDDfy.Tests/Exceptions/ExceptionThrowingTest.cs
+++ b/src/TestStack.BDDfy.Tests/Exceptions/ExceptionThrowingTest.cs
@@ -6,9 +6,9 @@ namespace TestStack.BDDfy.Tests.Exceptions
{
public class ExceptionThrowingTest where T : Exception, new()
{
- private static bool _givenShouldThrow;
- private static bool _whenShouldThrow;
- private static bool _thenShouldThrow;
+ private bool _givenShouldThrow;
+ private bool _whenShouldThrow;
+ private bool _thenShouldThrow;
Scenario _scenario;
void Given()
diff --git a/src/TestStack.BDDfy.Tests/ExclusiveAccessToConfiguratorFixture.cs b/src/TestStack.BDDfy.Tests/ExclusiveAccessToConfiguratorFixture.cs
new file mode 100644
index 00000000..2c9f5f33
--- /dev/null
+++ b/src/TestStack.BDDfy.Tests/ExclusiveAccessToConfiguratorFixture.cs
@@ -0,0 +1,9 @@
+using Xunit;
+
+namespace TestStack.BDDfy.Tests
+{
+ [CollectionDefinition("ExclusiveAccessToConfigurator", DisableParallelization = true)]
+ public class ExclusiveAccessToConfiguratorFixture
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs b/src/TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs
index 3fa7a968..85b32b7f 100644
--- a/src/TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs
+++ b/src/TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs
@@ -23,7 +23,7 @@ public void InitializesScenarioWithExampleBeforeRunning()
var sut = new TestRunner();
Func