public async stt::Task BatchAnnotateFilesAsync()
        {
            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);
            BatchAnnotateFilesRequest request = new BatchAnnotateFilesRequest
            {
                Requests =
                {
                    new AnnotateFileRequest(),
                },
            };
            BatchAnnotateFilesResponse expectedResponse = new BatchAnnotateFilesResponse
            {
                Responses =
                {
                    new AnnotateFileResponse(),
                },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            BatchAnnotateFilesResponse responseCancellationToken = await client.BatchAnnotateFilesAsync(request.Requests, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        public async Task BatchAnnotateFilesAsync2()
        {
            Mock <ImageAnnotator.ImageAnnotatorClient> mockGrpcClient = new Mock <ImageAnnotator.ImageAnnotatorClient>(MockBehavior.Strict);

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

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

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