Example #1
0
        public async stt::Task GetKeywordPlanRequestObjectAsync()
        {
            moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict);
            GetKeywordPlanRequest request = new GetKeywordPlanRequest
            {
                ResourceNameAsKeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"),
            };
            gagvr::KeywordPlan expectedResponse = new gagvr::KeywordPlan
            {
                ResourceNameAsKeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"),
                Id = -6774108720365892680L,
                KeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"),
                ForecastPeriod  = new gagvr::KeywordPlanForecastPeriod(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
        public void GetKeywordPlan()
        {
            moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict);
            GetKeywordPlanRequest request = new GetKeywordPlanRequest
            {
                ResourceNameAsKeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"),
            };
            gagvr::KeywordPlan expectedResponse = new gagvr::KeywordPlan
            {
                ResourceNameAsKeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"),
                Id = -6774108720365892680L,
                KeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"),
                ForecastPeriod  = new gagvr::KeywordPlanForecastPeriod(),
            };

            mockGrpcClient.Setup(x => x.GetKeywordPlan(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            KeywordPlanServiceClient client   = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::KeywordPlan       response = client.GetKeywordPlan(request.ResourceName);

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