Orleans.FSharp.Testing
3.0.0
See the version list below for details.
dotnet add package Orleans.FSharp.Testing --version 3.0.0
NuGet\Install-Package Orleans.FSharp.Testing -Version 3.0.0
<PackageReference Include="Orleans.FSharp.Testing" Version="3.0.0" />
<PackageVersion Include="Orleans.FSharp.Testing" Version="3.0.0" />
<PackageReference Include="Orleans.FSharp.Testing" />
paket add Orleans.FSharp.Testing --version 3.0.0
#r "nuget: Orleans.FSharp.Testing, 3.0.0"
#:package Orleans.FSharp.Testing@3.0.0
#addin nuget:?package=Orleans.FSharp.Testing&version=3.0.0
#tool nuget:?package=Orleans.FSharp.Testing&version=3.0.0
Orleans.FSharp.Testing
Test utilities for Orleans.FSharp grains -- in-process clusters, mocks, property-based testing, and log capture.
Components
TestHarness
Wraps an Orleans TestCluster with memory storage, memory streams, and integrated log capture. Start and tear down a full in-process silo in a few lines:
let! harness = TestHarness.createTestCluster ()
let grain = harness.Client.GetGrain<IMyGrain>(grainId)
// ... test grain calls ...
do! harness.Cluster.StopAllSilosAsync()
GrainMock
A MockGrainFactory that implements IGrainFactory with predefined grain responses. Useful for unit testing grain-to-grain interactions without a real silo:
let factory = MockGrainFactory()
GrainMock.withGrain<IMyDep> "key" myMockImpl factory
WebTestHarness
For HTTP endpoint tests, you can run ASP.NET Core TestServer without Orleans TestCluster
and inject a mocked grain factory directly:
let! harness =
WebTestHarness.createWithMockFactory
(fun factory ->
factory
|> GrainMock.withFSharpGrain "company-1" companyGrainDefinition)
(fun web ->
web.Configure(fun app ->
app.Run(fun ctx ->
task {
let gf = ctx.RequestServices.GetRequiredService<IGrainFactory>()
let handle = FSharpGrain.ref<CompanyState, CompanyCommand> gf "company-1"
let! state = handle |> FSharpGrain.send Increment
return! ctx.Response.WriteAsync(string state.Count)
} :> Task))
|> ignore)
This keeps endpoint tests fast and deterministic while still exercising
FSharpGrain.ref/send flows.
WebTestHarness.createWithFactory and createWithMockFactory fail fast when
configureWeb already registers IGrainFactory, preventing ambiguous DI setup.
For typed query-style responses, use FSharpGrain.ask:
type CompanyState = { Count: int }
type CompanyCommand =
| Increment
| GetCount
let companyDef =
grain {
defaultState { Count = 0 }
handleTyped (fun state cmd ->
task {
match cmd with
| Increment ->
let next = { Count = state.Count + 1 }
return next, next.Count
| GetCount ->
return state, state.Count
})
}
let! harness =
WebTestHarness.createWithMockFactory
(fun factory -> factory |> GrainMock.withFSharpGrain "company-42" companyDef)
(fun web ->
web.Configure(fun app ->
app.Run(fun ctx ->
task {
let gf = ctx.RequestServices.GetRequiredService<IGrainFactory>()
let handle = FSharpGrain.ref<CompanyState, CompanyCommand> gf "company-42"
let! count = handle |> FSharpGrain.ask<CompanyState, CompanyCommand, int> GetCount
return! ctx.Response.WriteAsync(string count)
} :> Task))
|> ignore)
Use send when the handler result is the state; use ask when the handler returns
another typed value (for example int, DTO, tuple).
GrainArbitrary
TypeShape-based auto-generator of FsCheck Arbitrary instances for F# discriminated unions. Automatically discovers DU cases and field types to produce well-typed random grain states.
FsCheckHelpers
commandSequenceArb<'Command>-- generates non-empty command sequencesstateMachineProperty-- verifies a state invariant holds after folding a command list
LogCapture
CapturingLogger / CapturingLoggerFactory -- an in-memory ILogger implementation that records structured log entries (CapturedLogEntry) for test assertions on log level, template, properties, and exceptions.
Dependencies
Microsoft.Orleans.TestingHostFsCheck 3.xTypeShapexunit
License
MIT
| 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
- FsCheck (>= 3.3.3)
- FSharp.Control.TaskSeq (>= 0.6.0)
- FSharp.Core (>= 10.1.201)
- FSharp.SystemTextJson (>= 1.4.36)
- FsToolkit.ErrorHandling (>= 5.2.0)
- IcedTasks (>= 0.11.9)
- Microsoft.AspNetCore.TestHost (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.9)
- Microsoft.Extensions.Hosting (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Orleans.BroadcastChannel (>= 10.2.1)
- Microsoft.Orleans.Core.Abstractions (>= 10.2.1)
- Microsoft.Orleans.EventSourcing (>= 10.2.1)
- Microsoft.Orleans.Reminders (>= 10.2.1)
- Microsoft.Orleans.Runtime (>= 10.2.1)
- Microsoft.Orleans.Sdk (>= 10.2.1)
- Microsoft.Orleans.Serialization.SystemTextJson (>= 10.2.1)
- Microsoft.Orleans.Server (>= 10.2.1)
- Microsoft.Orleans.Streaming (>= 10.2.1)
- Microsoft.Orleans.TestingHost (>= 10.2.1)
- Microsoft.Orleans.Transactions (>= 10.2.1)
- Orleans.FSharp (>= 3.0.0)
- Orleans.FSharp.Runtime (>= 3.0.0)
- Polly (>= 8.7.0)
- Serilog.Extensions.Logging (>= 10.0.0)
- TypeShape (>= 10.0.0)
- xunit (>= 2.9.3)
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.1 | 108 | 6/29/2026 |
| 3.0.0 | 107 | 6/29/2026 |
| 2.0.0-alpha.1 | 63 | 4/28/2026 |
| 1.0.0 | 128 | 4/3/2026 |