private Boolean ExecuteStartState(ref ITcpServer server, Object[] args) { const String serverStartFormat = "=================> Server was started on {0} : {1}"; Boolean result; if (args.Length >= 2 && (args[0] != null && args[1] != null)) { String ipAddress = args[0] as String; if (!String.IsNullOrEmpty(ipAddress)) { _ipAddress = ipAddress; } UInt16 port = Convert.ToUInt16(args[1]); _port = port; String settingsFile = args[2] as String; String scriptFile = args[3] as String; if (!String.IsNullOrEmpty(scriptFile)) { _scriptFile = scriptFile; } String compilerOptionFile = args[4] as String; CompilerOptions compilerOptions = compilerOptionFile != null?CompilerOptionsBuilder.Build(compilerOptionFile) : null; TcpServerConfig config = settingsFile != null?TcpServerConfigBuilder.Build(settingsFile) : null; if (compilerOptions != null) { _compilerOptions = compilerOptions; } if (config != null) { _config = config; } if (server == null || scriptFile != null || compilerOptionFile != null) { //System.Console.WriteLine("tcp server re-creation...."); server = new FlexibleTcpServer(_scriptFile, _ipAddress, _port, _compilerOptions, _logger, false, _config); } result = server.Start(_ipAddress, _port); if (result) { System.Console.WriteLine(serverStartFormat, _ipAddress, _port); } _currentState = result ? MachineState.Started : _currentState; return(result); } server = new FlexibleTcpServer(_scriptFile, _ipAddress, _port, _compilerOptions, _logger, false, _config); result = server.Start(); if (result) { System.Console.WriteLine("=================> Server was started"); } _currentState = result ? MachineState.Started : _currentState; return(result); }
public void TestRestart() { CompilerOptions compilerOptions = new CompilerOptions(); compilerOptions.Provider = new CSharpCodeProvider(new Dictionary <String, String>() { { "CompilerVersion", "v4.0" } }); compilerOptions.Parameters.GenerateExecutable = false; compilerOptions.Parameters.GenerateInMemory = true; compilerOptions.ScriptEntryType = "MossbauerLab.TinyTcpServer.Core.FunctionalTests.TestScripts.CustomScript"; // CustomScript, LocalIpAddress, ServerPort, compilerOptions _server = new FlexibleTcpServer(CustomScript, LocalIpAddress, ServerPort, compilerOptions); Boolean result = _server.Start(); Assert.IsTrue(result, "Checking that result is true"); _server.Stop(true); result = _server.Start(); Assert.IsTrue(result, "Checking that result is true"); _server.Stop(true); }
public void TestScriptRun(Int32 dataSize, Int32 repetition, Boolean isClientAsync) { _server = new FlexibleTcpServer(Script, LocalIpAddress, ServerPort); Boolean result = _server.Start(); Assert.IsTrue(result, "Checking that result is true"); using (TransportClient client = new TransportClient(isClientAsync, LocalIpAddress, ServerPort)) { client.Open(); ExchangeWithRandomDataAndCheck(client, dataSize, repetition); client.Close(); } Assert.DoesNotThrow(() => _server.Stop(true), "Checking that server correctly stops"); }
private void TestScriptRunImpl(Int32 dataSize, Int32 repetition, Boolean isClientAsync, String script, String ipAddress, UInt16 port, CompilerOptions options) { _server = new FlexibleTcpServer(script, ipAddress, port, options); Boolean result = _server.Start(); Assert.IsTrue(result, "Checking that result is true"); using (TransportClient client = new TransportClient(isClientAsync, ipAddress, port)) { client.Open(); ExchangeWithRandomDataAndCheck(client, dataSize, repetition); client.Close(); } Assert.DoesNotThrow(() => _server.Stop(true), "Checking that server correctly stops"); }