Class FakeApiCall (3.2.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
NameDescription
syncCallFunc<TRequest, CallOptions, TResponse>

Function to call for sync requests

baseCallSettingsCallSettings

The default call settings. May be null.

clockIClock

The clock to use; defaults to a new FakeClock.

Returns
TypeDescription
ApiCall<TRequest, TResponse>

The new API call.

Type Parameters
NameDescription
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
NameDescription
asyncCallFunc<TRequest, CallOptions, Task<TResponse>>

Function to call for async requests

syncCallFunc<TRequest, CallOptions, TResponse>

Function to call for sync requests

baseCallSettingsCallSettings

The default call settings. May be null.

clockIClock

The clock to use; defaults to a new FakeClock.

Returns
TypeDescription
ApiCall<TRequest, TResponse>

The new API call.

Type Parameters
NameDescription
TRequest

Request type

TResponse

Response type