public GreeterClientServiceContainer()
        {
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new Greeter.GreeterClient(channel);

            _service = new GreeterClientService(client);
        }
Example #2
0
        public async Task WillMockSayHelloAsync()
        {
            var client = new Mock <Greeter.GreeterClient>();
            // based on https://github.com/grpc/grpc/pull/15687/files#diff-1bcc0a32109704bea049ab7df4f68040R59
            var call = new Grpc.Core.AsyncUnaryCall <HelloReply>(
                Task.FromResult(new HelloReply()
            {
                Message = "Hello John Smith"
            }),
                Task.FromResult(new Metadata()),
                () => Status.DefaultSuccess,
                () => new Metadata(),
                () => { }
                );

            client.Setup(m => m.SayHelloAsync(
                             It.IsAny <HelloRequest>(), null, null, It.IsAny <CancellationToken>()))
            .Returns(call);
            var uut = new GreeterClientService(client.Object);

            var result = await uut.RequestHelloGreeting("John Smith");

            Assert.That(result, Is.EqualTo("Hello John Smith"));
        }