Esempio n. 1
0
        public void GetPersonById_Success(int id, string name)
        {
            //Arrange
            PersonName_Reply reply = null;

            //Act
            if (channel == null)
            {
                channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
                client  = new Greeter.GreeterClient(channel);
            }
            try
            {
                reply = client.GetPersonById(new PersonId_Request {
                    Id = id
                });
                Console.WriteLine($"Reply:\n{reply}");
            }
            catch (Grpc.Core.RpcException ex)
            {
                Console.WriteLine($"ERROR:\n{ex.Message}\n\nNot connected to service.");
            }

            //Assert
            if (reply.Name != name)
            {
                Assert.AreEqual(reply.Error, "ERROR: There is no person with that id.");
            }
            else
            {
                Assert.AreEqual(reply.Name, name);
            }
        }