public void DoesNotCallCloseOnListenerWhenListenerIsNull() { IHttpListener listener = null; var server = new RestServer(listener); Should.NotThrow(() => server.Dispose()); }
public void runServer(bool state) { try { if (state) { Rest = new RestServer(); Rest.Port = Settings.Default.Port; Rest.Host = Settings.Default.HostIP; if (Authentication.Enabled) { Rest.Advanced.AuthenticationSchemes = AuthenticationSchemes.Basic; } Rest.UseHttps = Settings.Default.HTTPS; Rest.Start(); setRunningStatus(); } else { Rest.Stop(); Rest.Dispose(); setStoppedStatus(); } } catch (Exception error) { DialogResult result = MessageBox.Show(error.ToString(), "Unexpected error.", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (result == DialogResult.OK) { Application.Exit(); } } }
public void CallsCloseOnListener() { var listener = Substitute.For <IHttpListener>(); listener.IsListening.Returns(false); var server = new RestServer(listener); server.Dispose(); listener.Received().Close(); }