Class GrpcDelegateAssertionExtensions
- Namespace
- TUnit.Assertions.Extensions
- Assembly
- GrpcAssertions.TUnit.dll
TUnit entry points for asserting on gRPC call outcomes. These extend the delegate assertion
source produced by Assert.That(() => client.Method(...)), so the call is executed and
its thrown RpcException (if any) is inspected by the returned assertion. The
methods live in TUnit.Assertions.Extensions so they are auto-imported alongside TUnit's
own assertions.
public static class GrpcDelegateAssertionExtensions
- Inheritance
-
GrpcDelegateAssertionExtensions
- Inherited Members
Methods
DoesNotThrowGrpcException<TValue>(IDelegateAssertionSource<TValue>)
Asserts that the delegate completes without throwing a gRPC RpcException.
public static GrpcDoesNotThrowAssertion<TValue> DoesNotThrowGrpcException<TValue>(this IDelegateAssertionSource<TValue> source)
Parameters
sourceIDelegateAssertionSource<TValue>The delegate assertion source.
Returns
Type Parameters
TValueThe evaluated value type of the delegate under assertion.
Exceptions
- ArgumentNullException
sourceis null.
ThrowsGrpcException<TValue>(IDelegateAssertionSource<TValue>)
Asserts that the delegate throws a gRPC RpcException of any status. Chain
WithDetail / WithDetailContaining or a status shorthand (IsUnavailable(),
...) to narrow the assertion.
public static GrpcExceptionAssertion ThrowsGrpcException<TValue>(this IDelegateAssertionSource<TValue> source)
Parameters
sourceIDelegateAssertionSource<TValue>The delegate assertion source.
Returns
- GrpcExceptionAssertion
A GrpcExceptionAssertion for further chaining.
Type Parameters
TValueThe evaluated value type of the delegate under assertion.
Exceptions
- ArgumentNullException
sourceis null.
ThrowsGrpcException<TValue>(IDelegateAssertionSource<TValue>, StatusCode)
Asserts that the delegate throws a gRPC RpcException whose
StatusCode equals expected.
public static GrpcExceptionAssertion ThrowsGrpcException<TValue>(this IDelegateAssertionSource<TValue> source, StatusCode expected)
Parameters
sourceIDelegateAssertionSource<TValue>The delegate assertion source.
expectedStatusCodeThe expected gRPC status code.
Returns
- GrpcExceptionAssertion
A GrpcExceptionAssertion for further chaining.
Type Parameters
TValueThe evaluated value type of the delegate under assertion.
Exceptions
- ArgumentNullException
sourceis null.