Ejemplo n.º 1
0
        public async stt::Task GetKeywordPlanCampaignKeywordRequestObjectAsync()
        {
            moq::Mock <KeywordPlanCampaignKeywordService.KeywordPlanCampaignKeywordServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanCampaignKeywordService.KeywordPlanCampaignKeywordServiceClient>(moq::MockBehavior.Strict);
            GetKeywordPlanCampaignKeywordRequest request = new GetKeywordPlanCampaignKeywordRequest
            {
                ResourceNameAsKeywordPlanCampaignKeywordName = gagvr::KeywordPlanCampaignKeywordName.FromCustomerKeywordPlanCampaignKeyword("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_KEYWORD_ID]"),
            };
            gagvr::KeywordPlanCampaignKeyword expectedResponse = new gagvr::KeywordPlanCampaignKeyword
            {
                ResourceNameAsKeywordPlanCampaignKeywordName = gagvr::KeywordPlanCampaignKeywordName.FromCustomerKeywordPlanCampaignKeyword("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_KEYWORD_ID]"),
                MatchType = gagve::KeywordMatchTypeEnum.Types.KeywordMatchType.Unspecified,
                KeywordPlanCampaignAsKeywordPlanCampaignName = gagvr::KeywordPlanCampaignName.FromCustomerKeywordPlanCampaign("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_ID]"),
                Id       = -6774108720365892680L,
                Text     = "textec51b21c",
                Negative = false,
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            gagvr::KeywordPlanCampaignKeyword responseCancellationToken = await client.GetKeywordPlanCampaignKeywordAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public void GetKeywordPlanCampaignKeyword()
        {
            moq::Mock <KeywordPlanCampaignKeywordService.KeywordPlanCampaignKeywordServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanCampaignKeywordService.KeywordPlanCampaignKeywordServiceClient>(moq::MockBehavior.Strict);
            GetKeywordPlanCampaignKeywordRequest request = new GetKeywordPlanCampaignKeywordRequest
            {
                ResourceNameAsKeywordPlanCampaignKeywordName = gagvr::KeywordPlanCampaignKeywordName.FromCustomerKeywordPlanCampaignKeyword("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_KEYWORD_ID]"),
            };
            gagvr::KeywordPlanCampaignKeyword expectedResponse = new gagvr::KeywordPlanCampaignKeyword
            {
                ResourceNameAsKeywordPlanCampaignKeywordName = gagvr::KeywordPlanCampaignKeywordName.FromCustomerKeywordPlanCampaignKeyword("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_KEYWORD_ID]"),
                MatchType = gagve::KeywordMatchTypeEnum.Types.KeywordMatchType.Unspecified,
                KeywordPlanCampaignAsKeywordPlanCampaignName = gagvr::KeywordPlanCampaignName.FromCustomerKeywordPlanCampaign("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_ID]"),
                Id       = -6774108720365892680L,
                Text     = "textec51b21c",
                Negative = false,
            };

            mockGrpcClient.Setup(x => x.GetKeywordPlanCampaignKeyword(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            KeywordPlanCampaignKeywordServiceClient client   = new KeywordPlanCampaignKeywordServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::KeywordPlanCampaignKeyword       response = client.GetKeywordPlanCampaignKeyword(request.ResourceName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }