/// ----------------------------------------------------------------------------- /// <summary> /// Initialise les différents serveurs pour le test /// </summary> /// <typeparam name="T">le protocole à utiliser</typeparam> /// <param name="port">le port de base pour le remoting</param> /// <param name="server">le serveur (tunnel)</param> /// <param name="client">le client (tunnel)</param> /// <param name="echo">le serveur d'echo</param> /// <param name="gw">la passerelle</param> /// ----------------------------------------------------------------------------- private void Initialize <T>(int port, out BdtServer server, out BdtClient client, out EchoServer echo, out GatewayServer gw) where T : GenericProtocol { Assert.AreEqual(ChannelServices.RegisteredChannels.Length, 0); var config = new TestConfigPackage(typeof(T).FullName, port); server = new TestServer(TestContext, config); client = new TestClient(TestContext, config); var args = new String[] { }; server.LoadConfiguration(args); client.LoadConfiguration(args); Tunnel.Configuration = server.Configuration; Tunnel.Logger = LoggedObject.GlobalLogger; server.Protocol.ConfigureServer(typeof(Tunnel)); client.StartClient(); Assert.AreEqual(ChannelServices.RegisteredChannels.Length, 2); echo = new EchoServer(port + EchoOffset, false); Servers.Add(echo); gw = new GatewayServer(port + GatewayOffset, false, port + EchoOffset, "localhost", client.Tunnel, client.Sid); Servers.Add(gw); }
/// ----------------------------------------------------------------------------- /// <summary> /// Destruction des entités de test /// </summary> /// <param name="server">le serveur (tunnel)</param> /// <param name="client">le client (tunnel)</param> /// <param name="echo">le serveur d'echo</param> /// <param name="gw">la passerelle</param> /// ----------------------------------------------------------------------------- private void Finalize(ref BdtServer server, ref BdtClient client, ref EchoServer echo, ref GatewayServer gw) { Assert.AreEqual(ChannelServices.RegisteredChannels.Length, 2); client.StopClient(); Tunnel.DisableChecking(); server.Protocol.UnConfigureServer(); server.UnLoadConfiguration(); client.UnLoadConfiguration(); server = null; client = null; Assert.AreEqual(ChannelServices.RegisteredChannels.Length, 0); echo.CloseServer(); Servers.Remove(echo); echo = null; gw.CloseServer(); Servers.Remove(gw); gw = null; }