Conjecture.Interactions
0.29.0
dotnet add package Conjecture.Interactions --version 0.29.0
NuGet\Install-Package Conjecture.Interactions -Version 0.29.0
<PackageReference Include="Conjecture.Interactions" Version="0.29.0" />
<PackageVersion Include="Conjecture.Interactions" Version="0.29.0" />
<PackageReference Include="Conjecture.Interactions" />
paket add Conjecture.Interactions --version 0.29.0
#r "nuget: Conjecture.Interactions, 0.29.0"
#:package Conjecture.Interactions@0.29.0
#addin nuget:?package=Conjecture.Interactions&version=0.29.0
#tool nuget:?package=Conjecture.Interactions&version=0.29.0
Conjecture.Interactions
Transport-agnostic interaction abstractions for Conjecture. Provides the building blocks (IInteraction, IInteractionTarget, InteractionStateMachine<TState>) that satellite packages — Conjecture.Http, Conjecture.Grpc, Conjecture.Messaging, Conjecture.EFCore — implement, so a single property test can drive HTTP + DB + queue side effects through one model.
Install
dotnet add package Conjecture.Core
dotnet add package Conjecture.Interactions
You usually depend on this package transitively via one of the satellite packages. Use it directly when modeling a custom transport.
Usage
using Conjecture.Core;
using Conjecture.Interactions;
public sealed record CounterState(int Value);
public sealed record IncrementInteraction(int By) : IInteraction;
public sealed class Counter : IInteractionTarget
{
public int Value;
public Task<object?> ExecuteAsync(IInteraction interaction, CancellationToken ct)
{
if (interaction is IncrementInteraction inc)
{
this.Value += inc.By;
}
return Task.FromResult<object?>(this.Value);
}
}
public sealed class CounterMachine : InteractionStateMachine<CounterState>
{
public override CounterState InitialState() => new(0);
public override IEnumerable<Strategy<IInteraction>> Commands(CounterState state)
{
yield return Strategy.Integers<int>(1, 10).Select(by => (IInteraction)new IncrementInteraction(by));
}
public override CounterState RunCommand(CounterState state, IInteraction interaction, IInteractionTarget target, CancellationToken ct)
{
IncrementInteraction inc = (IncrementInteraction)interaction;
return state with { Value = state.Value + inc.By };
}
public override void Invariant(CounterState state)
{
if (state.Value < 0) { throw new InvalidOperationException("counter went negative"); }
}
}
Then run with:
await Property.ForAll(new Counter(), new CounterMachine());
Types
| Type | Role |
|---|---|
IInteraction |
Marker interface for interaction messages. |
IAddressedInteraction |
Interaction tied to a named resource. |
IInteractionTarget |
Executes an interaction and returns an optional result. |
CompositeInteractionTarget |
Routes interactions to multiple named targets. |
InteractionStateMachine<TState> |
Stateful test model with Commands, RunCommand, Invariant. |
Property.ForAll(...) |
Runs a property or a state machine with shrinking. |
Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Conjecture.Core (>= 0.29.0)
- Conjecture.Interactions.Abstractions (>= 0.29.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.