Ejemplo n.º 1
0
        public void StopServer_ShouldAlsoStopClient()
        {
            var done = new AutoResetEvent(false);

            //A new server is created so other tests are not affected
            var server = new SpeedDateServer();

            var client = new SpeedDateClient();

            client.Started += () => done.Set();

            server.Started += () =>
            {
                client.Start(new DefaultConfigProvider(
                                 new NetworkConfig(SetUp.MasterServerIp, SetUp.MasterServerPort + 1), //Connect to port
                                 PluginsConfig.DefaultPeerPlugins));                                  //Load peer-plugins only
            };

            server.Start(new DefaultConfigProvider(
                             new NetworkConfig("0.0.0.0", SetUp.MasterServerPort + 1), //Listen in port
                             PluginsConfig.DefaultServerPlugins)                       //Load server-plugins only
                         );

            done.WaitOne(TimeSpan.FromSeconds(30)).ShouldBeTrue();

            client.IsConnected.ShouldBeTrue();
            client.Stopped += () => done.Set();

            server.Stop();
            server.Dispose();

            done.WaitOne(TimeSpan.FromSeconds(10)).ShouldBeTrue();

            client.IsConnected.ShouldBeFalse();
        }
Ejemplo n.º 2
0
 public void OneTimeTearDown()
 {
     Server.Stop();
     Server.Dispose();
 }