Пример #1
0
        public void RegisterDuplicatedCommand_ArgumentException()
        {
            TcpAppServer server = new TcpAppServer();

            server.RegisterCommand("DummyCommand", "Dummy", null);
            Assert.Throws <ArgumentException>(() => { server.RegisterCommand("dummycommand", "Dummy", null); });
        }
Пример #2
0
 public void Setup()
 {
     Server = new TcpAppServer(null);
     Server.Start(12500);
     System.Threading.Thread.Sleep(1000);
     Client = new TcpAppClient("localhost", 12500);
 }
 public void Setup()
 {
     Server = new TcpAppServer();
     Server.Start(12500);
     System.Threading.Thread.Sleep(1000);
     Client = new TcpAppClient("127.0.0.1", 12500);
 }
Пример #4
0
        public void Setup()
        {
            Server = new TcpAppServer();
            Server.Start(25000);
            Server.ClientSignedIn   += Server_ClientSignedIn;
            Server.ClientSigningOut += Server_ClientSigningOut;
            Server.RegisterCommand("Custom_1", "Custom Command.", Custom1Callback);
            Server.RegisterQueuedCommand("Delay", "Custom Delay", (TcpAppInputCommand sender) =>
            {
                //Each connection execute command from different thread
                int delay = Convert.ToInt32(sender.Command.Parameter("duration").Value);
                //TestContext.Progress.WriteLine(sender.Command.Parameter("client").Value + " Sleep " + delay.ToString());
                Thread.Sleep(delay);
                sender.Status        = TcpAppCommandStatus.OK;
                sender.OutputMessage = "Delay Tick";
            },
                                         TcpAppParameter.CreateParameter("client", "client name"),
                                         TcpAppParameter.CreateParameter("duration", "Duration in ms"));
            Server.RegisterCommand("DelayNoQueue", "Custom Delay", (TcpAppInputCommand sender) =>
            {
                //Each connection execute command from different thread
                int delay = Convert.ToInt32(sender.Command.Parameter("duration").Value);
                //TestContext.Progress.WriteLine(sender.Command.Parameter("client").Value + " Sleep " + delay.ToString());
                Thread.Sleep(delay);
                sender.Status        = TcpAppCommandStatus.OK;
                sender.OutputMessage = "MAIN";
            },
                                   TcpAppParameter.CreateParameter("client", "client name"),
                                   TcpAppParameter.CreateParameter("duration", "Duration in ms"));
            Server.RegisterPluginType(typeof(TcpAppServerSimpleMath));


            Client = new TcpAppClient("localhost", 25000);
            Tcp    = new TcpClient("localhost", 25000);
        }
        public void RegisterDuplicatedCommand_ArgumentException()
        {
            TcpAppServer server = new TcpAppServer(null);

            server.RegisterCommand("DummyCommand", "Dummy", null);
            server.RegisterCommand("dummycommand", "Dummy", null);
        }
Пример #6
0
        public Form1()
        {
            InitializeComponent();
            Server = new TcpServer();
            Server.ServerStarted        += Server_StateChanged;
            Server.ServerStopped        += Server_StateChanged;
            Server.ClientConnected      += Server_ClientConnected;
            Server.ClientDisconnected   += Server_ClientDisconnected;
            propertyGrid1.SelectedObject = Server;

            AppServer = new TcpAppServer(this);
            AppServer.WelcomeMessage      = "Welcome to TCP Application Server. Copyright (C) Code Art Engineering.";
            AppServer.ClientConnected    += AppServer_ClientConnected;
            AppServer.ClientDisconnected += AppServer_ClientDisconnected;


            //TCP Application Server Customization Test
            AppServer.RegisterCommand("CustomFunction", "Dummy Custom Function", customFunctionCallback);
            AppServer.RegisterCommand("CustomFunction2", "Dummy Custom Function with Parameter", customFunction2Callback,
                                      new TcpAppParameter("P1", "Parameter 1"),
                                      new TcpAppParameter("P2", "Parameter 2, optional.", "10"));

            CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin SamplePlugin = new CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin();
            AppServer.RegisterPluginType("SamplePlugin", typeof(CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin));

            propertyGrid2.SelectedObject = AppServer;
        }
Пример #7
0
 public void StartServer()
 {
     using (TcpAppServer server = new TcpAppServer())
     {
         server.Start(25100);
         Assert.IsTrue(server.IsServerStarted);
     }
 }
Пример #8
0
        public void RegisterCommandWithParameterArray()
        {
            TcpAppServer server = new TcpAppServer();

            server.RegisterCommand("DummyCommand", "Dummy", null,
                                   TcpAppParameter.CreateParameter("P1", "Param 1"),
                                   TcpAppParameter.CreateParameter("P2", "Param 2"),
                                   TcpAppParameter.CreateParameterArray("PArr1", "Array Param 1", true)
                                   );
        }
Пример #9
0
        public void RegisterCommandWithParameterArray_ArrayNotLastParam_ArgumentException()
        {
            TcpAppServer server = new TcpAppServer();

            Assert.Throws <ArgumentException>(() =>
            {
                server.RegisterCommand("DummyCommand", "Dummy", null,
                                       TcpAppParameter.CreateParameter("P1", "Param 1"),
                                       TcpAppParameter.CreateParameterArray("PArr1", "Array Param 1", true),
                                       TcpAppParameter.CreateParameter("P2", "Param 2")
                                       );
            });
        }
Пример #10
0
        public Form1()
        {
            InitializeComponent();
            Server = new TcpServer();
            Server.ServerStarted        += Server_StateChanged;
            Server.ServerStopped        += Server_StateChanged;
            Server.ClientConnected      += Server_ClientConnected;
            Server.ClientDisconnected   += Server_ClientDisconnected;
            propertyGrid1.SelectedObject = Server;

            AppServer = new TcpAppServer(this);
            AppServer.WelcomeMessage      = "Welcome to TCP Application Server. Copyright (C) Code Art Engineering.";
            AppServer.ClientConnected    += AppServer_ClientConnected;
            AppServer.ClientDisconnected += AppServer_ClientDisconnected;
            propertyGrid2.SelectedObject  = AppServer;
        }
Пример #11
0
        public Form1()
        {
            InitializeComponent();
            Server                       = new TcpServer();
            Server.MaxClients            = 5;
            Server.ServerStarted        += Server_StateChanged;
            Server.ServerStopped        += Server_StateChanged;
            Server.ClientConnected      += Server_ClientConnected;
            Server.ClientDisconnected   += Server_ClientDisconnected;
            propertyGrid1.SelectedObject = Server;

            AppServer = new TcpAppServer()
            {
                WelcomeMessage = "Welcome to TCP Application Server. Copyright (C) Code Art Engineering."
            };
            AppServer.MaxClients          = 5;
            AppServer.ExecutionTimeout    = 1000;
            AppServer.ClientConnected    += AppServer_ClientConnected;
            AppServer.ClientDisconnected += AppServer_ClientDisconnected;
            AppServer.ClientSignedIn     += AppServer_ClientInitialized;
            AppServer.ClientSigningOut   += AppServer_ClientSigningOut;
            tcpClientsList1.AssignObject(AppServer);
            tcpAppServerQueue1.AssignObject(AppServer);

            //TCP Application Server Customization Test
            AppServer.RegisterCommand("CustomFunction", "Dummy Custom Function", customFunctionCallback);
            AppServer.RegisterCommand("CustomFunction2", "Dummy Custom Function with Parameter", customFunction2Callback,
                                      TcpAppParameter.CreateParameter("P1", "Parameter 1"),
                                      TcpAppParameter.CreateOptionalParameter("P2", "Parameter 2, optional.", "10"));
            AppServer.RegisterCommand("SlowCommand", "Command which take 10 seconds to complete. Simulate blocking!", SlowCommand);
            AppServer.RegisterQueuedCommand("SlowCommandQ", "Command which take 10 seconds to complete. Run in queue. Simulate blocking!", SlowCommand);

            CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin SamplePlugin = new CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin();
            AppServer.RegisterPluginType(typeof(CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin));
            AppServer.RegisterPluginType(typeof(CodeArtEng.Tcp.Tests.TcpAppServerSimpleMath));

            propertyGrid2.SelectedObject = AppServer;
        }
Пример #12
0
 public void TearDown()
 {
     Server.Dispose(); Server = null;
     Client.Dispose(); Client = null;
     Debug.WriteLine("Fixture Tear Down Completed.");
 }
 public void InitServer()
 {
     TcpAppServer server = new TcpAppServer(null);
 }