given-fixture 1.0.0

.NET Standard 2.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


Simple but opinionated, fluent test fixture pattern.

Lets us write unit tests like this:

public class BreakfastServiceTests
    public Task When_attempting_to_get_breakfast_with_null_request() =>
             .When<BreakfastService, Breakfast>(x => x.GetBreakfastAsync(null))

    public Task When_attempting_to_get_breakfast_with_no_items() =>

    public Task When_getting_full_english_breakfast() =>
             .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)

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. 
.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)
Additional computed target framework(s)
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 11,334 8/25/2019
1.1.33 18,383 12/28/2018
1.1.31 641 12/28/2018
1.1.29 628 12/28/2018
1.1.27 670 12/28/2018
1.1.25 641 12/28/2018
1.1.23 693 12/26/2018
1.1.21 634 12/26/2018
1.1.19 677 12/20/2018
1.1.17 728 12/18/2018
1.1.15 631 12/17/2018
1.1.13 676 12/17/2018
1.1.11 658 12/9/2018
1.1.9 664 12/9/2018
1.1.7 687 12/7/2018
1.1.5 680 12/7/2018
1.0.2 860 11/28/2018
1.0.1 738 11/22/2018
1.0.0 697 11/22/2018