public async stt::Task SuggestGeoTargetConstantsRequestObjectAsync()
        {
            moq::Mock <GeoTargetConstantService.GeoTargetConstantServiceClient> mockGrpcClient = new moq::Mock <GeoTargetConstantService.GeoTargetConstantServiceClient>(moq::MockBehavior.Strict);
            SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest
            {
                LocationNames = new SuggestGeoTargetConstantsRequest.Types.LocationNames(),
                GeoTargets    = new SuggestGeoTargetConstantsRequest.Types.GeoTargets(),
                Locale        = "locale9e6d21fb",
                CountryCode   = "country_code8debec55",
            };
            SuggestGeoTargetConstantsResponse expectedResponse = new SuggestGeoTargetConstantsResponse
            {
                GeoTargetConstantSuggestions =
                {
                    new GeoTargetConstantSuggestion(),
                },
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            SuggestGeoTargetConstantsResponse responseCancellationToken = await client.SuggestGeoTargetConstantsAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void SuggestGeoTargetConstantsRequestObject()
        {
            moq::Mock <GeoTargetConstantService.GeoTargetConstantServiceClient> mockGrpcClient = new moq::Mock <GeoTargetConstantService.GeoTargetConstantServiceClient>(moq::MockBehavior.Strict);
            SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest
            {
                LocationNames = new SuggestGeoTargetConstantsRequest.Types.LocationNames(),
                GeoTargets    = new SuggestGeoTargetConstantsRequest.Types.GeoTargets(),
                Locale        = "locale9e6d21fb",
                CountryCode   = "country_code8debec55",
            };
            SuggestGeoTargetConstantsResponse expectedResponse = new SuggestGeoTargetConstantsResponse
            {
                GeoTargetConstantSuggestions =
                {
                    new GeoTargetConstantSuggestion(),
                },
            };

            mockGrpcClient.Setup(x => x.SuggestGeoTargetConstants(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            GeoTargetConstantServiceClient    client   = new GeoTargetConstantServiceClientImpl(mockGrpcClient.Object, null);
            SuggestGeoTargetConstantsResponse response = client.SuggestGeoTargetConstants(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        public void Run(GoogleAdsClient client)
        {
            // Get the GeoTargetConstantServiceClient.
            GeoTargetConstantServiceClient geoService =
                client.GetService(Services.V5.GeoTargetConstantService);

            // Locale is using ISO 639-1 format. If an invalid locale is given,
            // 'en' is used by default.
            string locale = "en";

            // A list of country codes can be referenced here:
            // https://developers.google.com/adwords/api/docs/appendix/geotargeting
            string countryCode = "FR";

            String[] locations = { "Paris", "Quebec", "Spain", "Deutschland" };

            SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest()
            {
                Locale        = locale,
                CountryCode   = countryCode,
                LocationNames = new SuggestGeoTargetConstantsRequest.Types.LocationNames()
            };

            request.LocationNames.Names.AddRange(locations);

            try
            {
                SuggestGeoTargetConstantsResponse response =
                    geoService.SuggestGeoTargetConstants(request);

                foreach (GeoTargetConstantSuggestion suggestion
                         in response.GeoTargetConstantSuggestions)
                {
                    Console.WriteLine(
                        $"{suggestion.GeoTargetConstant.ResourceName} " +
                        $"({suggestion.GeoTargetConstant.Name}, " +
                        $"{suggestion.GeoTargetConstant.CountryCode}, " +
                        $"{suggestion.GeoTargetConstant.TargetType}, " +
                        $"{suggestion.GeoTargetConstant.Status}) is found in locale " +
                        $"({suggestion.Locale}) with reach ({suggestion.Reach}) " +
                        $"for search term ({suggestion.SearchTerm}).");
                }
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
 /// <summary>Snippet for SuggestGeoTargetConstants</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void SuggestGeoTargetConstantsRequestObject()
 {
     // Create client
     GeoTargetConstantServiceClient geoTargetConstantServiceClient = GeoTargetConstantServiceClient.Create();
     // Initialize request argument(s)
     SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest
     {
         LocationNames = new SuggestGeoTargetConstantsRequest.Types.LocationNames(),
         Locale        = "",
         CountryCode   = "",
     };
     // Make the request
     SuggestGeoTargetConstantsResponse response = geoTargetConstantServiceClient.SuggestGeoTargetConstants(request);
 }
        public async Task SuggestGeoTargetConstantsAsync2()
        {
            Mock <GeoTargetConstantService.GeoTargetConstantServiceClient> mockGrpcClient = new Mock <GeoTargetConstantService.GeoTargetConstantServiceClient>(MockBehavior.Strict);
            SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest
            {
                Locale      = null,
                CountryCode = null,
            };
            SuggestGeoTargetConstantsResponse expectedResponse = new SuggestGeoTargetConstantsResponse();

            mockGrpcClient.Setup(x => x.SuggestGeoTargetConstantsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <SuggestGeoTargetConstantsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            GeoTargetConstantServiceClient    client   = new GeoTargetConstantServiceClientImpl(mockGrpcClient.Object, null);
            SuggestGeoTargetConstantsResponse response = await client.SuggestGeoTargetConstantsAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void SuggestGeoTargetConstants2()
        {
            Mock <GeoTargetConstantService.GeoTargetConstantServiceClient> mockGrpcClient = new Mock <GeoTargetConstantService.GeoTargetConstantServiceClient>(MockBehavior.Strict);
            SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest
            {
                Locale      = null,
                CountryCode = null,
            };
            SuggestGeoTargetConstantsResponse expectedResponse = new SuggestGeoTargetConstantsResponse();

            mockGrpcClient.Setup(x => x.SuggestGeoTargetConstants(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            GeoTargetConstantServiceClient    client   = new GeoTargetConstantServiceClientImpl(mockGrpcClient.Object, null);
            SuggestGeoTargetConstantsResponse response = client.SuggestGeoTargetConstants(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemple #7
0
        /// <summary>Snippet for SuggestGeoTargetConstantsAsync</summary>
        public async Task SuggestGeoTargetConstantsRequestObjectAsync()
        {
            // Snippet: SuggestGeoTargetConstantsAsync(SuggestGeoTargetConstantsRequest, CallSettings)
            // Additional: SuggestGeoTargetConstantsAsync(SuggestGeoTargetConstantsRequest, CancellationToken)
            // Create client
            GeoTargetConstantServiceClient geoTargetConstantServiceClient = await GeoTargetConstantServiceClient.CreateAsync();

            // Initialize request argument(s)
            SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest
            {
                LocationNames = new SuggestGeoTargetConstantsRequest.Types.LocationNames(),
                Locale        = "",
                CountryCode   = "",
            };
            // Make the request
            SuggestGeoTargetConstantsResponse response = await geoTargetConstantServiceClient.SuggestGeoTargetConstantsAsync(request);

            // End snippet
        }
        public async Task SuggestGeoTargetConstantsAsync()
        {
            Mock <GeoTargetConstantService.GeoTargetConstantServiceClient> mockGrpcClient = new Mock <GeoTargetConstantService.GeoTargetConstantServiceClient>(MockBehavior.Strict);
            SuggestGeoTargetConstantsRequest expectedRequest = new SuggestGeoTargetConstantsRequest
            {
                Locale = new StringValue().Value,
                // TODO(liseno): Implicit type cast from StringValue to String failed,
                CountryCode = new StringValue().Value,
                // TODO(liseno): Implicit type cast from StringValue to String failed,
            };
            SuggestGeoTargetConstantsResponse expectedResponse = new SuggestGeoTargetConstantsResponse();

            mockGrpcClient.Setup(x => x.SuggestGeoTargetConstantsAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <SuggestGeoTargetConstantsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            GeoTargetConstantServiceClient client = new GeoTargetConstantServiceClientImpl(mockGrpcClient.Object, null);
            StringValue locale      = new StringValue();
            StringValue countryCode = new StringValue();
            SuggestGeoTargetConstantsResponse response = await client.SuggestGeoTargetConstantsAsync(locale, countryCode);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }