Exemple #1
0
        public async stt::Task GetKeywordPlanCampaignResourceNamesAsync()
        {
            moq::Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanCampaignService.KeywordPlanCampaignServiceClient>(moq::MockBehavior.Strict);
            GetKeywordPlanCampaignRequest request = new GetKeywordPlanCampaignRequest
            {
                ResourceNameAsKeywordPlanCampaignName = gagvr::KeywordPlanCampaignName.FromCustomerKeywordPlanCampaign("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_ID]"),
            };
            gagvr::KeywordPlanCampaign expectedResponse = new gagvr::KeywordPlanCampaign
            {
                ResourceNameAsKeywordPlanCampaignName = gagvr::KeywordPlanCampaignName.FromCustomerKeywordPlanCampaign("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_ID]"),
                KeywordPlanNetwork = gagve::KeywordPlanNetworkEnum.Types.KeywordPlanNetwork.Unspecified,
                GeoTargets         =
                {
                    new gagvr::KeywordPlanGeoTarget(),
                },
                KeywordPlanAsKeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER_ID]", "[KEYWORD_PLAN_ID]"),
                Id = -6774108720365892680L,
                KeywordPlanCampaignName = gagvr::KeywordPlanCampaignName.FromCustomerKeywordPlanCampaign("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_ID]"),
                LanguageConstantsAsLanguageConstantNames =
                {
                    gagvr::LanguageConstantName.FromCriterion("[CRITERION_ID]"),
                },
                CpcBidMicros = 7321761304249472746L,
            };

            mockGrpcClient.Setup(x => x.GetKeywordPlanCampaignAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::KeywordPlanCampaign>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            KeywordPlanCampaignServiceClient client = new KeywordPlanCampaignServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::KeywordPlanCampaign       responseCallSettings = await client.GetKeywordPlanCampaignAsync(request.ResourceNameAsKeywordPlanCampaignName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::KeywordPlanCampaign responseCancellationToken = await client.GetKeywordPlanCampaignAsync(request.ResourceNameAsKeywordPlanCampaignName, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }