public async Task Singletons_ShouldReturn_Published()
        {
            var server         = new LightweightRpcServer();
            var connectionInfo = new RpcConnectionInfo(new Uri("test://test"));
            var endPoint       = new TestDiscoveryEndPoint(connectionInfo);

            server.AddEndPoint(endPoint);

            server.PublishSingleton <ISimpleService>();
            server.PublishSingleton <ISimpleService2>();

            server.Start();
            try
            {
                var clientId = Guid.NewGuid();
                var listener = endPoint.Listeners.First();
                var response = await listener.SendReceiveDatagramAsync <RpcDiscoveryRequest, RpcPublishedSingletonsResponse>(
                    ServiceDiscoveryOperations.GetPublishedSingletons,
                    new RpcDiscoveryRequest(clientId),
                    this.serializer);

                Assert.NotNull(response);
                Assert.AreEqual(clientId, response.ClientId);
                Assert.AreEqual(2, response.Services.Length);
            }
            finally
            {
                await server.ShutdownAsync();
            }
        }
        public async Task ServerEndPoint_Should_CreateStartAndStop_Listener()
        {
            var server         = new LightweightRpcServer();
            var connectionInfo = new RpcConnectionInfo(new Uri("test://test"));
            var endPoint       = new TestDiscoveryEndPoint(connectionInfo);

            server.AddEndPoint(endPoint);

            server.Start();

            TestDiscoveryListener listener = endPoint.Listeners.FirstOrDefault();

            Assert.NotNull(listener);

            Assert.IsTrue(listener.IsListening);
            await server.ShutdownAsync();

            Assert.IsTrue(listener.IsStopped);

            server.Dispose();
            Assert.IsTrue(listener.IsDisposed);
        }
 public TestDiscoveryListener(TestDiscoveryEndPoint endPoint, IRpcConnectionHandler connectionHandler)
 {
     this.endPoint          = endPoint;
     this.connectionHandler = connectionHandler;
 }