#region Copyright notice and license
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion
using System;
using System.Threading.Tasks;
using Grpc.Core;
namespace Grpc.Core.Testing
{
///
/// Test doubles for client-side call objects.
///
public static class TestCalls
{
///
/// Creates a test double for AsyncUnaryCall. Only for testing.
/// Note: experimental API that can change or be removed without any prior notice.
///
public static AsyncUnaryCall AsyncUnaryCall (
Task responseAsync, Task responseHeadersAsync, Func getStatusFunc,
Func getTrailersFunc, Action disposeAction)
{
return new AsyncUnaryCall(responseAsync, responseHeadersAsync, getStatusFunc, getTrailersFunc, disposeAction);
}
///
/// Creates a test double for AsyncClientStreamingCall. Only for testing.
/// Note: experimental API that can change or be removed without any prior notice.
///
public static AsyncClientStreamingCall AsyncClientStreamingCall(
IClientStreamWriter requestStream, Task responseAsync,
Task responseHeadersAsync, Func getStatusFunc,
Func getTrailersFunc, Action disposeAction)
{
return new AsyncClientStreamingCall(requestStream, responseAsync, responseHeadersAsync, getStatusFunc, getTrailersFunc, disposeAction);
}
///
/// Creates a test double for AsyncServerStreamingCall. Only for testing.
/// Note: experimental API that can change or be removed without any prior notice.
///
public static AsyncServerStreamingCall AsyncServerStreamingCall(
IAsyncStreamReader responseStream, Task responseHeadersAsync,
Func getStatusFunc, Func getTrailersFunc, Action disposeAction)
{
return new AsyncServerStreamingCall(responseStream, responseHeadersAsync, getStatusFunc, getTrailersFunc, disposeAction);
}
///
/// Creates a test double for AsyncDuplexStreamingCall. Only for testing.
/// Note: experimental API that can change or be removed without any prior notice.
///
public static AsyncDuplexStreamingCall AsyncDuplexStreamingCall(
IClientStreamWriter requestStream, IAsyncStreamReader responseStream,
Task responseHeadersAsync, Func getStatusFunc,
Func getTrailersFunc, Action disposeAction)
{
return new AsyncDuplexStreamingCall(requestStream, responseStream, responseHeadersAsync, getStatusFunc, getTrailersFunc, disposeAction);
}
}
}