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();
        }
Пример #2
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();
        }