public async stt::Task RawPredictResourceNamesAsync() { moq::Mock <PredictionService.PredictionServiceClient> mockGrpcClient = new moq::Mock <PredictionService.PredictionServiceClient>(moq::MockBehavior.Strict); RawPredictRequest request = new RawPredictRequest { EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), HttpBody = new ga::HttpBody(), }; ga::HttpBody expectedResponse = new ga::HttpBody { ContentType = "content_type085be0ea", Data = proto::ByteString.CopyFromUtf8("data387f778d"), Extensions = { new wkt::Any(), }, }; mockGrpcClient.Setup(x => x.RawPredictAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ga::HttpBody>(stt::Task.FromResult(expectedResponse), null, null, null, null)); PredictionServiceClient client = new PredictionServiceClientImpl(mockGrpcClient.Object, null); ga::HttpBody responseCallSettings = await client.RawPredictAsync(request.EndpointAsEndpointName, request.HttpBody, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ga::HttpBody responseCancellationToken = await client.RawPredictAsync(request.EndpointAsEndpointName, request.HttpBody, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for RawPredict</summary> public void RawPredictRequestObject() { // Snippet: RawPredict(RawPredictRequest, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) RawPredictRequest request = new RawPredictRequest { EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), HttpBody = new HttpBody(), }; // Make the request HttpBody response = predictionServiceClient.RawPredict(request); // End snippet }
/// <summary>Snippet for RawPredictAsync</summary> public async Task RawPredictRequestObjectAsync() { // Snippet: RawPredictAsync(RawPredictRequest, CallSettings) // Additional: RawPredictAsync(RawPredictRequest, CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) RawPredictRequest request = new RawPredictRequest { EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), HttpBody = new HttpBody(), }; // Make the request HttpBody response = await predictionServiceClient.RawPredictAsync(request); // End snippet }
public void RawPredictResourceNames() { moq::Mock <PredictionService.PredictionServiceClient> mockGrpcClient = new moq::Mock <PredictionService.PredictionServiceClient>(moq::MockBehavior.Strict); RawPredictRequest request = new RawPredictRequest { EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), HttpBody = new ga::HttpBody(), }; ga::HttpBody expectedResponse = new ga::HttpBody { ContentType = "content_type085be0ea", Data = proto::ByteString.CopyFromUtf8("data387f778d"), Extensions = { new wkt::Any(), }, }; mockGrpcClient.Setup(x => x.RawPredict(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PredictionServiceClient client = new PredictionServiceClientImpl(mockGrpcClient.Object, null); ga::HttpBody response = client.RawPredict(request.EndpointAsEndpointName, request.HttpBody); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }