public async stt::Task CompleteQueryRequestObjectAsync() { moq::Mock <Completion.CompletionClient> mockGrpcClient = new moq::Mock <Completion.CompletionClient>(moq::MockBehavior.Strict); CompleteQueryRequest request = new CompleteQueryRequest { ParentAsTenantOrProjectName = TenantOrProjectName.FromProjectTenant("[PROJECT]", "[TENANT]"), Query = "queryf0c71c1b", LanguageCodes = { "language_codes1de1a181", }, PageSize = -226905851, CompanyAsCompanyName = CompanyName.FromProjectCompany("[PROJECT]", "[COMPANY]"), Scope = CompleteQueryRequest.Types.CompletionScope.Unspecified, Type = CompleteQueryRequest.Types.CompletionType.Combined, }; CompleteQueryResponse expectedResponse = new CompleteQueryResponse { CompletionResults = { new CompleteQueryResponse.Types.CompletionResult(), }, Metadata = new ResponseMetadata(), }; mockGrpcClient.Setup(x => x.CompleteQueryAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <CompleteQueryResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CompletionClient client = new CompletionClientImpl(mockGrpcClient.Object, null); CompleteQueryResponse responseCallSettings = await client.CompleteQueryAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); CompleteQueryResponse responseCancellationToken = await client.CompleteQueryAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task CompleteQueryAsync() { Mock <Completion.CompletionClient> mockGrpcClient = new Mock <Completion.CompletionClient>(MockBehavior.Strict); CompleteQueryRequest request = new CompleteQueryRequest { ProjectName = new ProjectName("[PROJECT]"), Query = "query107944136", PageSize = 883849137, }; CompleteQueryResponse expectedResponse = new CompleteQueryResponse(); mockGrpcClient.Setup(x => x.CompleteQueryAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <CompleteQueryResponse>(Task.FromResult(expectedResponse), null, null, null, null)); CompletionClient client = new CompletionClientImpl(mockGrpcClient.Object, null); CompleteQueryResponse response = await client.CompleteQueryAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }