public void RpcTest() { TcpRpcServer server = new TcpRpcServer(new EchoServer()); server.Start(); CertificateStorage storage = new CertificateStorage(); TcpRpcClient client = new TcpRpcClient(); client.Connect(new IPEndPoint(IPAddress.Loopback, 4242)); Assert.IsTrue(client.Connected); var request = new EchoRequest(Guid.NewGuid(), "hello"); var responseData = client.Execute(request.ToBinary()); var response = Serializable.FromBinary<EchoResponse>(responseData); Assert.AreEqual(request.RequestId, response.RequestId); Assert.AreEqual("hello", response.Message); client.Disconnect(); Assert.IsFalse(client.Connected); server.Stop(); }
public void VotingServerTest() { TcpRpcServer server = new TcpRpcServer(new VotingRpcServer()); server.Start(); CertificateStorage storage = new CertificateStorage(); TcpRpcClient client = new TcpRpcClient(); client.Connect(new IPEndPoint(IPAddress.Loopback, 4242)); Assert.IsTrue(client.Connected); VotingRpcProxy proxy = new VotingRpcProxy(client); proxy.Start(); var ids = proxy.FetchVotingIds(); proxy.Stop(); client.Disconnect(); Assert.IsFalse(client.Connected); server.Stop(); }