Beispiel #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();
        }
        public async Task GetKeywordPlanAsync2()
        {
            Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict);
            GetKeywordPlanRequest request = new GetKeywordPlanRequest
            {
                ResourceName = new KeywordPlanName("[CUSTOMER]", "[KEYWORD_PLAN]").ToString(),
            };
            KeywordPlan expectedResponse = new KeywordPlan
            {
                ResourceName = "resourceName2625949903",
            };

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

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