Exemple #1
0
        public void CompleteQueryRequestObject()
        {
            moq::Mock <Completion.CompletionClient> mockGrpcClient = new moq::Mock <Completion.CompletionClient>(moq::MockBehavior.Strict);
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                ParentAsTenantOrProjectName = TenantOrProjectName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                Query         = "queryf0c71c1b",
                LanguageCodes =
                {
                    "language_codes1de1a181",
                },
                PageSize             = -226905851,
                CompanyAsCompanyName = CompanyName.FromProjectCompany("[PROJECT]", "[COMPANY]"),
                Scope = CompleteQueryRequest.Types.CompletionScope.Unspecified,
                Type  = CompleteQueryRequest.Types.CompletionType.Combined,
            };
            CompleteQueryResponse expectedResponse = new CompleteQueryResponse
            {
                CompletionResults =
                {
                    new CompleteQueryResponse.Types.CompletionResult(),
                },
                Metadata = new ResponseMetadata(),
            };

            mockGrpcClient.Setup(x => x.CompleteQuery(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CompletionClient      client   = new CompletionClientImpl(mockGrpcClient.Object, null);
            CompleteQueryResponse response = client.CompleteQuery(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemple #2
0
        public async stt::Task CompleteQueryRequestObjectAsync()
        {
            moq::Mock <Completion.CompletionClient> mockGrpcClient = new moq::Mock <Completion.CompletionClient>(moq::MockBehavior.Strict);
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                ParentAsTenantOrProjectName = TenantOrProjectName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                Query         = "queryf0c71c1b",
                LanguageCodes =
                {
                    "language_codes1de1a181",
                },
                PageSize             = -226905851,
                CompanyAsCompanyName = CompanyName.FromProjectCompany("[PROJECT]", "[COMPANY]"),
                Scope = CompleteQueryRequest.Types.CompletionScope.Unspecified,
                Type  = CompleteQueryRequest.Types.CompletionType.Combined,
            };
            CompleteQueryResponse expectedResponse = new CompleteQueryResponse
            {
                CompletionResults =
                {
                    new CompleteQueryResponse.Types.CompletionResult(),
                },
                Metadata = new ResponseMetadata(),
            };

            mockGrpcClient.Setup(x => x.CompleteQueryAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <CompleteQueryResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CompletionClient      client = new CompletionClientImpl(mockGrpcClient.Object, null);
            CompleteQueryResponse responseCallSettings = await client.CompleteQueryAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            CompleteQueryResponse responseCancellationToken = await client.CompleteQueryAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for CompleteQuery</summary>
 public void CompleteQuery_RequestObject()
 {
     // Snippet: CompleteQuery(CompleteQueryRequest,CallSettings)
     // Create client
     CompletionClient completionClient = CompletionClient.Create();
     // Initialize request argument(s)
     CompleteQueryRequest request = new CompleteQueryRequest
     {
         ProjectName = new ProjectName("[PROJECT]"),
         Query       = "",
         PageSize    = 0,
     };
     // Make the request
     CompleteQueryResponse response = completionClient.CompleteQuery(request);
     // End snippet
 }
 /// <summary>Snippet for CompleteQuery</summary>
 public void CompleteQuery_RequestObject()
 {
     // Snippet: CompleteQuery(CompleteQueryRequest,CallSettings)
     // Create client
     CompletionClient completionClient = CompletionClient.Create();
     // Initialize request argument(s)
     CompleteQueryRequest request = new CompleteQueryRequest
     {
         ParentAsTenantOrProjectNameOneof = TenantOrProjectNameOneof.From(new TenantName("[PROJECT]", "[TENANT]")),
         Query    = "",
         PageSize = 0,
     };
     // Make the request
     CompleteQueryResponse response = completionClient.CompleteQuery(request);
     // End snippet
 }
        public async Task CompleteQueryAsync()
        {
            Mock <Completion.CompletionClient> mockGrpcClient = new Mock <Completion.CompletionClient>(MockBehavior.Strict);
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                ProjectName = new ProjectName("[PROJECT]"),
                Query       = "query107944136",
                PageSize    = 883849137,
            };
            CompleteQueryResponse expectedResponse = new CompleteQueryResponse();

            mockGrpcClient.Setup(x => x.CompleteQueryAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <CompleteQueryResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CompletionClient      client   = new CompletionClientImpl(mockGrpcClient.Object, null);
            CompleteQueryResponse response = await client.CompleteQueryAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void CompleteQuery()
        {
            Mock <Completion.CompletionClient> mockGrpcClient = new Mock <Completion.CompletionClient>(MockBehavior.Strict);
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                ProjectName = new ProjectName("[PROJECT]"),
                Query       = "query107944136",
                PageSize    = 883849137,
            };
            CompleteQueryResponse expectedResponse = new CompleteQueryResponse();

            mockGrpcClient.Setup(x => x.CompleteQuery(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CompletionClient      client   = new CompletionClientImpl(mockGrpcClient.Object, null);
            CompleteQueryResponse response = client.CompleteQuery(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for CompleteQueryAsync</summary>
        public async Task CompleteQueryAsync_RequestObject()
        {
            // Snippet: CompleteQueryAsync(CompleteQueryRequest,CallSettings)
            // Additional: CompleteQueryAsync(CompleteQueryRequest,CancellationToken)
            // Create client
            CompletionClient completionClient = await CompletionClient.CreateAsync();

            // Initialize request argument(s)
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                ParentAsTenantOrProjectNameOneof = TenantOrProjectNameOneof.From(new TenantName("[PROJECT]", "[TENANT]")),
                Query    = "",
                PageSize = 0,
            };
            // Make the request
            CompleteQueryResponse response = await completionClient.CompleteQueryAsync(request);

            // End snippet
        }
        // [END histogram_search]

        // [START auto_complete_job_title]

        public static void JobTitleAutoComplete(String companyName, String query)
        {
            CompleteRequest completeRequest = new CompleteRequest(jobServiceClient, parent)
            {
                Query        = query,
                LanguageCode = "en-US",
                Type         = CompleteRequest.TypeEnum.JOBTITLE,
                PageSize     = 10
            };

            if (companyName != null)
            {
                completeRequest.CompanyName = companyName;
            }

            CompleteQueryResponse results = completeRequest.Execute();

            Console.WriteLine("Completion results: " + ToJsonString(results));
        }
        /// <summary>Snippet for CompleteQueryAsync</summary>
        public async Task CompleteQueryAsync_RequestObject()
        {
            // Snippet: CompleteQueryAsync(CompleteQueryRequest,CallSettings)
            // Additional: CompleteQueryAsync(CompleteQueryRequest,CancellationToken)
            // Create client
            CompletionClient completionClient = await CompletionClient.CreateAsync();

            // Initialize request argument(s)
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                Name     = new ProjectName("[PROJECT]").ToString(),
                Query    = "",
                PageSize = 0,
            };
            // Make the request
            CompleteQueryResponse response = await completionClient.CompleteQueryAsync(request);

            // End snippet
        }
 /// <summary>Snippet for CompleteQuery</summary>
 public void CompleteQueryRequestObject()
 {
     // Snippet: CompleteQuery(CompleteQueryRequest, CallSettings)
     // Create client
     CompletionClient completionClient = CompletionClient.Create();
     // Initialize request argument(s)
     CompleteQueryRequest request = new CompleteQueryRequest
     {
         ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
         Query                = "",
         LanguageCodes        = { "", },
         PageSize             = 0,
         CompanyAsCompanyName = CompanyName.FromProjectTenantCompany("[PROJECT]", "[TENANT]", "[COMPANY]"),
         Scope                = CompleteQueryRequest.Types.CompletionScope.Unspecified,
         Type = CompleteQueryRequest.Types.CompletionType.Unspecified,
     };
     // Make the request
     CompleteQueryResponse response = completionClient.CompleteQuery(request);
     // End snippet
 }
 /// <summary>Snippet for CompleteQuery</summary>
 public void CompleteQueryRequestObject()
 {
     // Snippet: CompleteQuery(CompleteQueryRequest, CallSettings)
     // Create client
     CompletionServiceClient completionServiceClient = CompletionServiceClient.Create();
     // Initialize request argument(s)
     CompleteQueryRequest request = new CompleteQueryRequest
     {
         CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
         Query          = "",
         LanguageCodes  = { "", },
         DeviceType     = "",
         MaxSuggestions = 0,
         Dataset        = "",
         VisitorId      = "",
     };
     // Make the request
     CompleteQueryResponse response = completionServiceClient.CompleteQuery(request);
     // End snippet
 }
Exemple #12
0
        public async stt::Task CompleteQueryRequestObjectAsync()
        {
            moq::Mock <CompletionService.CompletionServiceClient> mockGrpcClient = new moq::Mock <CompletionService.CompletionServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
                Query         = "queryf0c71c1b",
                LanguageCodes =
                {
                    "language_codes1de1a181",
                },
                DeviceType     = "device_typef69395c0",
                MaxSuggestions = -1310933316,
                Dataset        = "datasete4094d3c",
                VisitorId      = "visitor_id25f1c2bf",
            };
            CompleteQueryResponse expectedResponse = new CompleteQueryResponse
            {
                CompletionResults =
                {
                    new CompleteQueryResponse.Types.CompletionResult(),
                },
                AttributionToken    = "attribution_token14371a88",
                RecentSearchResults =
                {
                    new CompleteQueryResponse.Types.RecentSearchResult(),
                },
            };

            mockGrpcClient.Setup(x => x.CompleteQueryAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <CompleteQueryResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CompletionServiceClient client = new CompletionServiceClientImpl(mockGrpcClient.Object, null);
            CompleteQueryResponse   responseCallSettings = await client.CompleteQueryAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            CompleteQueryResponse responseCancellationToken = await client.CompleteQueryAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for CompleteQueryAsync</summary>
        public async Task CompleteQueryRequestObjectAsync()
        {
            // Snippet: CompleteQueryAsync(CompleteQueryRequest, CallSettings)
            // Additional: CompleteQueryAsync(CompleteQueryRequest, CancellationToken)
            // Create client
            CompletionClient completionClient = await CompletionClient.CreateAsync();

            // Initialize request argument(s)
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                TenantAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                Query                = "",
                LanguageCodes        = { "", },
                PageSize             = 0,
                CompanyAsCompanyName = CompanyName.FromProjectTenantCompany("[PROJECT]", "[TENANT]", "[COMPANY]"),
                Scope                = CompleteQueryRequest.Types.CompletionScope.Unspecified,
                Type = CompleteQueryRequest.Types.CompletionType.Unspecified,
            };
            // Make the request
            CompleteQueryResponse response = await completionClient.CompleteQueryAsync(request);

            // End snippet
        }