public exception_with_logging_from_http_listener_host() { _fakeLogger = new FakeLogger(); _httpListener = new TestHttpListener(new Configuration(_fakeLogger)); try { _httpListener.WebGet("/"); } catch (WebException e) { _response = (HttpWebResponse)e.Response; } }
public exception_with_logging_in_memory_host() { _fakeLogger = new FakeLogger(); var server = new InMemoryHost(() => { ResourceSpace.Uses.Resolver.AddDependencyInstance( typeof(ILogger), _fakeLogger, DependencyLifetime.Singleton); ResourceSpace.Has.ResourcesNamed("root") .AtUri("/") .HandledBy <ThrowingHandler>().TranscodedBy <TextPlainCodec>(); }); _response = server.Get(server.ApplicationVirtualPath).Result; }
public exception_with_logging_from_http_listener_host() { _fakeLogger = new FakeLogger(); var appPathVDir = $"Temporary_Listen_Addresses/{Guid.NewGuid()}/"; var started = false; int port = -1; do { try { port = _random.Next(2048, 4096); _httpListenerHost = new HttpListenerHost(new Configuration(_fakeLogger)); _httpListenerHost.Initialize(new[] { $"http://+:{port}/{appPathVDir}" }, appPathVDir, null); _httpListenerHost.StartListening(); started = true; } catch { } } while (!started); using (var webClient = new WebClient()) { try { webClient.DownloadString($"http://localhost:{port}/{appPathVDir}"); } catch (WebException e) { _response = (HttpWebResponse)e.Response; } } }
public Configuration(FakeLogger fakeLogger) { _fakeLogger = fakeLogger; }