예제 #1
0
        public void MutateCampaignGroups()
        {
            moq::Mock <CampaignGroupService.CampaignGroupServiceClient> mockGrpcClient = new moq::Mock <CampaignGroupService.CampaignGroupServiceClient>(moq::MockBehavior.Strict);
            MutateCampaignGroupsRequest request = new MutateCampaignGroupsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CampaignGroupOperation(),
                },
            };
            MutateCampaignGroupsResponse expectedResponse = new MutateCampaignGroupsResponse
            {
                Results =
                {
                    new MutateCampaignGroupResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCampaignGroups(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CampaignGroupServiceClient   client   = new CampaignGroupServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignGroupsResponse response = client.MutateCampaignGroups(request.CustomerId, request.Operations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #2
0
        public async stt::Task MutateCampaignGroupsRequestObjectAsync()
        {
            moq::Mock <CampaignGroupService.CampaignGroupServiceClient> mockGrpcClient = new moq::Mock <CampaignGroupService.CampaignGroupServiceClient>(moq::MockBehavior.Strict);
            MutateCampaignGroupsRequest request = new MutateCampaignGroupsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CampaignGroupOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = true,
                ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly,
            };
            MutateCampaignGroupsResponse expectedResponse = new MutateCampaignGroupsResponse
            {
                Results =
                {
                    new MutateCampaignGroupResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCampaignGroupsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateCampaignGroupsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CampaignGroupServiceClient   client = new CampaignGroupServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignGroupsResponse responseCallSettings = await client.MutateCampaignGroupsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            Assert.AreEqual(expectedResponse, responseCallSettings);
            MutateCampaignGroupsResponse responseCancellationToken = await client.MutateCampaignGroupsAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void MutateCampaignGroups2()
        {
            Mock <CampaignGroupService.CampaignGroupServiceClient> mockGrpcClient = new Mock <CampaignGroupService.CampaignGroupServiceClient>(MockBehavior.Strict);
            MutateCampaignGroupsRequest request = new MutateCampaignGroupsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCampaignGroupsResponse expectedResponse = new MutateCampaignGroupsResponse();

            mockGrpcClient.Setup(x => x.MutateCampaignGroups(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CampaignGroupServiceClient   client   = new CampaignGroupServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignGroupsResponse response = client.MutateCampaignGroups(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task MutateCampaignGroupsAsync2()
        {
            Mock <CampaignGroupService.CampaignGroupServiceClient> mockGrpcClient = new Mock <CampaignGroupService.CampaignGroupServiceClient>(MockBehavior.Strict);
            MutateCampaignGroupsRequest request = new MutateCampaignGroupsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCampaignGroupsResponse expectedResponse = new MutateCampaignGroupsResponse();

            mockGrpcClient.Setup(x => x.MutateCampaignGroupsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignGroupsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CampaignGroupServiceClient   client   = new CampaignGroupServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignGroupsResponse response = await client.MutateCampaignGroupsAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #5
0
        /// <summary>
        /// Creates a new CampaignGroup in the specified client account.
        /// </summary>
        /// <param name="client">The Google Ads API client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <returns>resource name of the newly created campaign group.</returns>
        private static String CreateCampaignGroup(GoogleAdsClient client, long customerId)
        {
            CampaignGroupServiceClient campaignGroupService = client.GetService(
                Services.V0.CampaignGroupService);

            CampaignGroup campaignGroup = new CampaignGroup()
            {
                Name = "Mars campaign group #" + ExampleUtilities.GetRandomString()
            };

            CampaignGroupOperation op = new CampaignGroupOperation()
            {
                Create = campaignGroup
            };

            MutateCampaignGroupsResponse response =
                campaignGroupService.MutateCampaignGroups(
                    customerId.ToString(), new CampaignGroupOperation[] { op });
            String groupResourceName = response.Results[0].ResourceName;

            Console.WriteLine($"Added campaign group with resource name: {groupResourceName}");
            return(groupResourceName);
        }