public void MutateKeywordPlanCampaigns() { moq::Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient>(moq::MockBehavior.Strict); MutateKeywordPlanCampaignsRequest request = new MutateKeywordPlanCampaignsRequest { CustomerId = "customer_id3b3724cb", Operations = { new KeywordPlanCampaignOperation(), }, }; MutateKeywordPlanCampaignsResponse expectedResponse = new MutateKeywordPlanCampaignsResponse { Results = { new MutateKeywordPlanCampaignResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateKeywordPlanCampaigns(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); KeywordPlanCampaignServiceClient client = new KeywordPlanCampaignServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanCampaignsResponse response = client.MutateKeywordPlanCampaigns(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task MutateKeywordPlanCampaignsRequestObjectAsync() { moq::Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient>(moq::MockBehavior.Strict); MutateKeywordPlanCampaignsRequest request = new MutateKeywordPlanCampaignsRequest { CustomerId = "customer_id3b3724cb", Operations = { new KeywordPlanCampaignOperation(), }, PartialFailure = false, ValidateOnly = true, }; MutateKeywordPlanCampaignsResponse expectedResponse = new MutateKeywordPlanCampaignsResponse { Results = { new MutateKeywordPlanCampaignResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateKeywordPlanCampaignsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateKeywordPlanCampaignsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanCampaignServiceClient client = new KeywordPlanCampaignServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanCampaignsResponse responseCallSettings = await client.MutateKeywordPlanCampaignsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateKeywordPlanCampaignsResponse responseCancellationToken = await client.MutateKeywordPlanCampaignsAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateKeywordPlanCampaigns</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateKeywordPlanCampaigns() { // Create client KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = KeywordPlanCampaignServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <KeywordPlanCampaignOperation> operations = new KeywordPlanCampaignOperation[] { new KeywordPlanCampaignOperation(), }; // Make the request MutateKeywordPlanCampaignsResponse response = keywordPlanCampaignServiceClient.MutateKeywordPlanCampaigns(customerId, operations); }
public async Task MutateKeywordPlanCampaignsAsync3() { Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient> mockGrpcClient = new Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient>(MockBehavior.Strict); MutateKeywordPlanCampaignsRequest request = new MutateKeywordPlanCampaignsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateKeywordPlanCampaignsResponse expectedResponse = new MutateKeywordPlanCampaignsResponse(); mockGrpcClient.Setup(x => x.MutateKeywordPlanCampaignsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateKeywordPlanCampaignsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanCampaignServiceClient client = new KeywordPlanCampaignServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanCampaignsResponse response = await client.MutateKeywordPlanCampaignsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateKeywordPlanCampaigns3() { Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient> mockGrpcClient = new Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient>(MockBehavior.Strict); MutateKeywordPlanCampaignsRequest request = new MutateKeywordPlanCampaignsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateKeywordPlanCampaignsResponse expectedResponse = new MutateKeywordPlanCampaignsResponse(); mockGrpcClient.Setup(x => x.MutateKeywordPlanCampaigns(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); KeywordPlanCampaignServiceClient client = new KeywordPlanCampaignServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanCampaignsResponse response = client.MutateKeywordPlanCampaigns(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateKeywordPlanCampaignsAsync</summary> public async Task MutateKeywordPlanCampaignsAsync() { // Snippet: MutateKeywordPlanCampaignsAsync(string, IEnumerable<KeywordPlanCampaignOperation>, CallSettings) // Additional: MutateKeywordPlanCampaignsAsync(string, IEnumerable<KeywordPlanCampaignOperation>, CancellationToken) // Create client KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = await KeywordPlanCampaignServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <KeywordPlanCampaignOperation> operations = new KeywordPlanCampaignOperation[] { new KeywordPlanCampaignOperation(), }; // Make the request MutateKeywordPlanCampaignsResponse response = await keywordPlanCampaignServiceClient.MutateKeywordPlanCampaignsAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateKeywordPlanCampaigns</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateKeywordPlanCampaignsRequestObject() { // Create client KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = KeywordPlanCampaignServiceClient.Create(); // Initialize request argument(s) MutateKeywordPlanCampaignsRequest request = new MutateKeywordPlanCampaignsRequest { CustomerId = "", Operations = { new KeywordPlanCampaignOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateKeywordPlanCampaignsResponse response = keywordPlanCampaignServiceClient.MutateKeywordPlanCampaigns(request); }
/// <summary> /// Creates the campaign for 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> /// <param name="keywordPlanResource">The keyword plan resource.</param> /// <returns>The newly created campaign resource.</returns> private string CreateKeywordPlanCampaign(GoogleAdsClient client, long customerId, String keywordPlanResource) { // Get the KeywordPlanCampaignService. KeywordPlanCampaignServiceClient serviceClient = client.GetService( Services.V6.KeywordPlanCampaignService); // Create a keyword plan campaign. KeywordPlanCampaign campaign = new KeywordPlanCampaign() { Name = "Keyword plan campaign #" + ExampleUtilities.GetRandomString(), CpcBidMicros = 1_000_000L, KeywordPlanNetwork = KeywordPlanNetwork.GoogleSearch, KeywordPlan = keywordPlanResource }; // See https://developers.google.com/adwords/api/docs/appendix/geotargeting // for the list of geo target IDs. campaign.GeoTargets.Add(new KeywordPlanGeoTarget() { GeoTargetConstant = ResourceNames.GeoTargetConstant(2840) /* USA */ }); // See https://developers.google.com/adwords/api/docs/appendix/codes-formats#languages // for the list of language criteria IDs. campaign.LanguageConstants.Add(ResourceNames.LanguageConstant(1000)); /* English */ KeywordPlanCampaignOperation operation = new KeywordPlanCampaignOperation() { Create = campaign }; // Add the campaign. MutateKeywordPlanCampaignsResponse response = serviceClient.MutateKeywordPlanCampaigns(customerId.ToString(), new KeywordPlanCampaignOperation[] { operation }); // Display the result. String planCampaignResource = response.Results[0].ResourceName; Console.WriteLine($"Created campaign for keyword plan: {planCampaignResource}."); return(planCampaignResource); }
/// <summary>Snippet for MutateKeywordPlanCampaignsAsync</summary> public async Task MutateKeywordPlanCampaignsRequestObjectAsync() { // Snippet: MutateKeywordPlanCampaignsAsync(MutateKeywordPlanCampaignsRequest, CallSettings) // Additional: MutateKeywordPlanCampaignsAsync(MutateKeywordPlanCampaignsRequest, CancellationToken) // Create client KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = await KeywordPlanCampaignServiceClient.CreateAsync(); // Initialize request argument(s) MutateKeywordPlanCampaignsRequest request = new MutateKeywordPlanCampaignsRequest { CustomerId = "", Operations = { new KeywordPlanCampaignOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateKeywordPlanCampaignsResponse response = await keywordPlanCampaignServiceClient.MutateKeywordPlanCampaignsAsync(request); // End snippet }
public async Task MutateKeywordPlanCampaignsAsync() { Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient> mockGrpcClient = new Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient>(MockBehavior.Strict); MutateKeywordPlanCampaignsRequest expectedRequest = new MutateKeywordPlanCampaignsRequest { CustomerId = "customerId-1772061412", Operations = { }, PartialFailure = true, ValidateOnly = false, }; MutateKeywordPlanCampaignsResponse expectedResponse = new MutateKeywordPlanCampaignsResponse(); mockGrpcClient.Setup(x => x.MutateKeywordPlanCampaignsAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateKeywordPlanCampaignsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanCampaignServiceClient client = new KeywordPlanCampaignServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; IEnumerable <KeywordPlanCampaignOperation> operations = new List <KeywordPlanCampaignOperation>(); bool partialFailure = true; bool validateOnly = false; MutateKeywordPlanCampaignsResponse response = await client.MutateKeywordPlanCampaignsAsync(customerId, operations, partialFailure, validateOnly); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }