BunsenBurner 7.0.0

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

// Install BunsenBurner as a Cake Tool
#tool nuget:?package=BunsenBurner&version=7.0.0                

Bunsen Burner Bunsen Burner

Nuget

Test framework-agnostic, zero dependencies, easy to use DSL, more maintainable, easier to refactor. Set 🔥 to your old tests! A better way to write tests :test_tube: in C#.

Getting Started

To use this library, simply include BunsenBurner.dll in your project or grab it from NuGet, and add this to the top of each test .cs file that needs it:

// for AAA style tests
using static BunsenBurner.ArrangeActAssert;

or

// for BDD style tests
using static BunsenBurner.GivenWhenThen;

[!NOTE] Tests must always return a Task to be compatible with the DSL.

Take an existing test,

[Fact(DisplayName = "SerializeAsync can work with anonymous objects")]
public async Task ExampleTest()
{
    // Arrange
    var widget = new { Name = "Widget1", Cost = 12.50 };
    var ms = new MemoryStream();

    // Act
    await JsonSerializer.SerializeAsync(ms, widget);

    // Assert
    Assert.Equal(
        expected: "{\"Name\":\"Widget1\",\"Cost\":12.5}",
        actual: Encoding.UTF8.GetString(ms.ToArray())
    );
}

and convert it to this,

[Fact(DisplayName = "SerializeAsync can work with anonymous objects")]
public Task ExampleTest() =>
     Arrange(() => new { Name = "Widget1", Cost = 12.50 })
    .Act(async widget =>
    {
        var ms = new MemoryStream();
        await JsonSerializer.SerializeAsync(ms, widget);
        return Encoding.UTF8.GetString(ms.ToArray());
    })
    .Assert(result => result == "{\"Name\":\"Widget1\",\"Cost\":12.5}");

This formalizes the structure and then opens up refactoring possibilities such as pulling out a shared act method,

[Fact(DisplayName = "SerializeAsync can work with anonymous objects")]
public Task ExampleTestUsingAaaBuilder2() =>
    Arrange(() =>
    {
        var widget = new { Name = "Widget1", Cost = 12.50 };
        var ms = new MemoryStream();
        return (widget, ms);
    })
    // pull out the shared test code
    .Act(CallSerializeAsync)
    .Assert(result =>
        Assert.Equal(
            expected: "{\"Name\":\"Widget1\",\"Cost\":12.5}", 
            actual: result)
    );

// this is now a shared stage and can be used in many tests
private static async Task<string> CallSerializeAsync<T>((T, MemoryStream) data)
{
    var (widget, ms) = data;
    await JsonSerializer.SerializeAsync(ms, widget);
    return Encoding.UTF8.GetString(ms.ToArray());
}

The principle is simple, refine the test structure using a DSL then use the new structure to identify common code and DRY that code up.

For more information, see Bunsen Burner.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (12)

Showing the top 5 NuGet packages that depend on BunsenBurner:

Package Downloads
BunsenBurner.Http

Extension methods for testing Http servers

BunsenBurner.Verify.Xunit

Integration with [Verify.Xunit](https://github.com/VerifyTests/Verify) to simplify assert steps

BunsenBurner.AutoFixture

Integration with [AutoFixture](https://github.com/AutoFixture) to simplify arrange steps

BunsenBurner.Bogus

Integration with [Bogus](https://github.com/bchavez/Bogus) to simplify arrange steps

BunsenBurner.Hedgehog

Integration with [Hedgehog](https://github.com/hedgehogqa/fsharp-hedgehog) to write property based tests

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.0 1,212 6/23/2024
6.2.4 12,619 6/20/2023
6.2.3 1,482 6/5/2023
6.2.2 3,525 4/25/2023
6.2.1 4,649 3/11/2023
6.2.0 2,817 1/29/2023
6.1.1 3,283 1/19/2023
6.1.0 4,512 1/12/2023
6.0.0 2,596 1/11/2023
5.3.1 2,679 1/7/2023
5.3.0 2,637 1/6/2023
5.2.0 2,711 12/17/2022
5.1.0 3,016 12/12/2022
5.0.0 2,700 12/11/2022
4.0.1 2,676 12/11/2022
4.0.0 2,715 12/11/2022
3.0.0 2,673 12/10/2022
2.2.0 2,639 12/9/2022
2.1.0 2,647 12/9/2022
2.0.0 2,756 12/9/2022
1.6.2 3,040 12/2/2022
1.6.1 2,983 12/1/2022
1.6.0 2,906 11/30/2022
1.5.1 3,060 11/26/2022
1.5.0 2,997 11/21/2022
1.4.1 2,410 11/19/2022
1.4.0 2,332 11/19/2022
1.3.0 2,196 11/19/2022
1.2.1 2,026 11/17/2022
1.2.0 2,089 11/16/2022
1.1.1 2,129 11/15/2022
1.1.0 2,021 11/15/2022
1.0.4 1,714 11/8/2022
1.0.3 1,836 11/6/2022
1.0.2 1,860 11/6/2022
1.0.1 1,838 11/6/2022
1.0.0 1,848 11/6/2022