public async Task <IActionResult> InvokeGrpcHello(string name)
        {
            var result = await _client.SayHelloAsync(new Greet.HelloRequest
            {
                Name = name
            });

            return(Ok(result.Message));
        }
Пример #2
0
        public override async Task <HelloReply> SayHello(HelloRequest request, ServerCallContext context)
        {
            var reply = await _greeterClient.SayHelloAsync(new Greet.HelloRequest {
                Name = "Nested: " + request.Name
            });

            return(new HelloReply {
                Message = reply.Message
            });
        }
Пример #3
0
        public async Task Dispose_StartCallOnClient_ThrowError()
        {
            // Arrange
            var channel = GrpcChannel.ForAddress("https://localhost", CreateGrpcChannelOptions());
            var client  = new Greet.Greeter.GreeterClient(channel);

            // Act
            channel.Dispose();

            // Assert
            await ExceptionAssert.ThrowsAsync <ObjectDisposedException>(() => client.SayHelloAsync(new Greet.HelloRequest()).ResponseAsync);
        }
Пример #4
0
        public async Task GreeterSayHelloTest()
        {
            var request = new Greet.HelloRequest
            {
                Name = "YIM",
            };

            using var channel = GrpcChannel.ForAddress(LocalHttpsHost);
            var client     = new Greet.Greeter.GreeterClient(channel);
            var helloReply = await client.SayHelloAsync(request);

            Assert.Equal("Hello " + request.Name, helloReply.Message);
        }
Пример #5
0
        public async Task UnsafeGrpcTest()
        {
            //Given
            var request = new Greet.HelloRequest
            {
                Name = "YIM",
            };

            //When
            using var channel = GrpcChannel.ForAddress(LocalHttpHost);
            var client     = new Greet.Greeter.GreeterClient(channel);
            var helloReply = await client.SayHelloAsync(request);

            //Then
            Assert.Equal("Hello " + request.Name, helloReply.Message);
        }