GrpcAssertions 0.3.0

Prefix Reserved
dotnet add package GrpcAssertions --version 0.3.0
                    
NuGet\Install-Package GrpcAssertions -Version 0.3.0
                    
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="GrpcAssertions" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GrpcAssertions" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="GrpcAssertions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GrpcAssertions --version 0.3.0
                    
#r "nuget: GrpcAssertions, 0.3.0"
                    
#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.
#:package GrpcAssertions@0.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GrpcAssertions&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=GrpcAssertions&version=0.3.0
                    
Install as a Cake Tool

GrpcAssertions

NuGet License: MIT .NET

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> via Success<T>(T) (infers T from its argument), Faulted<T>(RpcException) and Faulted<T>(StatusCode, string?) (need the explicit T); AsyncServerStreamingCall<T> via ServerStreaming<T>(IEnumerable<T>) and ServerStreamingFaulted<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 (StatusCode plus truncated Status.Detail) for failure messages, shared so consumer-authored gRPC assertions produce identical diagnostics.
  • GrpcExceptions: IsRpcException(Exception?) reports whether an exception is a gRPC RpcException (null and non-RpcException types return false).

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
0.3.0 440 6/14/2026
0.2.0 1,571 6/12/2026
0.1.2 170 6/5/2026
0.1.1 243 6/4/2026
0.1.0 175 6/2/2026
0.0.1 174 6/1/2026

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.