Esempio n. 1
0
        public void SetUp()
        {
            selfHost = new NancySelfHost(new RecordingBootstrapper());
            selfHost.Start();

            // setup processiong time on TestModule
            var configurationClient = new HttpClient()
            {
                BaseAddress = new Uri("http://localhost:9999")
            };
            var configurationResponse = configurationClient.PostAsync("configure?processing-time=1000", new StringContent("")).Result;

            httpClient = new HttpClient(new TimeoutingDelegatingHandler(TimeSpan.FromMilliseconds(500), new HttpClientHandler()))
            {
                BaseAddress = new Uri("http://localhost:9999")
            };

            try
            {
                var response1 = httpClient.GetAsync("timeout-for-the-first").Result;
            }
            catch (Exception ex)
            {
                httpClientException = ex;
            }

            response2 = httpClient.GetAsync("timeout-for-the-first").Result;
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private bool StartServer()
        {
            try
            {
                Print("Server is starting..");

                var port = int.Parse(ConfigurationManager.AppSettings["port"]);

                NancySelfHost.Start(port);

                Print($"Server started successfully");

                Print($"Listening on http://localhost:{port}");

                return(true);
            }
            catch (Exception e)
            {
                Print(e.Message);

                Logger.Log(e);

                return(false);
            }
        }
Esempio n. 3
0
 public void SetUp()
 {
     apiHost.Start();
 }