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(); }
public void BatchAnnotateFiles() { 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.BatchAnnotateFiles(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ImageAnnotatorClient client = new ImageAnnotatorClientImpl(mockGrpcClient.Object, null); BatchAnnotateFilesResponse response = client.BatchAnnotateFiles(request.Requests); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for BatchAnnotateFiles</summary> public void BatchAnnotateFiles_RequestObject() { // Snippet: BatchAnnotateFiles(BatchAnnotateFilesRequest,CallSettings) // Create client ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.Create(); // Initialize request argument(s) BatchAnnotateFilesRequest request = new BatchAnnotateFilesRequest { Requests = { }, }; // Make the request BatchAnnotateFilesResponse response = imageAnnotatorClient.BatchAnnotateFiles(request); // End snippet }
/// <summary>Snippet for BatchAnnotateFilesAsync</summary> public async Task BatchAnnotateFilesAsync_RequestObject() { // Snippet: BatchAnnotateFilesAsync(BatchAnnotateFilesRequest,CallSettings) // Additional: BatchAnnotateFilesAsync(BatchAnnotateFilesRequest,CancellationToken) // Create client ImageAnnotatorClient imageAnnotatorClient = await ImageAnnotatorClient.CreateAsync(); // Initialize request argument(s) BatchAnnotateFilesRequest request = new BatchAnnotateFilesRequest { Requests = { }, }; // Make the request BatchAnnotateFilesResponse response = await imageAnnotatorClient.BatchAnnotateFilesAsync(request); // End snippet }
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(); }
public void BatchAnnotateFiles2() { 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.BatchAnnotateFiles(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); ImageAnnotatorClient client = new ImageAnnotatorClientImpl(mockGrpcClient.Object, null); BatchAnnotateFilesResponse response = client.BatchAnnotateFiles(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }