Exemplo n.º 1
0
 /// <summary>Snippet for RedactImage</summary>
 public void RedactImage_RequestObject()
 {
     // Snippet: RedactImage(RedactImageRequest,CallSettings)
     // Create client
     DlpServiceClient dlpServiceClient = DlpServiceClient.Create();
     // Initialize request argument(s)
     RedactImageRequest request = new RedactImageRequest
     {
         ParentAsProjectName = new ProjectName("[PROJECT]"),
     };
     // Make the request
     RedactImageResponse response = dlpServiceClient.RedactImage(request);
     // End snippet
 }
Exemplo n.º 2
0
        /// <summary>Snippet for RedactImageAsync</summary>
        public async Task RedactImageAsync_RequestObject()
        {
            // Snippet: RedactImageAsync(RedactImageRequest,CallSettings)
            // Additional: RedactImageAsync(RedactImageRequest,CancellationToken)
            // Create client
            DlpServiceClient dlpServiceClient = await DlpServiceClient.CreateAsync();

            // Initialize request argument(s)
            RedactImageRequest request = new RedactImageRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
            };
            // Make the request
            RedactImageResponse response = await dlpServiceClient.RedactImageAsync(request);

            // End snippet
        }
        public async Task RedactImageAsync()
        {
            Mock <DlpService.DlpServiceClient> mockGrpcClient = new Mock <DlpService.DlpServiceClient>(MockBehavior.Strict);
            RedactImageRequest request = new RedactImageRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
            };
            RedactImageResponse expectedResponse = new RedactImageResponse
            {
                RedactedImage = ByteString.CopyFromUtf8("28"),
                ExtractedText = "extractedText998260012",
            };

            mockGrpcClient.Setup(x => x.RedactImageAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <RedactImageResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            DlpServiceClient    client   = new DlpServiceClientImpl(mockGrpcClient.Object, null);
            RedactImageResponse response = await client.RedactImageAsync(request);

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