GrpcAssertions 0.3.0
Prefix Reserveddotnet add package GrpcAssertions --version 0.3.0
NuGet\Install-Package GrpcAssertions -Version 0.3.0
<PackageReference Include="GrpcAssertions" Version="0.3.0" />
<PackageVersion Include="GrpcAssertions" Version="0.3.0" />
<PackageReference Include="GrpcAssertions" />
paket add GrpcAssertions --version 0.3.0
#r "nuget: GrpcAssertions, 0.3.0"
#:package GrpcAssertions@0.3.0
#addin nuget:?package=GrpcAssertions&version=0.3.0
#tool nuget:?package=GrpcAssertions&version=0.3.0
GrpcAssertions
Scope: Test projects only. Not intended for production code.
Framework-agnostic core for the GrpcAssertions package family. The TUnit-native fluent assertion entry points ship in the adapter package GrpcAssertions.TUnit.
Most users want
GrpcAssertions.TUnit, not this package directly. Install this core directly only when authoring a non-TUnit adapter or when you only need the test-double builder and predicates.
What's in this package
GrpcCallBuilder: builds gRPC client test doubles, replacing the multi-parameter constructor every hand-rolled fake repeats.AsyncUnaryCall<T>viaSuccess<T>(T)(infersTfrom its argument),Faulted<T>(RpcException)andFaulted<T>(StatusCode, string?)(need the explicitT);AsyncServerStreamingCall<T>viaServerStreaming<T>(IEnumerable<T>)andServerStreamingFaulted<T>(StatusCode, IEnumerable<T>, string?)(v0.3.0+). The GitHub README has a before/after recipe for replacing hand-rolled factories.GrpcOutcomeRendering: renders a gRPC outcome (StatusCodeplus truncatedStatus.Detail) for failure messages, shared so consumer-authored gRPC assertions produce identical diagnostics.GrpcExceptions:IsRpcException(Exception?)reports whether an exception is a gRPCRpcException(null and non-RpcExceptiontypes returnfalse).
All over the single Grpc.Core.Api dependency (RpcException / StatusCode / Status).
Install
dotnet add package GrpcAssertions.TUnit
The core (GrpcAssertions) comes transitively; install it directly only when authoring a non-TUnit adapter for the assertion family.
License
MIT throughout. Takes a single runtime dependency on Grpc.Core.Api (Apache-2.0), the package that defines the gRPC RpcException / StatusCode / Status types the assertions are about.
| 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
- Grpc.Core.Api (>= 2.80.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on GrpcAssertions:
| Package | Downloads |
|---|---|
|
GrpcAssertions.TUnit
TUnit-native gRPC assertions for .NET tests. Fluent ThrowsGrpcException / DoesNotThrowGrpcException on a delegate, with StatusCode shorthands (IsUnavailable, IsNotFound, and the rest) and WithDetail / WithDetailContaining refinements, plus the IsRpcException discriminator and the GrpcCallBuilder test-double helper from the framework-agnostic core. AOT-compatible, trimmable, no runtime reflection in the assertion path. |
GitHub repositories
This package is not used by any popular GitHub repositories.
View the rendered release notes: https://github.com/JohnVerheij/GrpcAssertions.TUnit/releases/tag/v0.3.0
Minor release. Extends the builder and the assertion surface from unary calls to server-streaming calls: `GrpcCallBuilder` now constructs `AsyncServerStreamingCall<T>` test doubles, and a `Streams()` chain asserts on the streamed responses. Purely additive; the `0.2.0` ApiCompat baseline is preserved.
### Added
- **`GrpcCallBuilder.ServerStreaming<TResponse>(IEnumerable<TResponse> responses)`** builds a successful server-streaming call whose response stream yields the responses in order and then ends cleanly with a terminal `StatusCode.OK`.
- **`GrpcCallBuilder.ServerStreamingFaulted<TResponse>(StatusCode statusCode, IEnumerable<TResponse> responses, string? detail = null)`** builds a server-streaming call that yields the responses and then throws an `RpcException` on the next read, so a wrapper's mid-stream fault handling can be exercised.
- **`Streams()`** on an `AsyncServerStreamingCall<TResponse>` begins a server-streaming assertion that reads the response stream once. Chain **`StreamsAtLeast(int)`** / **`StreamsExactly(int)`** to assert the response count, **`StreamContains(Func<TResponse, bool>)`** to assert at least one response matches (the predicate text is captured for the failure message), and **`AndStreamItems(Func<IReadOnlyList<TResponse>, Task>)`** to run follow-on assertions against the materialized responses without re-reading the stream. A stream that faults mid-read fails with the partial count and the rendered gRPC outcome.