public async stt::Task GenerateKeywordIdeasRequestObjectAsync() { 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.GenerateKeywordIdeasAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GenerateKeywordIdeaResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanIdeaServiceClient client = new KeywordPlanIdeaServiceClientImpl(mockGrpcClient.Object, null); GenerateKeywordIdeaResponse responseCallSettings = await client.GenerateKeywordIdeasAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); GenerateKeywordIdeaResponse responseCancellationToken = await client.GenerateKeywordIdeasAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GenerateKeywordIdeasAsync() { 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.GenerateKeywordIdeasAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <GenerateKeywordIdeaResponse>(Task.FromResult(expectedResponse), null, null, null, null)); 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 = await client.GenerateKeywordIdeasAsync(customerId, language, geoTargetConstants, keywordPlanNetwork); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task GenerateKeywordIdeasAsync2() { 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.GenerateKeywordIdeasAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <GenerateKeywordIdeaResponse>(Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanIdeaServiceClient client = new KeywordPlanIdeaServiceClientImpl(mockGrpcClient.Object, null); GenerateKeywordIdeaResponse response = await client.GenerateKeywordIdeasAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }