VOOZH about

URL: https://www.nuget.org/packages/DrifterApps.Seeds.FluentScenario/

⇱ NuGet Gallery | DrifterApps.Seeds.FluentScenario 1.0.19




👁 Image
DrifterApps.Seeds.FluentScenario 1.0.19

dotnet add package DrifterApps.Seeds.FluentScenario --version 1.0.19
 
 
NuGet\Install-Package DrifterApps.Seeds.FluentScenario -Version 1.0.19
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DrifterApps.Seeds.FluentScenario" Version="1.0.19" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DrifterApps.Seeds.FluentScenario" Version="1.0.19" />
 
Directory.Packages.props
<PackageReference Include="DrifterApps.Seeds.FluentScenario" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DrifterApps.Seeds.FluentScenario --version 1.0.19
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DrifterApps.Seeds.FluentScenario, 1.0.19"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DrifterApps.Seeds.FluentScenario@1.0.19
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DrifterApps.Seeds.FluentScenario&version=1.0.19
 
Install as a Cake Addin
#tool nuget:?package=DrifterApps.Seeds.FluentScenario&version=1.0.19
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

<img alt='paper plane icons' src='./icon.png' height='10%' width='10%'> Fluent Scenario

FluentScenario is a C# library that provides a fluent BDD scenario testing framework.

👁 Build and Publish NuGet Package
👁 CodeQL

Table of Contents

Installation

To install FluentScenario, you can use the NuGet package manager:

dotnet add package DrifterApps.Seeds.FluentScenario

If you use FluentAssertions to assert your tests. You can use the NuGet package manager:

dotnet add package DrifterApps.Seeds.FluentScenario.FluentAssertions

Usage

Scenario basics

Here is a basic test scenario :

[Fact]
public async Task SimpleScenario()
{
 int temperatureInside = 0;
 int temperatureOutside = 0;

 await ScenarioRunner.Create("when the weather is too cold", _scenarioOutput)
 .Given("I want to go play outside", () => temperatureInside = 19)
 .When("the temperature is below 0C", () => temperatureOutside = -5)
 .Then("I stay inside if the temperature difference is greater than 20C", () => (temperatureInside - temperatureOutside).Should().BeGreaterThan(20))
 .PlayAsync();
}

This will produce this output:

✓ SCENARIO for when the weather is too cold
✓ GIVEN I want to go play outside
✓ WHEN the temperature is below 0C
✓ THEN I stay inside if the temperature difference is greater than 20C

Scenario with execution methods

For scenarios where some steps could be shared between multiple scenarions, you can create a set of execution methods for those common steps :

[Fact]
public async Task ScenarioWithExecutionMethods()
{
 await ScenarioRunner.Create("when the weather is too cold", _scenarioOutput)
 .Given(PlayOutsideMethod)
 .When(TemperatureBelow0CMethod)
 .Then(StayInsideMethod)
 .PlayAsync();
}

private static void PlayOutsideMethod(IStepRunner runner)
{
 runner.Execute("I want to go play outside", () =>
 {
 runner.SetContextData("temperatureInside", 19);
 });
}

private static void TemperatureBelow0CMethod(IStepRunner runner)
{
 runner.Execute("the temperature is below 0C", () =>
 {
 runner.SetContextData("temperatureOutside", -5);
 });
}

private static void StayInsideMethod(IStepRunner runner)
{
 runner.Execute("I stay inside if the temperature difference is greater than 20C", () =>
 {
 var temperatureInside = runner.GetContextData<int>("temperatureInside");
 var temperatureOutside = runner.GetContextData<int>("temperatureOutside");
 (temperatureInside - temperatureOutside).Should().BeGreaterThan(20);
 });
}

This will produce this output:

✓ SCENARIO for when the weather is too cold
✓ GIVEN I want to go play outside
✓ WHEN the temperature is below 0C
✓ THEN I stay inside if the temperature difference is greater than 20C

Scenario with well named methods

Some of us like to properly name our methods so they are clear to the reader what the intent of the method is.

In this case, you can forgo a description and the ScenarioRunner will use the name of your calling methods to create the description :

[Fact]
public async Task WhenTheWeatherIsTooCold()
{
 await ScenarioRunner.Create(_scenarioOutput)
 .Given(IWantToGoPlayOutside)
 .When(TheTemperatureIsBelow0C)
 .Then(IStayInsideIfTheTemperatureDifferenceIsGreaterThan20C)
 .PlayAsync();
}

private static void IWantToGoPlayOutside(IStepRunner runner)
{
 runner.Execute(() =>
 {
 runner.SetContextData("temperatureInside", 19);
 });
}

private static void TheTemperatureIsBelow0C(IStepRunner runner)
{
 runner.Execute(() =>
 {
 runner.SetContextData("temperatureOutside", -5);
 });
}

private static void IStayInsideIfTheTemperatureDifferenceIsGreaterThan20C(IStepRunner runner)
{
 runner.Execute(() =>
 {
 var temperatureInside = runner.GetContextData<int>("temperatureInside");
 var temperatureOutside = runner.GetContextData<int>("temperatureOutside");
 (temperatureInside - temperatureOutside).Should().BeGreaterThan(20);
 });
}

This will produce this output:

✓ SCENARIO for When The Weather Is Too Cold
✓ GIVEN I Want To Go Play Outside
✓ WHEN The Temperature Is Below0 C
✓ THEN I Stay Inside If The Temperature Difference Is Greater Than20 C

Scenario with parameters and results

To start a scenario, you can pass values in the Create method. And you can also pass values between steps.

Each values passed as a parameter is a value object. This value object is there to help ensuring that the value received is a valid value.

Here's an example :

[Theory]
[InlineData(19)]
public async Task ScenarioWithParameters(int inside)
{
 await ScenarioRunner.Create("when the weather is too cold", inside, _scenarioOutput)
 .Given("I want to go play outside", (Ensure<int> temperatureInside) =>
 {
 temperatureInside.Should().BeValid(); // ensure the temperature is valid
 return (temperatureInside.Value, -5);
 })
 .When("the temperature difference is great", (Ensure<(int inside, int outside)> temperatures) =>
 {
 temperatures.Should().BeValid(); // ensure the temperatures are valid
 return temperatures.Value.inside - temperatures.Value.outside;
 })
 .Then("I stay inside if the temperature difference is greater than 20C",
 (Ensure<int> temperatureDifference) =>
 {
 temperatureDifference.Should().BeValid().And.Subject.Value.Should().BeGreaterThan(20);
 })
 .PlayAsync();
}

This will produce this output:

✓ SCENARIO for when the weather is too cold
✓ GIVEN I want to go play outside
✓ WHEN the temperature difference is great
✓ THEN I stay inside if the temperature difference is greater than 20C

Contributing

Contributions are welcome! Please read the contributing guidelines for more information.

License

This project is licensed under the MIT License. See the file for details.

Product Versions Compatible and additional computed target framework versions.
.NET net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on DrifterApps.Seeds.FluentScenario:

Package Downloads
DrifterApps.Seeds.Testing

Package Description

DrifterApps.Seeds.FluentScenario.FluentAssertions

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.19 301 5/14/2026
1.0.13 749 1/25/2026
1.0.10 473 12/26/2025
1.0.8 622 11/14/2025
1.0.5 630 6/24/2025
1.0.4 1,016 6/1/2025
1.0.0 1,662 3/15/2025
0.1.14 1,366 1/18/2025
0.1.13 487 1/17/2025
0.1.11 239 1/16/2025
0.1.4 523 12/3/2024
0.1.2 407 11/26/2024
0.1.0 209 11/26/2024