JoanComas.ScenarioUnitTesting 1.2.6

dotnet add package JoanComas.ScenarioUnitTesting --version 1.2.6                
NuGet\Install-Package JoanComas.ScenarioUnitTesting -Version 1.2.6                
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="JoanComas.ScenarioUnitTesting" Version="1.2.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JoanComas.ScenarioUnitTesting --version 1.2.6                
#r "nuget: JoanComas.ScenarioUnitTesting, 1.2.6"                
#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.
// Install JoanComas.ScenarioUnitTesting as a Cake Addin
#addin nuget:?package=JoanComas.ScenarioUnitTesting&version=1.2.6

// Install JoanComas.ScenarioUnitTesting as a Cake Tool
#tool nuget:?package=JoanComas.ScenarioUnitTesting&version=1.2.6                

.NET Scenario Unit Testing

A very easy way to write Unit Tests in xUnit, leveraging NSubstitute and AutoFixture, complemented with FluentAssertions.

Usage

  1. Decorate your test with [Theory, AutoData].
  2. Add a Scenario<MyClass> parameter to the test method.
  3. Use the Dependency<T> method to get a Mock, then configure it or assert it.
  4. Use the When() method to get the instance of the System Under Test.

Example:

[Theory, AutoData]
public void ExampleTest(Scenario<MyClass> scenario)
{
    scenario.Dependency<IMyInterface>().GetSomething(true).Returns(123);

    scenario.When().DoSomething();

    scenario.Dependency<IMyInterface>()
        .Received()
        .GetSomething(true);
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on JoanComas.ScenarioUnitTesting:

Package Downloads
JoanComas.ScenarioUnitTesting.AspNetCore

Simplify your controller unit tests with a Scenario<T> class as a single point to access the class under test and its dependencies, leveraging xUnit, AutoFixture and NSubstitute.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.6 109 8/15/2024
1.2.5 99 8/15/2024
1.2.3 103 8/14/2024
1.2.2 114 8/14/2024
1.1.5 160 8/29/2023
1.1.4 116 8/29/2023
1.1.3 131 8/29/2023
1.1.2 172 8/29/2023
1.1.1 148 8/29/2023
1.1.0 287 8/29/2023
1.0.1 260 3/3/2022

Upgraded to .NET 8.