public async stt::Task BatchAnnotateImagesRequestObjectAsync()
        {
            moq::Mock <ImageAnnotator.ImageAnnotatorClient> mockGrpcClient = new moq::Mock <ImageAnnotator.ImageAnnotatorClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            BatchAnnotateImagesRequest request = new BatchAnnotateImagesRequest
            {
                Requests =
                {
                    new AnnotateImageRequest(),
                },
                Parent = "parent7858e4d0",
            };
            BatchAnnotateImagesResponse expectedResponse = new BatchAnnotateImagesResponse
            {
                Responses =
                {
                    new AnnotateImageResponse(),
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void BatchAnnotateImages()
        {
            moq::Mock <ImageAnnotator.ImageAnnotatorClient> mockGrpcClient = new moq::Mock <ImageAnnotator.ImageAnnotatorClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            BatchAnnotateImagesRequest request = new BatchAnnotateImagesRequest
            {
                Requests =
                {
                    new AnnotateImageRequest(),
                },
            };
            BatchAnnotateImagesResponse expectedResponse = new BatchAnnotateImagesResponse
            {
                Responses =
                {
                    new AnnotateImageResponse(),
                },
            };

            mockGrpcClient.Setup(x => x.BatchAnnotateImages(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ImageAnnotatorClient        client   = new ImageAnnotatorClientImpl(mockGrpcClient.Object, null);
            BatchAnnotateImagesResponse response = client.BatchAnnotateImages(request.Requests);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 3
0
        public async Task BatchAnnotateImagesAsync2()
        {
            Mock <ImageAnnotator.ImageAnnotatorClient> mockGrpcClient = new Mock <ImageAnnotator.ImageAnnotatorClient>(MockBehavior.Strict);
            BatchAnnotateImagesRequest request = new BatchAnnotateImagesRequest
            {
                Requests = { },
            };
            BatchAnnotateImagesResponse expectedResponse = new BatchAnnotateImagesResponse();

            mockGrpcClient.Setup(x => x.BatchAnnotateImagesAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <BatchAnnotateImagesResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            ImageAnnotatorClient        client   = new ImageAnnotatorClientImpl(mockGrpcClient.Object, null);
            BatchAnnotateImagesResponse response = await client.BatchAnnotateImagesAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 4
0
        public void BatchAnnotateImages2()
        {
            Mock <ImageAnnotator.ImageAnnotatorClient> mockGrpcClient = new Mock <ImageAnnotator.ImageAnnotatorClient>(MockBehavior.Strict);
            BatchAnnotateImagesRequest request = new BatchAnnotateImagesRequest
            {
                Requests = { },
            };
            BatchAnnotateImagesResponse expectedResponse = new BatchAnnotateImagesResponse();

            mockGrpcClient.Setup(x => x.BatchAnnotateImages(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ImageAnnotatorClient        client   = new ImageAnnotatorClientImpl(mockGrpcClient.Object, null);
            BatchAnnotateImagesResponse response = client.BatchAnnotateImages(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 5
0
        public void BatchAnnotateFiles()
        {
            Mock <ImageAnnotator.ImageAnnotatorClient> mockGrpcClient = new Mock <ImageAnnotator.ImageAnnotatorClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            BatchAnnotateFilesRequest expectedRequest = new BatchAnnotateFilesRequest
            {
                Requests = { },
            };
            BatchAnnotateFilesResponse expectedResponse = new BatchAnnotateFilesResponse();

            mockGrpcClient.Setup(x => x.BatchAnnotateFiles(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ImageAnnotatorClient client = new ImageAnnotatorClientImpl(mockGrpcClient.Object, null);
            IEnumerable <AnnotateFileRequest> requests = new List <AnnotateFileRequest>();
            BatchAnnotateFilesResponse        response = client.BatchAnnotateFiles(requests);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }