Hypothesist 2.0.16

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

// Install Hypothesist as a Cake Tool
#tool nuget:?package=Hypothesist&version=2.0.16                

nuget

Hypothesist

The future assertion library for .NET.

This library is there to help you do assertions on events that are about to happen in the near future. For example, when building integration tests for a subscriber on a service bus.

schema

Define

Define your hypothesis with an experiment, time constraint and test:

var hypothesis = Hypothesis
    .For<Data>()
    .Any(x => x.Value == 1234);

Test

You test your hypothesis by providing samples:

await hypothesis.Test(sample);

For example with an injected stub:

var service = Substitute.For<IDemoService>();
service
    .When(x => x.Demo(Arg.Any<Data>()))
    .Do(x => hypothesis.Test(x.Arg<Data>()));

or with a hand-rolled implementation:

class TestService : IDemoService
{
    private readonly IHypothesis<Data> _hypothesis;

    public TestService(IHypothesis<Data> hypothesis) => 
        _hypothesis = hypothesis;

    public Task Demo(Data data) =>
        _hypothesis.Test(data);
}

var service = new TestService(hypothesis);

or with the consumer factory Hypothesist.MassTransit when using MassTransit:

cfg.ReceiveEndpoint("...", x =>
{
    x.Consumer(hypothesis.AsConsumer);
});

Validate

You validate if your hypothesis holds true for the supplied samples during the specified time window.

await hypothesis.Validate(15.Seconds()); // <-- using TimeSpan extension from FluentAssertions

But somewhere in between you've fired off the eventing mechanism that ultimately invokes the injected service.

Experiments

The two parts of the hypothesis are the experiment and a time constraint.

Any

Validates that at least one item matches the assertion, meaning the experiment stops when this item is observed.

All

Validates that all items that are observed during the experiment matches the assertion.

Remark: having no items observed during the time window also means the hypothesis holds true;

First

Validates that the first item that is observed matches the assertion.

Single

Validates that exactly one item is observed that matches the assertion.

Remark: having other items not matching the assert means the hypothesis still holds true.

Exactly

Validates that exactly the given number of occurrences is observed that matches the assertion within the given timeframe.

AtLeast

Validates that at least the given number of occurrences is observed that matches the assertion.

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 netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Hypothesist:

Package Downloads
Hypothesist.MassTransit

Plugin the hypothesis as a consumer into MassTransit to validate message arrival.

Hypothesist.Rebus

Plugin the hypothesis as a handler into Rebus to validate message arrival.

Hypothesist.ServiceBus

Test your hypothesis easily with a ServiceBusProcessor.

Hypothesist.AspNet

Plugin the hypothesis as a middleware into aspnet to validate requests and responses.

Hypothesist.EF

Plugin the hypothesis as a handler into Entity Framework to validate entity events.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Hypothesist:

Repository Stars
mehdihadeli/food-delivery-microservices
🍔 A practical and imaginary food delivery microservices, built with .Net 8, MassTransit, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
Eventuous/eventuous
Event Sourcing library for .NET
mehdihadeli/food-delivery-modular-monolith
🌭 A practical and imaginary food and grocery delivery modular monolith, built with .Net 8, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
Version Downloads Last updated
3.0.91 758 3/8/2024
3.0.89 252 3/8/2024
3.0.88 1,745 1/11/2024
2.2.72 544 11/23/2023
2.2.71 275 11/23/2023
2.2.66 596 11/6/2023
2.2.64 271 11/6/2023
2.2.63 294 11/2/2023
2.1.62 278 11/2/2023
2.1.61 256 11/2/2023
2.1.60 259 11/1/2023
2.1.55 2,259 3/2/2023
2.1.52 585 3/2/2023
2.1.50 1,225 1/31/2023
2.1.49 597 1/27/2023
2.1.44 708 12/5/2022
2.1.39 663 11/30/2022
2.0.30 13,642 2/4/2022
2.0.28 916 2/4/2022
2.0.23 1,481 11/1/2021
2.0.22 950 9/14/2021
2.0.20 582 9/14/2021
2.0.17 585 9/13/2021
2.0.16 698 9/13/2021
2.0.12 2,003 6/10/2021
2.0.11 397 6/8/2021
1.3.1 411 6/2/2021

🤟