public async stt::Task MutateKeywordPlanAdGroupsAsync() { moq::Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient>(moq::MockBehavior.Strict); MutateKeywordPlanAdGroupsRequest request = new MutateKeywordPlanAdGroupsRequest { CustomerId = "customer_id3b3724cb", Operations = { new KeywordPlanAdGroupOperation(), }, }; MutateKeywordPlanAdGroupsResponse expectedResponse = new MutateKeywordPlanAdGroupsResponse { Results = { new MutateKeywordPlanAdGroupResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateKeywordPlanAdGroupsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateKeywordPlanAdGroupsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanAdGroupServiceClient client = new KeywordPlanAdGroupServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanAdGroupsResponse responseCallSettings = await client.MutateKeywordPlanAdGroupsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); MutateKeywordPlanAdGroupsResponse responseCancellationToken = await client.MutateKeywordPlanAdGroupsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary> /// Creates the ad group 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="planCampaignResource">The resource name of the campaign under which the /// ad group is created.</param> /// <returns>The newly created ad group resource.</returns> private string CreateKeywordPlanAdGroup(GoogleAdsClient client, long customerId, string planCampaignResource) { // Get the KeywordPlanAdGroupService. KeywordPlanAdGroupServiceClient serviceClient = client.GetService( Services.V6.KeywordPlanAdGroupService); // Create the keyword plan ad group. KeywordPlanAdGroup adGroup = new KeywordPlanAdGroup() { KeywordPlanCampaign = planCampaignResource, Name = "Keyword plan ad group #" + ExampleUtilities.GetRandomString(), CpcBidMicros = 2_500_000L }; KeywordPlanAdGroupOperation operation = new KeywordPlanAdGroupOperation() { Create = adGroup }; // Add the ad group. MutateKeywordPlanAdGroupsResponse response = serviceClient.MutateKeywordPlanAdGroups( customerId.ToString(), new KeywordPlanAdGroupOperation[] { operation }); // Display the result. String planAdGroupResource = response.Results[0].ResourceName; Console.WriteLine($"Created ad group for keyword plan: {planAdGroupResource}."); return(planAdGroupResource); }
public void MutateKeywordPlanAdGroups() { moq::Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient>(moq::MockBehavior.Strict); MutateKeywordPlanAdGroupsRequest request = new MutateKeywordPlanAdGroupsRequest { CustomerId = "customer_id3b3724cb", Operations = { new KeywordPlanAdGroupOperation(), }, }; MutateKeywordPlanAdGroupsResponse expectedResponse = new MutateKeywordPlanAdGroupsResponse { Results = { new MutateKeywordPlanAdGroupResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateKeywordPlanAdGroups(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); KeywordPlanAdGroupServiceClient client = new KeywordPlanAdGroupServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanAdGroupsResponse response = client.MutateKeywordPlanAdGroups(request.CustomerId, request.Operations); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateKeywordPlanAdGroups</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateKeywordPlanAdGroups() { // Create client KeywordPlanAdGroupServiceClient keywordPlanAdGroupServiceClient = KeywordPlanAdGroupServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <KeywordPlanAdGroupOperation> operations = new KeywordPlanAdGroupOperation[] { new KeywordPlanAdGroupOperation(), }; // Make the request MutateKeywordPlanAdGroupsResponse response = keywordPlanAdGroupServiceClient.MutateKeywordPlanAdGroups(customerId, operations); }
/// <summary>Snippet for MutateKeywordPlanAdGroups</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateKeywordPlanAdGroupsRequestObject() { // Create client KeywordPlanAdGroupServiceClient keywordPlanAdGroupServiceClient = KeywordPlanAdGroupServiceClient.Create(); // Initialize request argument(s) MutateKeywordPlanAdGroupsRequest request = new MutateKeywordPlanAdGroupsRequest { CustomerId = "", Operations = { new KeywordPlanAdGroupOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateKeywordPlanAdGroupsResponse response = keywordPlanAdGroupServiceClient.MutateKeywordPlanAdGroups(request); }
/// <summary>Snippet for MutateKeywordPlanAdGroupsAsync</summary> public async Task MutateKeywordPlanAdGroupsAsync() { // Snippet: MutateKeywordPlanAdGroupsAsync(string, IEnumerable<KeywordPlanAdGroupOperation>, CallSettings) // Additional: MutateKeywordPlanAdGroupsAsync(string, IEnumerable<KeywordPlanAdGroupOperation>, CancellationToken) // Create client KeywordPlanAdGroupServiceClient keywordPlanAdGroupServiceClient = await KeywordPlanAdGroupServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <KeywordPlanAdGroupOperation> operations = new KeywordPlanAdGroupOperation[] { new KeywordPlanAdGroupOperation(), }; // Make the request MutateKeywordPlanAdGroupsResponse response = await keywordPlanAdGroupServiceClient.MutateKeywordPlanAdGroupsAsync(customerId, operations); // End snippet }
public async Task MutateKeywordPlanAdGroupsAsync3() { Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient> mockGrpcClient = new Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient>(MockBehavior.Strict); MutateKeywordPlanAdGroupsRequest request = new MutateKeywordPlanAdGroupsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateKeywordPlanAdGroupsResponse expectedResponse = new MutateKeywordPlanAdGroupsResponse(); mockGrpcClient.Setup(x => x.MutateKeywordPlanAdGroupsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateKeywordPlanAdGroupsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanAdGroupServiceClient client = new KeywordPlanAdGroupServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanAdGroupsResponse response = await client.MutateKeywordPlanAdGroupsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateKeywordPlanAdGroups3() { Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient> mockGrpcClient = new Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient>(MockBehavior.Strict); MutateKeywordPlanAdGroupsRequest request = new MutateKeywordPlanAdGroupsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateKeywordPlanAdGroupsResponse expectedResponse = new MutateKeywordPlanAdGroupsResponse(); mockGrpcClient.Setup(x => x.MutateKeywordPlanAdGroups(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); KeywordPlanAdGroupServiceClient client = new KeywordPlanAdGroupServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanAdGroupsResponse response = client.MutateKeywordPlanAdGroups(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateKeywordPlanAdGroupsAsync</summary> public async Task MutateKeywordPlanAdGroupsRequestObjectAsync() { // Snippet: MutateKeywordPlanAdGroupsAsync(MutateKeywordPlanAdGroupsRequest, CallSettings) // Additional: MutateKeywordPlanAdGroupsAsync(MutateKeywordPlanAdGroupsRequest, CancellationToken) // Create client KeywordPlanAdGroupServiceClient keywordPlanAdGroupServiceClient = await KeywordPlanAdGroupServiceClient.CreateAsync(); // Initialize request argument(s) MutateKeywordPlanAdGroupsRequest request = new MutateKeywordPlanAdGroupsRequest { CustomerId = "", Operations = { new KeywordPlanAdGroupOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateKeywordPlanAdGroupsResponse response = await keywordPlanAdGroupServiceClient.MutateKeywordPlanAdGroupsAsync(request); // End snippet }
public async Task MutateKeywordPlanAdGroupsAsync() { Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient> mockGrpcClient = new Mock <KeywordPlanAdGroupService.KeywordPlanAdGroupServiceClient>(MockBehavior.Strict); MutateKeywordPlanAdGroupsRequest expectedRequest = new MutateKeywordPlanAdGroupsRequest { CustomerId = "customerId-1772061412", Operations = { }, PartialFailure = true, ValidateOnly = false, }; MutateKeywordPlanAdGroupsResponse expectedResponse = new MutateKeywordPlanAdGroupsResponse(); mockGrpcClient.Setup(x => x.MutateKeywordPlanAdGroupsAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateKeywordPlanAdGroupsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanAdGroupServiceClient client = new KeywordPlanAdGroupServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; IEnumerable <KeywordPlanAdGroupOperation> operations = new List <KeywordPlanAdGroupOperation>(); bool partialFailure = true; bool validateOnly = false; MutateKeywordPlanAdGroupsResponse response = await client.MutateKeywordPlanAdGroupsAsync(customerId, operations, partialFailure, validateOnly); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }