Class FakeApiCall (4.4.0)

public static class FakeApiCall

Helper class to use when faking services; enables ApiCall<TRequest, TResponse> objects to be created without gRPC

Inheritance

object > FakeApiCall

Namespace

Google.Api.Gax.Grpc.Testing

Assembly

Google.Api.Gax.Grpc.Testing.dll

Methods

Create<TRequest, TResponse>(Func<TRequest, CallOptions, TResponse>, CallSettings, IClock)

public static ApiCall<TRequest, TResponse> Create<TRequest, TResponse>(Func<TRequest, CallOptions, TResponse> syncCall, CallSettings baseCallSettings = null, IClock clock = null) where TRequest : class, IMessage<TRequest> where TResponse : class, IMessage<TResponse>

Creates an API call from a synchronous function, which is just called synchronously for asynchronous requests.

Parameters
Name Description
syncCall FuncCallOptions

Function to call for sync requests

baseCallSettings CallSettings

The default call settings. May be null.

clock IClock

The clock to use; defaults to a new FakeClock.

Returns
Type Description
ApiCall

The new API call.

Type Parameters
Name Description
TRequest

Request type

TResponse

Response type

Remarks

For asynchronous requests, the synchronous function is called but within an async context; exceptions will still be reported back via the returned task, but the call will complete synchronously.

Create<TRequest, TResponse>(Func<TRequest, CallOptions, Task<TResponse>>, Func<TRequest, CallOptions, TResponse>, CallSettings, IClock)

public static ApiCall<TRequest, TResponse> Create<TRequest, TResponse>(Func<TRequest, CallOptions, Task<TResponse>> asyncCall, Func<TRequest, CallOptions, TResponse> syncCall, CallSettings baseCallSettings = null, IClock clock = null) where TRequest : class, IMessage<TRequest> where TResponse : class, IMessage<TResponse>

Creates an API call from the given async/sync functions.

Parameters
Name Description
asyncCall FuncCallOptionsTask

Function to call for async requests

syncCall FuncCallOptions

Function to call for sync requests

baseCallSettings CallSettings

The default call settings. May be null.

clock IClock

The clock to use; defaults to a new FakeClock.

Returns
Type Description
ApiCall

The new API call.

Type Parameters
Name Description
TRequest

Request type

TResponse

Response type