given-fixture 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package given-fixture --version 1.0.0
NuGet\Install-Package given-fixture -Version 1.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="given-fixture" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add given-fixture --version 1.0.0
#r "nuget: given-fixture, 1.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 given-fixture as a Cake Addin
#addin nuget:?package=given-fixture&version=1.0.0

// Install given-fixture as a Cake Tool
#tool nuget:?package=given-fixture&version=1.0.0

Build status NuGet

given-fixture

Simple but opinionated, fluent test fixture pattern.

Lets us write unit tests like this:

public class BreakfastServiceTests
{
    [Fact]
    public Task When_attempting_to_get_breakfast_with_null_request() =>
        Given.Fixture
             .When<BreakfastService, Breakfast>(x => x.GetBreakfastAsync(null))
             .ShouldThrowArgumentNullException("request")
             .RunAsync();

    [Fact]
    public Task When_attempting_to_get_breakfast_with_no_items() =>
        Given.Fixture
             .WhenGettingBreakfast()
             .ShouldThrowArgumentException("request")
             .RunAsync();

    [Fact]
    public Task When_getting_full_english_breakfast() =>
        Given.Fixture
             .HavingBreakfastItem(BreakfastItemType.Bacon, out var bacon)
             .HavingBreakfastItem(BreakfastItemType.Egg, out var egg)
             .HavingBreakfastItem(BreakfastItemType.Sausage, out var sausage)
             .HavingBreakfastItem(BreakfastItemType.Toast, out var toast)
             .WhenGettingBreakfast(BreakfastItemType.Bacon, BreakfastItemType.Egg,
                                   BreakfastItemType.Sausage, BreakfastItemType.Toast)
             .ShouldReturnBreakfastWithCorrectNameAndPrice("Full English Breakfast", bacon, egg, sausage, toast)
             .RunAsync();
}

We use extension methods to keep the fluent test conversation going:

internal static class BreakfastTestExtensions
{
    public static ITestFixture HavingBreakfastItem(this ITestFixture fixture, BreakfastItemType type, out BreakfastItem item) =>
        fixture.HavingModel(out item, c => c.With(x => x.Type, type)
                                            .With(x => x.Name, type.ToString()))
               .HavingMocked<IBreakfastItemRepository, BreakfastItem>(x => x.GetBreakfastItemAsync(type), item);


    public static ITestFixture WhenGettingBreakfast(this ITestFixture fixture, params BreakfastItemType[] types) =>
        fixture.When<BreakfastService, Breakfast>(x => x.GetBreakfastAsync(new GetBreakfastRequest { BreakfastItems = types }));

    public static ITestFixture ShouldReturnBreakfastWithCorrectNameAndPrice(this ITestFixture fixture,
                                                                            string expectedName,
                                                                            params BreakfastItem[] expectedItems) =>
        fixture.ShouldReturnEquivalent(new Breakfast { Name = expectedName, Price = expectedItems.Sum(i => i.Price) });
}
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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.35 13,459 8/25/2019
1.1.33 20,094 12/28/2018
1.1.31 699 12/28/2018
1.1.29 701 12/28/2018
1.1.27 744 12/28/2018
1.1.25 701 12/28/2018
1.1.23 755 12/26/2018
1.1.21 690 12/26/2018
1.1.19 735 12/20/2018
1.1.17 789 12/18/2018
1.1.15 708 12/17/2018
1.1.13 741 12/17/2018
1.1.11 727 12/9/2018
1.1.9 743 12/9/2018
1.1.7 761 12/7/2018
1.1.5 748 12/7/2018
1.0.2 936 11/28/2018
1.0.1 819 11/22/2018
1.0.0 754 11/22/2018