public async stt::Task MutateCampaignSharedSetsAsync() { moq::Mock <CampaignSharedSetService.CampaignSharedSetServiceClient> mockGrpcClient = new moq::Mock <CampaignSharedSetService.CampaignSharedSetServiceClient>(moq::MockBehavior.Strict); MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new CampaignSharedSetOperation(), }, }; MutateCampaignSharedSetsResponse expectedResponse = new MutateCampaignSharedSetsResponse { Results = { new MutateCampaignSharedSetResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateCampaignSharedSetsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateCampaignSharedSetsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CampaignSharedSetServiceClient client = new CampaignSharedSetServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignSharedSetsResponse responseCallSettings = await client.MutateCampaignSharedSetsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateCampaignSharedSetsResponse responseCancellationToken = await client.MutateCampaignSharedSetsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void MutateCampaignSharedSetsRequestObject() { moq::Mock <CampaignSharedSetService.CampaignSharedSetServiceClient> mockGrpcClient = new moq::Mock <CampaignSharedSetService.CampaignSharedSetServiceClient>(moq::MockBehavior.Strict); MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new CampaignSharedSetOperation(), }, PartialFailure = false, ValidateOnly = true, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateCampaignSharedSetsResponse expectedResponse = new MutateCampaignSharedSetsResponse { Results = { new MutateCampaignSharedSetResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateCampaignSharedSets(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CampaignSharedSetServiceClient client = new CampaignSharedSetServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignSharedSetsResponse response = client.MutateCampaignSharedSets(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateCampaignSharedSets() { moq::Mock <CampaignSharedSetService.CampaignSharedSetServiceClient> mockGrpcClient = new moq::Mock <CampaignSharedSetService.CampaignSharedSetServiceClient>(moq::MockBehavior.Strict); MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new CampaignSharedSetOperation(), }, }; MutateCampaignSharedSetsResponse expectedResponse = new MutateCampaignSharedSetsResponse { Results = { new MutateCampaignSharedSetResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateCampaignSharedSets(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CampaignSharedSetServiceClient client = new CampaignSharedSetServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignSharedSetsResponse response = client.MutateCampaignSharedSets(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateCampaignSharedSets</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateCampaignSharedSets() { // Create client CampaignSharedSetServiceClient campaignSharedSetServiceClient = CampaignSharedSetServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <CampaignSharedSetOperation> operations = new CampaignSharedSetOperation[] { new CampaignSharedSetOperation(), }; // Make the request MutateCampaignSharedSetsResponse response = campaignSharedSetServiceClient.MutateCampaignSharedSets(customerId, operations); }
public async Task MutateCampaignSharedSetsAsync2() { Mock <CampaignSharedSetService.CampaignSharedSetServiceClient> mockGrpcClient = new Mock <CampaignSharedSetService.CampaignSharedSetServiceClient>(MockBehavior.Strict); MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateCampaignSharedSetsResponse expectedResponse = new MutateCampaignSharedSetsResponse(); mockGrpcClient.Setup(x => x.MutateCampaignSharedSetsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignSharedSetsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); CampaignSharedSetServiceClient client = new CampaignSharedSetServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignSharedSetsResponse response = await client.MutateCampaignSharedSetsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateCampaignSharedSets2() { Mock <CampaignSharedSetService.CampaignSharedSetServiceClient> mockGrpcClient = new Mock <CampaignSharedSetService.CampaignSharedSetServiceClient>(MockBehavior.Strict); MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateCampaignSharedSetsResponse expectedResponse = new MutateCampaignSharedSetsResponse(); mockGrpcClient.Setup(x => x.MutateCampaignSharedSets(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); CampaignSharedSetServiceClient client = new CampaignSharedSetServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignSharedSetsResponse response = client.MutateCampaignSharedSets(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateCampaignSharedSetsAsync</summary> public async Task MutateCampaignSharedSetsAsync() { // Snippet: MutateCampaignSharedSetsAsync(string, IEnumerable<CampaignSharedSetOperation>, CallSettings) // Additional: MutateCampaignSharedSetsAsync(string, IEnumerable<CampaignSharedSetOperation>, CancellationToken) // Create client CampaignSharedSetServiceClient campaignSharedSetServiceClient = await CampaignSharedSetServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <CampaignSharedSetOperation> operations = new CampaignSharedSetOperation[] { new CampaignSharedSetOperation(), }; // Make the request MutateCampaignSharedSetsResponse response = await campaignSharedSetServiceClient.MutateCampaignSharedSetsAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateCampaignSharedSets</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateCampaignSharedSetsRequestObject() { // Create client CampaignSharedSetServiceClient campaignSharedSetServiceClient = CampaignSharedSetServiceClient.Create(); // Initialize request argument(s) MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest { CustomerId = "", Operations = { new CampaignSharedSetOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateCampaignSharedSetsResponse response = campaignSharedSetServiceClient.MutateCampaignSharedSets(request); }
/// <summary>Snippet for MutateCampaignSharedSetsAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task MutateCampaignSharedSetsRequestObjectAsync() { // Create client CampaignSharedSetServiceClient campaignSharedSetServiceClient = await CampaignSharedSetServiceClient.CreateAsync(); // Initialize request argument(s) MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest { CustomerId = "", Operations = { new CampaignSharedSetOperation(), }, PartialFailure = false, ValidateOnly = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateCampaignSharedSetsResponse response = await campaignSharedSetServiceClient.MutateCampaignSharedSetsAsync(request); }
/// <summary>Snippet for MutateCampaignSharedSets</summary> public void MutateCampaignSharedSetsRequestObject() { // Snippet: MutateCampaignSharedSets(MutateCampaignSharedSetsRequest, CallSettings) // Create client CampaignSharedSetServiceClient campaignSharedSetServiceClient = CampaignSharedSetServiceClient.Create(); // Initialize request argument(s) MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest { CustomerId = "", Operations = { new CampaignSharedSetOperation(), }, PartialFailure = false, ValidateOnly = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateCampaignSharedSetsResponse response = campaignSharedSetServiceClient.MutateCampaignSharedSets(request); // End snippet }
/// <summary>Snippet for MutateCampaignSharedSetsAsync</summary> public async Task MutateCampaignSharedSetsRequestObjectAsync() { // Snippet: MutateCampaignSharedSetsAsync(MutateCampaignSharedSetsRequest, CallSettings) // Additional: MutateCampaignSharedSetsAsync(MutateCampaignSharedSetsRequest, CancellationToken) // Create client CampaignSharedSetServiceClient campaignSharedSetServiceClient = await CampaignSharedSetServiceClient.CreateAsync(); // Initialize request argument(s) MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest { CustomerId = "", Operations = { new CampaignSharedSetOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateCampaignSharedSetsResponse response = await campaignSharedSetServiceClient.MutateCampaignSharedSetsAsync(request); // End snippet }
public async Task MutateCampaignSharedSetsAsync() { Mock <CampaignSharedSetService.CampaignSharedSetServiceClient> mockGrpcClient = new Mock <CampaignSharedSetService.CampaignSharedSetServiceClient>(MockBehavior.Strict); MutateCampaignSharedSetsRequest expectedRequest = new MutateCampaignSharedSetsRequest { CustomerId = "customerId-1772061412", Operations = { }, PartialFailure = true, ValidateOnly = false, }; MutateCampaignSharedSetsResponse expectedResponse = new MutateCampaignSharedSetsResponse(); mockGrpcClient.Setup(x => x.MutateCampaignSharedSetsAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignSharedSetsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); CampaignSharedSetServiceClient client = new CampaignSharedSetServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; IEnumerable <CampaignSharedSetOperation> operations = new List <CampaignSharedSetOperation>(); bool partialFailure = true; bool validateOnly = false; MutateCampaignSharedSetsResponse response = await client.MutateCampaignSharedSetsAsync(customerId, operations, partialFailure, validateOnly); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Runs the code example. /// </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="campaignId">The ID of the campaign for which shared criterion is updated. /// </param> public void Run(GoogleAdsClient client, long customerId, long campaignId) { SharedSetServiceClient sharedSetService = client.GetService( Services.V4.SharedSetService); SharedCriterionServiceClient sharedCriterionService = client.GetService(Services.V4.SharedCriterionService); CampaignSharedSetServiceClient campaignSharedSetService = client.GetService(Services.V4.CampaignSharedSetService); try { // Keywords to create a shared set of. string[] keywords = new string[] { "mars cruise", "mars hotels" }; // Create shared negative keyword set. SharedSet sharedSet = new SharedSet() { Name = "API Negative keyword list - " + ExampleUtilities.GetRandomString(), Type = SharedSetType.NegativeKeywords, }; SharedSetOperation operation = new SharedSetOperation() { Create = sharedSet }; MutateSharedSetsResponse sharedSetResponse = sharedSetService.MutateSharedSets( customerId.ToString(), new SharedSetOperation[] { operation }); string sharedSetResourceName = sharedSetResponse.Results[0].ResourceName; Console.WriteLine($"Created shared set {sharedSetResourceName}."); // Create negative keywords in the shared set. List <SharedCriterionOperation> criterionOperations = new List <SharedCriterionOperation>(); foreach (string keyword in keywords) { SharedCriterion sharedCriterion = new SharedCriterion() { Keyword = new KeywordInfo() { Text = keyword, MatchType = KeywordMatchType.Broad }, SharedSet = sharedSetResourceName }; criterionOperations.Add(new SharedCriterionOperation() { Create = sharedCriterion }); } MutateSharedCriteriaResponse criteriaResponse = sharedCriterionService.MutateSharedCriteria( customerId.ToString(), criterionOperations); foreach (MutateSharedCriterionResult result in criteriaResponse.Results) { Console.WriteLine($"Created shared criterion {result.ResourceName}."); } // Attach shared set to campaign. CampaignSharedSet campaignSet = new CampaignSharedSet() { Campaign = ResourceNames.Campaign(customerId, campaignId), SharedSet = sharedSetResourceName }; CampaignSharedSetOperation sharedSetoperation = new CampaignSharedSetOperation() { Create = campaignSet }; MutateCampaignSharedSetsResponse response = campaignSharedSetService.MutateCampaignSharedSets(customerId.ToString(), new CampaignSharedSetOperation[] { sharedSetoperation }); Console.WriteLine("Created campaign shared set {0}.", response.Results[0].ResourceName); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }