public async stt::Task FetchProcessorTypesResourceNamesAsync() { moq::Mock <DocumentProcessorService.DocumentProcessorServiceClient> mockGrpcClient = new moq::Mock <DocumentProcessorService.DocumentProcessorServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); FetchProcessorTypesRequest request = new FetchProcessorTypesRequest { ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), }; FetchProcessorTypesResponse expectedResponse = new FetchProcessorTypesResponse { ProcessorTypes = { new ProcessorType(), }, }; mockGrpcClient.Setup(x => x.FetchProcessorTypesAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <FetchProcessorTypesResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DocumentProcessorServiceClient client = new DocumentProcessorServiceClientImpl(mockGrpcClient.Object, null); FetchProcessorTypesResponse responseCallSettings = await client.FetchProcessorTypesAsync(request.ParentAsLocationName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); FetchProcessorTypesResponse responseCancellationToken = await client.FetchProcessorTypesAsync(request.ParentAsLocationName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void FetchProcessorTypesResourceNames() { moq::Mock <DocumentProcessorService.DocumentProcessorServiceClient> mockGrpcClient = new moq::Mock <DocumentProcessorService.DocumentProcessorServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); FetchProcessorTypesRequest request = new FetchProcessorTypesRequest { ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), }; FetchProcessorTypesResponse expectedResponse = new FetchProcessorTypesResponse { ProcessorTypes = { new ProcessorType(), }, }; mockGrpcClient.Setup(x => x.FetchProcessorTypes(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DocumentProcessorServiceClient client = new DocumentProcessorServiceClientImpl(mockGrpcClient.Object, null); FetchProcessorTypesResponse response = client.FetchProcessorTypes(request.ParentAsLocationName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }