Esempio n. 1
0
 private FluentMockServer(int port, bool ssl)
 {
     string protocol = ssl ? "https" : "http";
     _httpServer = new TinyHttpServer(protocol + "://localhost:" + port + "/", HandleRequest);
     _port = port;
     _httpServer.Start();
 }
Esempio n. 2
0
        private FluentMockServer(int port, bool ssl)
        {
            string protocol = ssl ? "https" : "http";

            _httpServer = new TinyHttpServer(protocol + "://localhost:" + port + "/", HandleRequest);
            _port       = port;
            _httpServer.Start();
        }
Esempio n. 3
0
        public string RegisterInstance(object instance)
        {
            if (_session == null)
            {
                _session = new Session(new SimpleTimer(_tickInterval), _cleanupInterval);
                _server  = new TinyHttpServer(_prefix, _session);
            }

            return(new ObjectAddress(_prefix, _session.RegisterInstance(DispatcherFactory.CreateDispatcher(instance, this, _useThreadDispatcher))).Encode());
        }
Esempio n. 4
0
 public void Should_Call_Handler_on_Request()
 {
     // given
     var port = Ports.FindFreeTcpPort();
     bool called = false;
     var urlPrefix = "http://localhost:" + port + "/";
     var server = new TinyHttpServer(urlPrefix, ctx => called = true);
     server.Start();
     // when
     var httpClient = new HttpClient();
     httpClient.GetAsync(urlPrefix).Wait(3000);
     // then
     Check.That(called).IsTrue();
 }
 /// <summary>
 /// Dirty HACK to get HttpListenerResponse instances
 /// </summary>
 public HttpListenerResponse CreateHttpListenerResponse()
 {
     var port = Ports.FindFreeTcpPort();
     var urlPrefix = "http://localhost:" + port + "/";
     var responseReady = new AutoResetEvent(false);
     HttpListenerResponse response = null;
     _server = new TinyHttpServer(urlPrefix, context =>
     {
         response = context.Response;
         responseReady.Set();
     });
     _server.Start();
     _responseMsgTask = new HttpClient().GetAsync(urlPrefix);
     responseReady.WaitOne();
     return response;
 }
Esempio n. 6
0
        public void Should_Call_Handler_on_Request()
        {
            // given
            var  port      = Ports.FindFreeTcpPort();
            bool called    = false;
            var  urlPrefix = "http://localhost:" + port + "/";
            var  server    = new TinyHttpServer(urlPrefix, ctx => called = true);

            server.Start();
            // when
            var httpClient = new HttpClient();

            httpClient.GetAsync(urlPrefix).Wait(3000);
            // then
            Check.That(called).IsTrue();
        }
Esempio n. 7
0
        /// <summary>
        /// Dirty HACK to get HttpListenerResponse instances
        /// </summary>
        public HttpListenerResponse CreateHttpListenerResponse()
        {
            var port                      = Ports.FindFreeTcpPort();
            var urlPrefix                 = "http://localhost:" + port + "/";
            var responseReady             = new AutoResetEvent(false);
            HttpListenerResponse response = null;

            _server = new TinyHttpServer(urlPrefix, context =>
            {
                response = context.Response;
                responseReady.Set();
            });
            _server.Start();
            _responseMsgTask = new HttpClient().GetAsync(urlPrefix);
            responseReady.WaitOne();
            return(response);
        }
Esempio n. 8
0
        public Endpoint(string prefix, object rootInstance, bool useThreadDispatcher, TimeSpan cleanupInterval, TimeSpan executionTimeout)
        {
            _prefix = prefix;
            _useThreadDispatcher = useThreadDispatcher;
            _cleanupInterval     = cleanupInterval;
            _tickInterval        = TimeSpan.FromMinutes(1);
            _executionTimeout    = executionTimeout;
            if (_tickInterval > _cleanupInterval)
            {
                _tickInterval = _cleanupInterval;
            }

            if (rootInstance != null)
            {
                _session = new Session(new SimpleTimer(_tickInterval), _cleanupInterval, DispatcherFactory.CreateDispatcher(rootInstance, this, useThreadDispatcher));
                _server  = new TinyHttpServer(prefix, _session);
            }
        }