public void SuggestQueriesRequestObject() { moq::Mock <AutoSuggestionService.AutoSuggestionServiceClient> mockGrpcClient = new moq::Mock <AutoSuggestionService.AutoSuggestionServiceClient>(moq::MockBehavior.Strict); SuggestQueriesRequest request = new SuggestQueriesRequest { ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Scopes = { "scopes35c99a1e", }, Query = "queryf0c71c1b", SuggestionTypes = { SuggestionType.Entity, }, }; SuggestQueriesResponse expectedResponse = new SuggestQueriesResponse { Suggestions = { new Suggestion(), }, }; mockGrpcClient.Setup(x => x.SuggestQueries(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AutoSuggestionServiceClient client = new AutoSuggestionServiceClientImpl(mockGrpcClient.Object, null); SuggestQueriesResponse response = client.SuggestQueries(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task SuggestQueriesRequestObjectAsync() { moq::Mock <AutoSuggestionService.AutoSuggestionServiceClient> mockGrpcClient = new moq::Mock <AutoSuggestionService.AutoSuggestionServiceClient>(moq::MockBehavior.Strict); SuggestQueriesRequest request = new SuggestQueriesRequest { ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Scopes = { "scopes35c99a1e", }, Query = "queryf0c71c1b", SuggestionTypes = { SuggestionType.Entity, }, }; SuggestQueriesResponse expectedResponse = new SuggestQueriesResponse { Suggestions = { new Suggestion(), }, }; mockGrpcClient.Setup(x => x.SuggestQueriesAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <SuggestQueriesResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AutoSuggestionServiceClient client = new AutoSuggestionServiceClientImpl(mockGrpcClient.Object, null); SuggestQueriesResponse responseCallSettings = await client.SuggestQueriesAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); SuggestQueriesResponse responseCancellationToken = await client.SuggestQueriesAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for SuggestQueries</summary> public void SuggestQueriesRequestObject() { // Snippet: SuggestQueries(SuggestQueriesRequest, CallSettings) // Create client AutoSuggestionServiceClient autoSuggestionServiceClient = AutoSuggestionServiceClient.Create(); // Initialize request argument(s) SuggestQueriesRequest request = new SuggestQueriesRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Scopes = { "", }, Query = "", SuggestionTypes = { SuggestionType.Unspecified, }, }; // Make the request SuggestQueriesResponse response = autoSuggestionServiceClient.SuggestQueries(request); // End snippet }