public async stt::Task MutateAssetSetsRequestObjectAsync() { moq::Mock <AssetSetService.AssetSetServiceClient> mockGrpcClient = new moq::Mock <AssetSetService.AssetSetServiceClient>(moq::MockBehavior.Strict); MutateAssetSetsRequest request = new MutateAssetSetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AssetSetOperation(), }, PartialFailure = false, ValidateOnly = true, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateAssetSetsResponse expectedResponse = new MutateAssetSetsResponse { Results = { new MutateAssetSetResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateAssetSetsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateAssetSetsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AssetSetServiceClient client = new AssetSetServiceClientImpl(mockGrpcClient.Object, null); MutateAssetSetsResponse responseCallSettings = await client.MutateAssetSetsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateAssetSetsResponse responseCancellationToken = await client.MutateAssetSetsAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void MutateAssetSets() { moq::Mock <AssetSetService.AssetSetServiceClient> mockGrpcClient = new moq::Mock <AssetSetService.AssetSetServiceClient>(moq::MockBehavior.Strict); MutateAssetSetsRequest request = new MutateAssetSetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AssetSetOperation(), }, }; MutateAssetSetsResponse expectedResponse = new MutateAssetSetsResponse { Results = { new MutateAssetSetResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateAssetSets(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AssetSetServiceClient client = new AssetSetServiceClientImpl(mockGrpcClient.Object, null); MutateAssetSetsResponse response = client.MutateAssetSets(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
// [END add_asset] // [START add_asset_set] /// <summary> /// Creates the asset set. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID.</param> /// <returns>The resource name of the asset set.</returns> private string CreateAssetSet(GoogleAdsClient client, long customerId) { AssetSetServiceClient assetSetService = client.GetService( Services.V10.AssetSetService); // Creates an AssetSet which will be used to link the dynamic remarketing assets // to a campaign. AssetSet assetSet = new AssetSet() { Name = "My dynamic remarketing assets " + ExampleUtilities.GetRandomString(), Type = AssetSetType.DynamicEducation }; // Creates an operation to add the link. AssetSetOperation operation = new AssetSetOperation() { Create = assetSet }; // Sends the mutate request. MutateAssetSetsResponse response = assetSetService.MutateAssetSets( customerId.ToString(), new[] { operation }); // Prints some information about the response. string resourceName = response.Results[0].ResourceName; Console.WriteLine($"Created asset set with resource name {resourceName}."); return(resourceName); }