private static void Main(string[] args) { IsTesting = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); StartupForm startup_form = new StartupForm(); if (startup_form.ShowDialog() != DialogResult.OK) return; if (startup_form.IsServer) { MainForm form = new MainForm(); using (HttpServer server = new HttpServer(form)) { try { server.Start(startup_form.Port); } catch (SocketException) { MessageBox.Show( string.Format("The server is unable to start because port " + "{0} is already in use. Another server may " + "already be running.", startup_form.Port), "Port In Use", MessageBoxButtons.OK); return; } Application.Run(form); } } else { Application.Run(new ScoreForm(new RemoteScore(startup_form.Host, startup_form.Port))); } }
public void TestStartup() { StartupForm form = new StartupForm(); Assert.AreEqual(true, form.IsServer); Assert.AreEqual("localhost", form.Host); Assert.AreEqual(80, form.Port); Config.IsServer = false; Config.Host = "example.com"; Config.Port = 8080; form = new StartupForm(); Assert.AreEqual(false, form.IsServer); Assert.AreEqual("example.com", form.Host); Assert.AreEqual(8080, form.Port); }
private static void Main(string[] args) { IsTesting = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); StartupForm startup_form = new StartupForm(); if (startup_form.ShowDialog() != DialogResult.OK) { return; } if (startup_form.IsServer) { MainForm form = new MainForm(); using (HttpServer server = new HttpServer(form)) { try { server.Start(startup_form.Port); } catch (SocketException) { MessageBox.Show( string.Format("The server is unable to start because port " + "{0} is already in use. Another server may " + "already be running.", startup_form.Port), "Port In Use", MessageBoxButtons.OK); return; } Application.Run(form); } } else { Application.Run(new ScoreForm(new RemoteScore(startup_form.Host, startup_form.Port))); } }