Ejemplo n.º 1
0
        public void respond_with_httpmessage_text_message()
        {
            var url = _serverEndPoint.ToHttpUrl("/ping?format=json");
            Func <HttpResponse, bool> verifier = response => Codec.Json.From <HttpMessage.TextMessage>(response.Body) != null;

            var result = _portableServer.StartServiceAndSendRequest(HttpBootstrap.RegisterPing, url, verifier);

            Assert.IsTrue(result.Item1, result.Item2);
        }
Ejemplo n.º 2
0
        protected override void When()
        {
            Func <HttpResponse, bool> verifier = response => {
                _results = Codec.Json.From <List <MonitoringMessage.TcpConnectionStats> >(response.Body);
                return(true);
            };

            _portableServer.StartServiceAndSendRequest(y => {}, _url, verifier);
        }
Ejemplo n.º 3
0
        public void handle_invalid_characters_in_url()
        {
            var url = _serverEndPoint.ToHttpUrl("/ping^\"");
            Func <HttpResponse, bool> verifier = response => string.IsNullOrEmpty(response.Body) &&
                                                 response.HttpStatusCode == (int)HttpStatusCode.NotFound;

            var result = _portableServer.StartServiceAndSendRequest(HttpBootstrap.RegisterPing, url, verifier);

            Assert.IsTrue(result.Item1, result.Item2);
        }
Ejemplo n.º 4
0
        public void should_throw_an_exception()
        {
            var sleepFor = _timeout + 1000;
            var url      = _serverEndPoint.ToHttpUrl(EndpointExtensions.HTTP_SCHEMA,
                                                     string.Format("/test-timeout?sleepfor={0}", sleepFor));
            Func <HttpResponse, bool> verifier = response => { return(true); };
            var result = _portableServer.StartServiceAndSendRequest(url, verifier);

            Assert.IsFalse(result.Item1, "Should not have got a response");             // We should not have got a response
            Assert.That(!string.IsNullOrEmpty(result.Item2), "Error was empty");
        }
        protected override void When()
        {
            Func <HttpResponse, bool> verifier = response => {
                _results  = Codec.Json.From <List <MonitoringMessage.TcpConnectionStats> >(response.Body);
                _response = response;
                return(true);
            };

            var res = _portableServer.StartServiceAndSendRequest(y => { }, _url, verifier);

            Assert.IsEmpty(res.Item2, "Http call failed");
        }
Ejemplo n.º 6
0
        public void should_throw_an_exception()
        {
            var sleepFor = _timeout + 1000;
            var url      = _serverEndPoint.ToHttpUrl(string.Format("/test-timeout?sleepfor={0}", sleepFor));
            Func <HttpResponse, bool> verifier = response => {
                return(true);
            };
            var result = _portableServer.StartServiceAndSendRequest(service =>
                                                                    service.SetupController(new TestController(new FakePublisher())), url, verifier);

            Assert.IsFalse(result.Item1, "Should not have got a response"); // We should not have got a response
            Assert.IsNotNullOrEmpty(result.Item2, "Error was empty");
        }