Example #1
0
            public void ThrowsExceptionWhenExceptionOccursWhileStopping()
            {
                var listener = Substitute.For <IHttpListener>();

                listener.When(_ => _.Stop()).Do(_ => { throw new Exception(); });
                listener.IsListening.Returns(true);

                using (var server = new RestServer(listener))
                {
                    Should.Throw <UnableToStopHostException>(() => server.Stop());
                    server.GetIsStopping().ShouldBeFalse();
                    listener.IsListening.Returns(false);
                }
            }