Hypothesist.EF 3.0.91

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

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

nuget

Hypothesist.EF

Use Hypothesist to observe and validate entity events on an Entity Framework context.

Arrange

await using var context = new TestContext(...);
var observer = context.ObserverFor<Item>();

Act

context.Items.Add(new Item(0));
await context.SaveChangesAsync();

Assert

await Hypothesis
    .On(observer)
    .Timebox(2.Seconds())
    .Any()
    .Match(new Item(1))
    .Validate();

Filter

If you need the state change of the entity in your validation, specify the filter on the observer:

var observer = context.ObserverFor<Item>(EntityState.Added);

or:

var observer = context.ObserverFor<Item>(args => args.State == EntityState.Added);

Remark

Don't use this for normal straightforward in-process entity framework events where you can just use normal async/await operations. Use this as a validation entry-point for out-of-process interactions from a test with your system-under-test!

A great example is with dapr, where:

  1. your test invokes the sidecar
  2. the sidecar sends a message to a pub/sub broker
  3. the broker puts a request on your API endpoint
  4. the API endpoint invokes some business logic
  5. the business logic ultimately stores something in a database

Here you leverage the pluggable component of the database context to validate that the expected entity event occured. Another option is to hook into the middleware of ASP.NET, for example using the ASP.NET adapter.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
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
3.0.91 142 3/8/2024
3.0.89 109 3/8/2024

🤟