Beispiel #1
0
        public async stt::Task GenerateHistoricalMetricsResourceNamesAsync()
        {
            moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict);
            GenerateHistoricalMetricsRequest request = new GenerateHistoricalMetricsRequest
            {
                KeywordPlanAsKeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"),
            };
            GenerateHistoricalMetricsResponse expectedResponse = new GenerateHistoricalMetricsResponse
            {
                Metrics =
                {
                    new KeywordPlanKeywordHistoricalMetrics(),
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public async stt::Task GenerateHistoricalMetricsAsync()
        {
            moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict);
            GenerateHistoricalMetricsRequest request = new GenerateHistoricalMetricsRequest
            {
                KeywordPlan = "keyword_plan348c505a",
            };
            GenerateHistoricalMetricsResponse expectedResponse = new GenerateHistoricalMetricsResponse
            {
                Metrics =
                {
                    new KeywordPlanKeywordHistoricalMetrics(),
                },
            };

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

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

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task GenerateHistoricalMetricsAsync2()
        {
            Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict);
            GenerateHistoricalMetricsRequest request = new GenerateHistoricalMetricsRequest
            {
                KeywordPlan = new KeywordPlanName("[CUSTOMER]", "[KEYWORD_PLAN]").ToString(),
            };
            GenerateHistoricalMetricsResponse expectedResponse = new GenerateHistoricalMetricsResponse();

            mockGrpcClient.Setup(x => x.GenerateHistoricalMetricsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <GenerateHistoricalMetricsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            KeywordPlanServiceClient          client   = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null);
            GenerateHistoricalMetricsResponse response = await client.GenerateHistoricalMetricsAsync(request);

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