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(); }
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(); }