public async Task AnnotateTextAsync()
        {
            Mock <LanguageService.LanguageServiceClient> mockGrpcClient = new Mock <LanguageService.LanguageServiceClient>(MockBehavior.Strict);
            AnnotateTextRequest expectedRequest = new AnnotateTextRequest
            {
                Document     = new Document(),
                Features     = new AnnotateTextRequest.Types.Features(),
                EncodingType = EncodingType.None,
            };
            AnnotateTextResponse expectedResponse = new AnnotateTextResponse
            {
                Language = "language-1613589672",
            };

            mockGrpcClient.Setup(x => x.AnnotateTextAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <AnnotateTextResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            LanguageServiceClient client = new LanguageServiceClientImpl(mockGrpcClient.Object, null);
            Document document            = new Document();

            AnnotateTextRequest.Types.Features features = new AnnotateTextRequest.Types.Features();
            EncodingType         encodingType           = EncodingType.None;
            AnnotateTextResponse response = await client.AnnotateTextAsync(document, features, encodingType);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #2
0
 /// <summary>
 /// A convenience method that provides all the features that analyzeSentiment,
 /// analyzeEntities, and analyzeSyntax provide in one call.
 /// </summary>
 /// <param name="request">
 /// The request object containing all of the parameters for the API call.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// The RPC response.
 /// </returns>
 public override AnnotateTextResponse AnnotateText(
     AnnotateTextRequest request,
     CallSettings callSettings = null)
 {
     Modify_AnnotateTextRequest(ref request, ref callSettings);
     return(_callAnnotateText.Sync(request, callSettings));
 }
        public async stt::Task AnnotateText1Async()
        {
            moq::Mock <LanguageService.LanguageServiceClient> mockGrpcClient = new moq::Mock <LanguageService.LanguageServiceClient>(moq::MockBehavior.Strict);
            AnnotateTextRequest request = new AnnotateTextRequest
            {
                Document     = new Document(),
                Features     = new AnnotateTextRequest.Types.Features(),
                EncodingType = EncodingType.None,
            };
            AnnotateTextResponse expectedResponse = new AnnotateTextResponse
            {
                Sentences         = { new Sentence(), },
                Tokens            = { new Token(), },
                Entities          = { new Entity(), },
                DocumentSentiment = new Sentiment(),
                Language          = "language7dae1285",
                Categories        =
                {
                    new ClassificationCategory(),
                },
            };

            mockGrpcClient.Setup(x => x.AnnotateTextAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AnnotateTextResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            LanguageServiceClient client = new LanguageServiceClientImpl(mockGrpcClient.Object, null);
            AnnotateTextResponse  responseCallSettings = await client.AnnotateTextAsync(request.Document, request.Features, request.EncodingType, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            AnnotateTextResponse responseCancellationToken = await client.AnnotateTextAsync(request.Document, request.Features, request.EncodingType, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void AnnotateText1()
        {
            moq::Mock <LanguageService.LanguageServiceClient> mockGrpcClient = new moq::Mock <LanguageService.LanguageServiceClient>(moq::MockBehavior.Strict);
            AnnotateTextRequest request = new AnnotateTextRequest
            {
                Document     = new Document(),
                Features     = new AnnotateTextRequest.Types.Features(),
                EncodingType = EncodingType.None,
            };
            AnnotateTextResponse expectedResponse = new AnnotateTextResponse
            {
                Sentences         = { new Sentence(), },
                Tokens            = { new Token(), },
                Entities          = { new Entity(), },
                DocumentSentiment = new Sentiment(),
                Language          = "language7dae1285",
                Categories        =
                {
                    new ClassificationCategory(),
                },
            };

            mockGrpcClient.Setup(x => x.AnnotateText(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            LanguageServiceClient client   = new LanguageServiceClientImpl(mockGrpcClient.Object, null);
            AnnotateTextResponse  response = client.AnnotateText(request.Document, request.Features, request.EncodingType);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #5
0
 public void AnnotateText_RequestObject()
 {
     // Snippet: AnnotateText(AnnotateTextRequest,CallSettings)
     // Create client
     LanguageServiceClient languageServiceClient = LanguageServiceClient.Create();
     // Initialize request argument(s)
     AnnotateTextRequest request = new AnnotateTextRequest
     {
         Document = new Document(),
         Features = new AnnotateTextRequest.Types.Features(),
     };
     // Make the request
     AnnotateTextResponse response = languageServiceClient.AnnotateText(request);
     // End snippet
 }
Пример #6
0
        /// <summary>
        /// A convenience method that provides all the features that analyzeSentiment,
        /// analyzeEntities, and analyzeSyntax provide in one call.
        /// </summary>
        /// <param name="document">
        /// Input document.
        /// </param>
        /// <param name="features">
        /// The enabled features.
        /// </param>
        /// <param name="encodingType">
        /// The encoding type used by the API to calculate offsets.
        /// </param>
        /// <param name="callSettings">
        /// If not null, applies overrides to this RPC call.
        /// </param>
        /// <returns>
        /// The RPC response.
        /// </returns>
        public override AnnotateTextResponse AnnotateText(
            Document document,
            AnnotateTextRequest.Types.Features features,
            EncodingType encodingType,
            CallSettings callSettings = null)
        {
            AnnotateTextRequest request = new AnnotateTextRequest
            {
                Document     = document,
                Features     = features,
                EncodingType = encodingType,
            };

            Modify_AnnotateTextRequest(ref request, ref callSettings);
            return(_callAnnotateText.Sync(request, callSettings));
        }
        public async Task AnnotateTextAsync_RequestObject()
        {
            // Snippet: AnnotateTextAsync(AnnotateTextRequest,CallSettings)
            // Create client
            LanguageServiceClient languageServiceClient = await LanguageServiceClient.CreateAsync();

            // Initialize request argument(s)
            AnnotateTextRequest request = new AnnotateTextRequest
            {
                Document     = new Document(),
                Features     = new AnnotateTextRequest.Types.Features(),
                EncodingType = EncodingType.None,
            };
            // Make the request
            AnnotateTextResponse response = await languageServiceClient.AnnotateTextAsync(request);

            // End snippet
        }
        public void AnnotateText2()
        {
            Mock <LanguageService.LanguageServiceClient> mockGrpcClient = new Mock <LanguageService.LanguageServiceClient>(MockBehavior.Strict);
            AnnotateTextRequest request = new AnnotateTextRequest
            {
                Document = new Document(),
                Features = new AnnotateTextRequest.Types.Features(),
            };
            AnnotateTextResponse expectedResponse = new AnnotateTextResponse
            {
                Language = "language-1613589672",
            };

            mockGrpcClient.Setup(x => x.AnnotateText(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            LanguageServiceClient client   = new LanguageServiceClientImpl(mockGrpcClient.Object, null);
            AnnotateTextResponse  response = client.AnnotateText(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #9
0
 partial void Modify_AnnotateTextRequest(ref AnnotateTextRequest request, ref CallSettings settings);
Пример #10
0
 /// <summary>
 /// A convenience method that provides all the features that analyzeSentiment,
 /// analyzeEntities, and analyzeSyntax provide in one call.
 /// </summary>
 /// <param name="request">
 /// The request object containing all of the parameters for the API call.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// The RPC response.
 /// </returns>
 public virtual AnnotateTextResponse AnnotateText(
     AnnotateTextRequest request,
     CallSettings callSettings = null)
 {
     throw new NotImplementedException();
 }
Пример #11
0
        /// Documentation https://developers.google.com/cloudnaturallanguage/v1/reference/documents/annotateText
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated CloudNaturalLanguage service.</param>
        /// <param name="body">A valid CloudNaturalLanguage v1 body.</param>
        /// <returns>AnnotateTextResponseResponse</returns>
        public static AnnotateTextResponse AnnotateText(CloudNaturalLanguageService service, AnnotateTextRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }

                // Make the request.
                return(service.Documents.AnnotateText(body).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Documents.AnnotateText failed.", ex);
            }
        }