Ejemplo n.º 1
0
        public void reply_with_404_to_every_request()
        {
            var requests  = new[] { "/ping", "/streams", "/gossip", "/stuff", "/notfound", "/magic/url.exe" };
            var successes = new bool[requests.Length];
            var errors    = new string[requests.Length];
            var signals   = new AutoResetEvent[requests.Length];

            for (var i = 0; i < signals.Length; i++)
            {
                signals[i] = new AutoResetEvent(false);
            }

            _portableServer.Publish(new SystemMessage.SystemInit());

            for (var i = 0; i < requests.Length; i++)
            {
                var i1 = i;
                _portableServer.BuiltInClient.Get(
                    _serverEndPoint.ToHttpUrl(EndpointExtensions.HTTP_SCHEMA, requests[i]),
                    response => {
                    successes[i1] = response.HttpStatusCode == (int)HttpStatusCode.NotFound;
                    signals[i1].Set();
                },
                    exception => {
                    successes[i1] = false;
                    errors[i1]    = exception.Message;
                    signals[i1].Set();
                });
            }

            foreach (var signal in signals)
            {
                signal.WaitOne();
            }

            Assert.IsTrue(successes.All(x => x), string.Join(";", errors.Where(e => !string.IsNullOrEmpty(e))));
        }
Ejemplo n.º 2
0
 public void start_after_system_message_system_init_published()
 {
     Assert.IsFalse(_portableServer.IsListening);
     _portableServer.Publish(new SystemMessage.SystemInit());
     Assert.IsTrue(_portableServer.IsListening);
 }