public void MutateBiddingSeasonalityAdjustments() { moq::Mock <BiddingSeasonalityAdjustmentService.BiddingSeasonalityAdjustmentServiceClient> mockGrpcClient = new moq::Mock <BiddingSeasonalityAdjustmentService.BiddingSeasonalityAdjustmentServiceClient>(moq::MockBehavior.Strict); MutateBiddingSeasonalityAdjustmentsRequest request = new MutateBiddingSeasonalityAdjustmentsRequest { CustomerId = "customer_id3b3724cb", Operations = { new BiddingSeasonalityAdjustmentOperation(), }, }; MutateBiddingSeasonalityAdjustmentsResponse expectedResponse = new MutateBiddingSeasonalityAdjustmentsResponse { Results = { new MutateBiddingSeasonalityAdjustmentsResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateBiddingSeasonalityAdjustments(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); BiddingSeasonalityAdjustmentServiceClient client = new BiddingSeasonalityAdjustmentServiceClientImpl(mockGrpcClient.Object, null); MutateBiddingSeasonalityAdjustmentsResponse response = client.MutateBiddingSeasonalityAdjustments(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task MutateBiddingSeasonalityAdjustmentsAsync() { moq::Mock <BiddingSeasonalityAdjustmentService.BiddingSeasonalityAdjustmentServiceClient> mockGrpcClient = new moq::Mock <BiddingSeasonalityAdjustmentService.BiddingSeasonalityAdjustmentServiceClient>(moq::MockBehavior.Strict); MutateBiddingSeasonalityAdjustmentsRequest request = new MutateBiddingSeasonalityAdjustmentsRequest { CustomerId = "customer_id3b3724cb", Operations = { new BiddingSeasonalityAdjustmentOperation(), }, }; MutateBiddingSeasonalityAdjustmentsResponse expectedResponse = new MutateBiddingSeasonalityAdjustmentsResponse { Results = { new MutateBiddingSeasonalityAdjustmentsResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateBiddingSeasonalityAdjustmentsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateBiddingSeasonalityAdjustmentsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); BiddingSeasonalityAdjustmentServiceClient client = new BiddingSeasonalityAdjustmentServiceClientImpl(mockGrpcClient.Object, null); MutateBiddingSeasonalityAdjustmentsResponse responseCallSettings = await client.MutateBiddingSeasonalityAdjustmentsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateBiddingSeasonalityAdjustmentsResponse responseCancellationToken = await client.MutateBiddingSeasonalityAdjustmentsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); 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="startDateTime">The start time of the data exclusion (in /// yyyy-MM-dd HH:mm:ss format) in the account's timezone.</param> /// <param name="endDateTime">The end time of the data exclusion (in /// yyyy-MM-dd HH:mm:ss format) in the account's timezone.</param> /// <param name="conversionRateModifier">The conversion rate adjustment (an increase or a /// decrease), which accounts for estimated changes in conversion rate due to a future /// event.</param> public void Run(GoogleAdsClient client, long customerId, string startDateTime, string endDateTime, double conversionRateModifier) { // Get the BiddingSeasonalityAdjustmentServiceClient. BiddingSeasonalityAdjustmentServiceClient biddingSeasonalityAdjustmentService = client.GetService(Services.V10.BiddingSeasonalityAdjustmentService); // [START add_bidding_seasonality_adjustment] BiddingSeasonalityAdjustment seasonalityAdjustment = new BiddingSeasonalityAdjustment() { // A unique name is required for every seasonality adjustment. Name = "Seasonality adjustment #" + ExampleUtilities.GetRandomString(), // The CHANNEL scope applies the conversionRateModifier to all campaigns of // specific advertising channel types. In this example, the // conversionRateModifier will only apply to Search campaigns. Use the // CAMPAIGN scope to instead limit the scope to specific campaigns. Scope = SeasonalityEventScope.Channel, AdvertisingChannelTypes = { AdvertisingChannelType.Search }, // If setting scope CAMPAIGN, add individual campaign resource name(s) // according to the commented out line below. // Campaigns = { "INSERT_CAMPAIGN_RESOURCE_NAME_HERE" }, // The date range should be less than 14 days. StartDateTime = startDateTime, EndDateTime = endDateTime, // The conversionRateModifier is the expected future conversion rate change. // When this field is unset or set to 1.0, no adjustment will be applied to // traffic. The allowed range is 0.1 to 10.0. ConversionRateModifier = conversionRateModifier }; BiddingSeasonalityAdjustmentOperation operation = new BiddingSeasonalityAdjustmentOperation() { Create = seasonalityAdjustment }; try { MutateBiddingSeasonalityAdjustmentsResponse response = biddingSeasonalityAdjustmentService.MutateBiddingSeasonalityAdjustments( customerId.ToString(), new[] { operation }); Console.WriteLine($"Added seasonality adjustment with resource name: " + $"{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; } // [END add_bidding_seasonality_adjustment] }