Exemplo n.º 1
0
            public void DoesNotCallCloseOnListenerWhenListenerIsNull()
            {
                IHttpListener listener = null;
                var           server   = new RestServer(listener);

                Should.NotThrow(() => server.Dispose());
            }
Exemplo n.º 2
0
        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();
                }
            }
        }
Exemplo n.º 3
0
            public void CallsCloseOnListener()
            {
                var listener = Substitute.For <IHttpListener>();

                listener.IsListening.Returns(false);
                var server = new RestServer(listener);

                server.Dispose();

                listener.Received().Close();
            }