Esempio n. 1
0
        public async stt::Task GenerateForecastCurveResourceNamesAsync()
        {
            moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict);
            GenerateForecastCurveRequest request = new GenerateForecastCurveRequest
            {
                KeywordPlanAsKeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"),
            };
            GenerateForecastCurveResponse expectedResponse = new GenerateForecastCurveResponse
            {
                CampaignForecastCurves =
                {
                    new KeywordPlanCampaignForecastCurve(),
                },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            GenerateForecastCurveResponse responseCancellationToken = await client.GenerateForecastCurveAsync(request.KeywordPlanAsKeywordPlanName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        public async stt::Task GenerateForecastCurveAsync()
        {
            moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict);
            GenerateForecastCurveRequest request = new GenerateForecastCurveRequest
            {
                KeywordPlan = "keyword_plan348c505a",
            };
            GenerateForecastCurveResponse expectedResponse = new GenerateForecastCurveResponse
            {
                CampaignForecastCurves =
                {
                    new KeywordPlanCampaignForecastCurve(),
                },
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            GenerateForecastCurveResponse responseCancellationToken = await client.GenerateForecastCurveAsync(request.KeywordPlan, st::CancellationToken.None);

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