Пример #1
0
        public void GenerateKeywordIdeas()
        {
            Mock <KeywordPlanIdeaService.KeywordPlanIdeaServiceClient> mockGrpcClient = new Mock <KeywordPlanIdeaService.KeywordPlanIdeaServiceClient>(MockBehavior.Strict);
            GenerateKeywordIdeasRequest expectedRequest = new GenerateKeywordIdeasRequest
            {
                CustomerId         = "customerId-1772061412",
                Language           = null,
                GeoTargetConstants = { },
                KeywordPlanNetwork = KeywordPlanNetworkEnum.Types.KeywordPlanNetwork.Unspecified,
            };
            GenerateKeywordIdeaResponse expectedResponse = new GenerateKeywordIdeaResponse();

            mockGrpcClient.Setup(x => x.GenerateKeywordIdeas(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            KeywordPlanIdeaServiceClient client = new KeywordPlanIdeaServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            string language   = null;
            IEnumerable <string> geoTargetConstants = new List <string>();

            KeywordPlanNetworkEnum.Types.KeywordPlanNetwork keywordPlanNetwork = KeywordPlanNetworkEnum.Types.KeywordPlanNetwork.Unspecified;
            GenerateKeywordIdeaResponse response = client.GenerateKeywordIdeas(customerId, language, geoTargetConstants, keywordPlanNetwork);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GenerateKeywordIdeasRequestObject()
        {
            moq::Mock <KeywordPlanIdeaService.KeywordPlanIdeaServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanIdeaService.KeywordPlanIdeaServiceClient>(moq::MockBehavior.Strict);
            GenerateKeywordIdeasRequest request = new GenerateKeywordIdeasRequest
            {
                CustomerId         = "customer_id3b3724cb",
                KeywordAndUrlSeed  = new KeywordAndUrlSeed(),
                KeywordSeed        = new KeywordSeed(),
                UrlSeed            = new UrlSeed(),
                Language           = "language7dae1285",
                GeoTargetConstants =
                {
                    "geo_target_constants2f692206",
                },
                KeywordPlanNetwork = gagve::KeywordPlanNetworkEnum.Types.KeywordPlanNetwork.Unspecified,
            };
            GenerateKeywordIdeaResponse expectedResponse = new GenerateKeywordIdeaResponse
            {
                Results =
                {
                    new GenerateKeywordIdeaResult(),
                },
            };

            mockGrpcClient.Setup(x => x.GenerateKeywordIdeas(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            KeywordPlanIdeaServiceClient client   = new KeywordPlanIdeaServiceClientImpl(mockGrpcClient.Object, null);
            GenerateKeywordIdeaResponse  response = client.GenerateKeywordIdeas(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GenerateKeywordIdeas2()
        {
            Mock <KeywordPlanIdeaService.KeywordPlanIdeaServiceClient> mockGrpcClient = new Mock <KeywordPlanIdeaService.KeywordPlanIdeaServiceClient>(MockBehavior.Strict);
            GenerateKeywordIdeasRequest request = new GenerateKeywordIdeasRequest
            {
                CustomerId = "customerId-1772061412",
                Language   = new StringValue().Value,
                // TODO(liseno): Implicit type cast from StringValue to String failed,
                GeoTargetConstants = { },
                KeywordPlanNetwork = KeywordPlanNetworkEnum.Types.KeywordPlanNetwork.Unspecified,
            };
            GenerateKeywordIdeaResponse expectedResponse = new GenerateKeywordIdeaResponse();

            mockGrpcClient.Setup(x => x.GenerateKeywordIdeas(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            KeywordPlanIdeaServiceClient client   = new KeywordPlanIdeaServiceClientImpl(mockGrpcClient.Object, null);
            GenerateKeywordIdeaResponse  response = client.GenerateKeywordIdeas(request);

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