public async stt::Task MutateAdsRequestObjectAsync() { moq::Mock <AdService.AdServiceClient> mockGrpcClient = new moq::Mock <AdService.AdServiceClient>(moq::MockBehavior.Strict); MutateAdsRequest request = new MutateAdsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AdOperation(), }, }; MutateAdsResponse expectedResponse = new MutateAdsResponse { Results = { new MutateAdResult(), }, }; mockGrpcClient.Setup(x => x.MutateAdsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateAdsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdServiceClient client = new AdServiceClientImpl(mockGrpcClient.Object, null); MutateAdsResponse responseCallSettings = await client.MutateAdsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateAdsResponse responseCancellationToken = await client.MutateAdsAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task MutateAdsRequestObjectAsync() { moq::Mock <AdService.AdServiceClient> mockGrpcClient = new moq::Mock <AdService.AdServiceClient>(moq::MockBehavior.Strict); MutateAdsRequest request = new MutateAdsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AdOperation(), }, ValidateOnly = true, PartialFailure = false, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateAdsResponse expectedResponse = new MutateAdsResponse { Results = { new MutateAdResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateAdsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateAdsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdServiceClient client = new AdServiceClientImpl(mockGrpcClient.Object, null); MutateAdsResponse responseCallSettings = await client.MutateAdsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); MutateAdsResponse responseCancellationToken = await client.MutateAdsAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void MutateAdsRequestObject() { moq::Mock <AdService.AdServiceClient> mockGrpcClient = new moq::Mock <AdService.AdServiceClient>(moq::MockBehavior.Strict); MutateAdsRequest request = new MutateAdsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AdOperation(), }, ValidateOnly = true, PartialFailure = false, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateAdsResponse expectedResponse = new MutateAdsResponse { Results = { new MutateAdResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateAds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AdServiceClient client = new AdServiceClientImpl(mockGrpcClient.Object, null); MutateAdsResponse response = client.MutateAds(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateAds</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateAds() { // Create client AdServiceClient adServiceClient = AdServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <AdOperation> operations = new AdOperation[] { new AdOperation(), }; // Make the request MutateAdsResponse response = adServiceClient.MutateAds(customerId, operations); }
/// <summary>Snippet for MutateAds</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateAdsRequestObject() { // Create client AdServiceClient adServiceClient = AdServiceClient.Create(); // Initialize request argument(s) MutateAdsRequest request = new MutateAdsRequest { CustomerId = "", Operations = { new AdOperation(), }, }; // Make the request MutateAdsResponse response = adServiceClient.MutateAds(request); }
/// <summary>Snippet for MutateAdsAsync</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 MutateAdsRequestObjectAsync() { // Create client AdServiceClient adServiceClient = await AdServiceClient.CreateAsync(); // Initialize request argument(s) MutateAdsRequest request = new MutateAdsRequest { CustomerId = "", Operations = { new AdOperation(), }, }; // Make the request MutateAdsResponse response = await adServiceClient.MutateAdsAsync(request); }
/// <summary>Snippet for MutateAdsAsync</summary> public async Task MutateAdsAsync() { // Snippet: MutateAdsAsync(string, IEnumerable<AdOperation>, CallSettings) // Additional: MutateAdsAsync(string, IEnumerable<AdOperation>, CancellationToken) // Create client AdServiceClient adServiceClient = await AdServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <AdOperation> operations = new AdOperation[] { new AdOperation(), }; // Make the request MutateAdsResponse response = await adServiceClient.MutateAdsAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateAds</summary> public void MutateAdsRequestObject() { // Snippet: MutateAds(MutateAdsRequest, CallSettings) // Create client AdServiceClient adServiceClient = AdServiceClient.Create(); // Initialize request argument(s) MutateAdsRequest request = new MutateAdsRequest { CustomerId = "", Operations = { new AdOperation(), }, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateAdsResponse response = adServiceClient.MutateAds(request); // End snippet }
/// <summary>Snippet for MutateAds</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateAdsRequestObject() { // Create client AdServiceClient adServiceClient = AdServiceClient.Create(); // Initialize request argument(s) MutateAdsRequest request = new MutateAdsRequest { CustomerId = "", Operations = { new AdOperation(), }, ValidateOnly = false, PartialFailure = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateAdsResponse response = adServiceClient.MutateAds(request); }
/// <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="adId"> ID of the ad to update.</param> // [START update_expanded_text_ad] public void Run(GoogleAdsClient client, long customerId, long adId) { // Get the AdService. AdServiceClient adService = client.GetService(Services.V10.AdService); Ad ad = new Ad() { ResourceName = ResourceNames.Ad(customerId, adId), ExpandedTextAd = new ExpandedTextAdInfo() { // Update some properties of the expanded text ad. HeadlinePart1 = "Cruise to Pluto #" + ExampleUtilities.GetShortRandomString(), HeadlinePart2 = "Tickets on sale now", Description = "Best space cruise ever.", }, FinalUrls = { "http://www.example.com/" }, FinalMobileUrls = { "http://www.example.com/mobile" } }; AdOperation operation = new AdOperation() { Update = ad, UpdateMask = FieldMasks.AllSetFieldsOf(ad) }; try { // Issue the update request. MutateAdsResponse response = adService.MutateAds(customerId.ToString(), new[] { operation }); // Display the results. foreach (MutateAdResult updatedAd in response.Results) { Console.WriteLine($"Ad with resource ID = '{updatedAd.ResourceName}' was " + $"updated."); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
public async Task MutateAdsAsync2() { Mock <AdService.AdServiceClient> mockGrpcClient = new Mock <AdService.AdServiceClient>(MockBehavior.Strict); MutateAdsRequest request = new MutateAdsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateAdsResponse expectedResponse = new MutateAdsResponse(); mockGrpcClient.Setup(x => x.MutateAdsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateAdsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); AdServiceClient client = new AdServiceClientImpl(mockGrpcClient.Object, null); MutateAdsResponse response = await client.MutateAdsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateAds2() { Mock <AdService.AdServiceClient> mockGrpcClient = new Mock <AdService.AdServiceClient>(MockBehavior.Strict); MutateAdsRequest request = new MutateAdsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateAdsResponse expectedResponse = new MutateAdsResponse(); mockGrpcClient.Setup(x => x.MutateAds(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); AdServiceClient client = new AdServiceClientImpl(mockGrpcClient.Object, null); MutateAdsResponse response = client.MutateAds(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateAdsAsync</summary> public async Task MutateAdsRequestObjectAsync() { // Snippet: MutateAdsAsync(MutateAdsRequest, CallSettings) // Additional: MutateAdsAsync(MutateAdsRequest, CancellationToken) // Create client AdServiceClient adServiceClient = await AdServiceClient.CreateAsync(); // Initialize request argument(s) MutateAdsRequest request = new MutateAdsRequest { CustomerId = "", Operations = { new AdOperation(), }, }; // Make the request MutateAdsResponse response = await adServiceClient.MutateAdsAsync(request); // End snippet }
/// <summary>Snippet for MutateAdsAsync</summary> public async Task MutateAdsRequestObjectAsync() { // Snippet: MutateAdsAsync(MutateAdsRequest, CallSettings) // Additional: MutateAdsAsync(MutateAdsRequest, CancellationToken) // Create client AdServiceClient adServiceClient = await AdServiceClient.CreateAsync(); // Initialize request argument(s) MutateAdsRequest request = new MutateAdsRequest { CustomerId = "", Operations = { new AdOperation(), }, ValidateOnly = false, PartialFailure = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateAdsResponse response = await adServiceClient.MutateAdsAsync(request); // End snippet }
public void MutateAds() { moq::Mock <AdService.AdServiceClient> mockGrpcClient = new moq::Mock <AdService.AdServiceClient>(moq::MockBehavior.Strict); MutateAdsRequest request = new MutateAdsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AdOperation(), }, }; MutateAdsResponse expectedResponse = new MutateAdsResponse { Results = { new MutateAdResult(), }, }; mockGrpcClient.Setup(x => x.MutateAds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AdServiceClient client = new AdServiceClientImpl(mockGrpcClient.Object, null); MutateAdsResponse response = client.MutateAds(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }