예제 #1
0
 /// <summary>Snippet for ValidateMessage</summary>
 public void ValidateMessageRequestObject()
 {
     // Snippet: ValidateMessage(ValidateMessageRequest, CallSettings)
     // Create client
     SchemaServiceClient schemaServiceClient = SchemaServiceClient.Create();
     // Initialize request argument(s)
     ValidateMessageRequest request = new ValidateMessageRequest
     {
         ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
         SchemaName          = SchemaName.FromProjectSchema("[PROJECT]", "[SCHEMA]"),
         Message             = ByteString.Empty,
         Encoding            = Encoding.Unspecified,
     };
     // Make the request
     ValidateMessageResponse response = schemaServiceClient.ValidateMessage(request);
     // End snippet
 }
예제 #2
0
        /// <summary>Snippet for ValidateMessageAsync</summary>
        public async Task ValidateMessageRequestObjectAsync()
        {
            // Snippet: ValidateMessageAsync(ValidateMessageRequest, CallSettings)
            // Additional: ValidateMessageAsync(ValidateMessageRequest, CancellationToken)
            // Create client
            SchemaServiceClient schemaServiceClient = await SchemaServiceClient.CreateAsync();

            // Initialize request argument(s)
            ValidateMessageRequest request = new ValidateMessageRequest
            {
                ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
                SchemaName          = SchemaName.FromProjectSchema("[PROJECT]", "[SCHEMA]"),
                Message             = ByteString.Empty,
                Encoding            = Encoding.Unspecified,
            };
            // Make the request
            ValidateMessageResponse response = await schemaServiceClient.ValidateMessageAsync(request);

            // End snippet
        }
        public void ValidateMessageRequestObject()
        {
            moq::Mock <SchemaService.SchemaServiceClient> mockGrpcClient = new moq::Mock <SchemaService.SchemaServiceClient>(moq::MockBehavior.Strict);
            ValidateMessageRequest request = new ValidateMessageRequest
            {
                ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                SchemaName          = SchemaName.FromProjectSchema("[PROJECT]", "[SCHEMA]"),
                Schema   = new Schema(),
                Message  = proto::ByteString.CopyFromUtf8("message0231e778"),
                Encoding = Encoding.Json,
            };
            ValidateMessageResponse expectedResponse = new ValidateMessageResponse {
            };

            mockGrpcClient.Setup(x => x.ValidateMessage(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SchemaServiceClient     client   = new SchemaServiceClientImpl(mockGrpcClient.Object, null);
            ValidateMessageResponse response = client.ValidateMessage(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task ValidateMessageRequestObjectAsync()
        {
            moq::Mock <SchemaService.SchemaServiceClient> mockGrpcClient = new moq::Mock <SchemaService.SchemaServiceClient>(moq::MockBehavior.Strict);
            ValidateMessageRequest request = new ValidateMessageRequest
            {
                ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                SchemaName          = SchemaName.FromProjectSchema("[PROJECT]", "[SCHEMA]"),
                Schema   = new Schema(),
                Message  = proto::ByteString.CopyFromUtf8("message0231e778"),
                Encoding = Encoding.Json,
            };
            ValidateMessageResponse expectedResponse = new ValidateMessageResponse {
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ValidateMessageResponse responseCancellationToken = await client.ValidateMessageAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }