Example #1
0
        public void ProcessDocumentRequestObject()
        {
            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);
            ProcessRequest request = new ProcessRequest
            {
                ProcessorName   = ProcessorName.FromProjectLocationProcessor("[PROJECT]", "[LOCATION]", "[PROCESSOR]"),
                SkipHumanReview = true,
                InlineDocument  = new Document(),
                RawDocument     = new RawDocument(),
            };
            ProcessResponse expectedResponse = new ProcessResponse
            {
                Document          = new Document(),
                HumanReviewStatus = new HumanReviewStatus(),
            };

            mockGrpcClient.Setup(x => x.ProcessDocument(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            DocumentProcessorServiceClient client = new DocumentProcessorServiceClientImpl(mockGrpcClient.Object, null);
            ProcessResponse response = client.ProcessDocument(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
        public async stt::Task ProcessDocumentRequestObjectAsync()
        {
            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);
            ProcessRequest request = new ProcessRequest
            {
                ProcessorName   = ProcessorName.FromProjectLocationProcessor("[PROJECT]", "[LOCATION]", "[PROCESSOR]"),
                SkipHumanReview = true,
                InlineDocument  = new Document(),
                RawDocument     = new RawDocument(),
            };
            ProcessResponse expectedResponse = new ProcessResponse
            {
                Document          = new Document(),
                HumanReviewStatus = new HumanReviewStatus(),
            };

            mockGrpcClient.Setup(x => x.ProcessDocumentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ProcessResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            DocumentProcessorServiceClient client = new DocumentProcessorServiceClientImpl(mockGrpcClient.Object, null);
            ProcessResponse responseCallSettings  = await client.ProcessDocumentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ProcessResponse responseCancellationToken = await client.ProcessDocumentAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task CreateProcessorResourceNamesAsync()
        {
            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);
            CreateProcessorRequest request = new CreateProcessorRequest
            {
                ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                Processor            = new Processor(),
            };
            Processor expectedResponse = new Processor
            {
                ProcessorName           = ProcessorName.FromProjectLocationProcessor("[PROJECT]", "[LOCATION]", "[PROCESSOR]"),
                Type                    = "typee2cc9d59",
                DisplayName             = "display_name137f65c2",
                State                   = Processor.Types.State.Failed,
                ProcessEndpoint         = "process_endpoint4445f26d",
                CreateTime              = new wkt::Timestamp(),
                KmsKeyName              = "kms_key_name06bd122b",
                DefaultProcessorVersion = "default_processor_versiona99cda5e",
            };

            mockGrpcClient.Setup(x => x.CreateProcessorAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Processor>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            DocumentProcessorServiceClient client = new DocumentProcessorServiceClientImpl(mockGrpcClient.Object, null);
            Processor responseCallSettings        = await client.CreateProcessorAsync(request.ParentAsLocationName, request.Processor, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Processor responseCancellationToken = await client.CreateProcessorAsync(request.ParentAsLocationName, request.Processor, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void CreateProcessorRequestObject()
        {
            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);
            CreateProcessorRequest request = new CreateProcessorRequest
            {
                ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                Processor            = new Processor(),
            };
            Processor expectedResponse = new Processor
            {
                ProcessorName           = ProcessorName.FromProjectLocationProcessor("[PROJECT]", "[LOCATION]", "[PROCESSOR]"),
                Type                    = "typee2cc9d59",
                DisplayName             = "display_name137f65c2",
                State                   = Processor.Types.State.Failed,
                ProcessEndpoint         = "process_endpoint4445f26d",
                CreateTime              = new wkt::Timestamp(),
                KmsKeyName              = "kms_key_name06bd122b",
                DefaultProcessorVersion = "default_processor_versiona99cda5e",
            };

            mockGrpcClient.Setup(x => x.CreateProcessor(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            DocumentProcessorServiceClient client = new DocumentProcessorServiceClientImpl(mockGrpcClient.Object, null);
            Processor response = client.CreateProcessor(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        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 ProcessDocumentResourceNames()
        {
            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);
            ProcessRequest request = new ProcessRequest
            {
                ProcessorName = ProcessorName.FromProjectLocationProcessor("[PROJECT]", "[LOCATION]", "[PROCESSOR]"),
            };
            ProcessResponse expectedResponse = new ProcessResponse
            {
                Document = new Document(),
#pragma warning disable CS0612
                HumanReviewOperation = "human_review_operationb1fb7921",
#pragma warning restore CS0612
                HumanReviewStatus = new HumanReviewStatus(),
            };

            mockGrpcClient.Setup(x => x.ProcessDocument(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            DocumentProcessorServiceClient client = new DocumentProcessorServiceClientImpl(mockGrpcClient.Object, null);
            ProcessResponse response = client.ProcessDocument(request.ProcessorName);

            xunit::Assert.Same(expectedResponse, response);
            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();
        }