Hypothesist.EF
3.0.89
See the version list below for details.
dotnet add package Hypothesist.EF --version 3.0.89
NuGet\Install-Package Hypothesist.EF -Version 3.0.89
<PackageReference Include="Hypothesist.EF" Version="3.0.89" />
paket add Hypothesist.EF --version 3.0.89
#r "nuget: Hypothesist.EF, 3.0.89"
// Install Hypothesist.EF as a Cake Addin #addin nuget:?package=Hypothesist.EF&version=3.0.89 // Install Hypothesist.EF as a Cake Tool #tool nuget:?package=Hypothesist.EF&version=3.0.89
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:
- your test invokes the sidecar
- the sidecar sends a message to a pub/sub broker
- the broker puts a request on your API endpoint
- the API endpoint invokes some business logic
- 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 | Versions 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. |
-
net7.0
- Hypothesist (>= 3.0.89)
- Microsoft.EntityFrameworkCore (>= 7.0.14)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
🤟