Example #1
0
        public async stt::Task MutateKeywordPlansAsync()
        {
            moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict);
            MutateKeywordPlansRequest request = new MutateKeywordPlansRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new KeywordPlanOperation(),
                },
            };
            MutateKeywordPlansResponse expectedResponse = new MutateKeywordPlansResponse
            {
                Results =
                {
                    new MutateKeywordPlansResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateKeywordPlansAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateKeywordPlansResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            KeywordPlanServiceClient   client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null);
            MutateKeywordPlansResponse responseCallSettings = await client.MutateKeywordPlansAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            MutateKeywordPlansResponse responseCancellationToken = await client.MutateKeywordPlansAsync(request.CustomerId, request.Operations, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
        /// <summary>
        /// Creates the keyword plan.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <returns>The newly created keyword plan resource.</returns>
        private string CreateKeywordPlan(GoogleAdsClient client, long customerId)
        {
            // Get the KeywordPlanService.
            KeywordPlanServiceClient serviceClient = client.GetService(
                Services.V6.KeywordPlanService);

            // Create a keyword plan for next quarter forecast.
            KeywordPlan keywordPlan = new KeywordPlan()
            {
                Name           = "Keyword plan for traffic estimate #" + ExampleUtilities.GetRandomString(),
                ForecastPeriod = new KeywordPlanForecastPeriod()
                {
                    DateInterval = KeywordPlanForecastInterval.NextQuarter
                }
            };

            KeywordPlanOperation operation = new KeywordPlanOperation()
            {
                Create = keywordPlan
            };

            // Add the keyword plan.
            MutateKeywordPlansResponse response = serviceClient.MutateKeywordPlans(
                customerId.ToString(), new KeywordPlanOperation[] { operation });

            // Display the results.
            String planResource = response.Results[0].ResourceName;

            Console.WriteLine($"Created keyword plan: {planResource}.");
            return(planResource);
        }
Example #3
0
        public void MutateKeywordPlans()
        {
            moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict);
            MutateKeywordPlansRequest request = new MutateKeywordPlansRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new KeywordPlanOperation(),
                },
            };
            MutateKeywordPlansResponse expectedResponse = new MutateKeywordPlansResponse
            {
                Results =
                {
                    new MutateKeywordPlansResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateKeywordPlans(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            KeywordPlanServiceClient   client   = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null);
            MutateKeywordPlansResponse response = client.MutateKeywordPlans(request.CustomerId, request.Operations);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #4
0
 /// <summary>Snippet for MutateKeywordPlans</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateKeywordPlans()
 {
     // Create client
     KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <KeywordPlanOperation> operations = new KeywordPlanOperation[]
     {
         new KeywordPlanOperation(),
     };
     // Make the request
     MutateKeywordPlansResponse response = keywordPlanServiceClient.MutateKeywordPlans(customerId, operations);
 }
Example #5
0
 /// <summary>Snippet for MutateKeywordPlans</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateKeywordPlansRequestObject()
 {
     // Create client
     KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create();
     // Initialize request argument(s)
     MutateKeywordPlansRequest request = new MutateKeywordPlansRequest
     {
         CustomerId = "",
         Operations =
         {
             new KeywordPlanOperation(),
         },
         PartialFailure = false,
         ValidateOnly   = false,
     };
     // Make the request
     MutateKeywordPlansResponse response = keywordPlanServiceClient.MutateKeywordPlans(request);
 }
Example #6
0
        /// <summary>Snippet for MutateKeywordPlansAsync</summary>
        public async Task MutateKeywordPlansAsync()
        {
            // Snippet: MutateKeywordPlansAsync(string, IEnumerable<KeywordPlanOperation>, CallSettings)
            // Additional: MutateKeywordPlansAsync(string, IEnumerable<KeywordPlanOperation>, CancellationToken)
            // Create client
            KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <KeywordPlanOperation> operations = new KeywordPlanOperation[]
            {
                new KeywordPlanOperation(),
            };
            // Make the request
            MutateKeywordPlansResponse response = await keywordPlanServiceClient.MutateKeywordPlansAsync(customerId, operations);

            // End snippet
        }
        public async Task MutateKeywordPlansAsync3()
        {
            Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict);
            MutateKeywordPlansRequest request = new MutateKeywordPlansRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateKeywordPlansResponse expectedResponse = new MutateKeywordPlansResponse();

            mockGrpcClient.Setup(x => x.MutateKeywordPlansAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateKeywordPlansResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            KeywordPlanServiceClient   client   = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null);
            MutateKeywordPlansResponse response = await client.MutateKeywordPlansAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void MutateKeywordPlans3()
        {
            Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict);
            MutateKeywordPlansRequest request = new MutateKeywordPlansRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateKeywordPlansResponse expectedResponse = new MutateKeywordPlansResponse();

            mockGrpcClient.Setup(x => x.MutateKeywordPlans(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            KeywordPlanServiceClient   client   = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null);
            MutateKeywordPlansResponse response = client.MutateKeywordPlans(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #9
0
        /// <summary>Snippet for MutateKeywordPlansAsync</summary>
        public async Task MutateKeywordPlansRequestObjectAsync()
        {
            // Snippet: MutateKeywordPlansAsync(MutateKeywordPlansRequest, CallSettings)
            // Additional: MutateKeywordPlansAsync(MutateKeywordPlansRequest, CancellationToken)
            // Create client
            KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateKeywordPlansRequest request = new MutateKeywordPlansRequest
            {
                CustomerId = "",
                Operations =
                {
                    new KeywordPlanOperation(),
                },
                PartialFailure = false,
                ValidateOnly   = false,
            };
            // Make the request
            MutateKeywordPlansResponse response = await keywordPlanServiceClient.MutateKeywordPlansAsync(request);

            // End snippet
        }
        public async Task MutateKeywordPlansAsync()
        {
            Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict);
            MutateKeywordPlansRequest expectedRequest = new MutateKeywordPlansRequest
            {
                CustomerId     = "customerId-1772061412",
                Operations     = { },
                PartialFailure = true,
                ValidateOnly   = false,
            };
            MutateKeywordPlansResponse expectedResponse = new MutateKeywordPlansResponse();

            mockGrpcClient.Setup(x => x.MutateKeywordPlansAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateKeywordPlansResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            IEnumerable <KeywordPlanOperation> operations = new List <KeywordPlanOperation>();
            bool partialFailure = true;
            bool validateOnly   = false;
            MutateKeywordPlansResponse response = await client.MutateKeywordPlansAsync(customerId, operations, partialFailure, validateOnly);

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