internal NancyHttpHost(Uri baseUri, PactConfig config, INancyBootstrapper bootstrapper) { _baseUri = baseUri; _bootstrapper = bootstrapper; _log = LogProvider.GetLogger(config.LoggerName); _config = config; }
public WebServer(INancyBootstrapper bootstrapper) { _nancyHost = new NancyHost(new Uri("http://localhost:1234"), bootstrapper, new HostConfiguration { RewriteLocalhost = false }); }
/// <summary> /// Initializes a new instance of the <see cref="Browser"/> class. /// </summary> /// <param name="bootstrapper">A <see cref="INancyBootstrapper"/> instance that determines the Nancy configuration that should be used by the browser.</param> /// <param name="defaults">The default <see cref="BrowserContext"/> that should be used in a all requests through this browser object.</param> public Browser(INancyBootstrapper bootstrapper, Action<BrowserContext> defaults = null, bool initialiseBootstrapper = true) { this.bootstrapper = bootstrapper; if (initialiseBootstrapper) this.bootstrapper.Initialise(); this.engine = this.bootstrapper.GetEngine(); this.defaultBrowserContext = defaults ?? this.DefaultBrowserContext; }
public NancyOwinHostFixture() { this.fakeEngine = A.Fake <INancyEngine>(); this.fakeBootstrapper = A.Fake <INancyBootstrapper>(); A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine); this.host = new NancyOwinHost(fakeBootstrapper); this.fakeResponseCallback = (status, headers, bodyDelegate) => { }; this.fakeErrorCallback = (ex) => { }; this.environment = new Dictionary <string, object>() { { "owin.RequestMethod", "GET" }, { "owin.RequestPath", "/test" }, { "owin.RequestPathBase", "/root" }, { "owin.RequestQueryString", "var=value" }, { "owin.RequestHeaders", new Dictionary <string, string>() }, { "owin.RequestBody", null }, { "owin.RequestScheme", "http" }, { "owin.Version", "1.0" } }; }
/// <summary> /// Initializes a new instance of the <see cref="Browser"/> class. /// </summary> /// <param name="bootstrapper">A <see cref="INancyBootstrapper"/> instance that determines the Nancy configuration that should be used by the browser.</param> /// <param name="defaults">The default <see cref="BrowserContext"/> that should be used in a all requests through this browser object.</param> public Browser(INancyBootstrapper bootstrapper, Action <BrowserContext> defaults = null) { this.bootstrapper = bootstrapper; this.bootstrapper.Initialise(); this.engine = this.bootstrapper.GetEngine(); this.defaultBrowserContext = defaults ?? this.DefaultBrowserContext; }
public ViewBagTests() { this.bootstrapper = new ConfigurableBootstrapper( configuration => configuration.Modules(typeof(RazorTestModule))); this.browser = new Browser(bootstrapper); }
public module_tests_base() { AppDomainAssemblyTypeScanner.LoadAssemblies("*.dll"); _bootstrapper = new ConfigurableBootstrapper(config => config.ViewFactory<TestingViewFactory>()); _browser = new Browser(_bootstrapper); }
public NancyOwinHostFixture() { this.fakeEngine = A.Fake<INancyEngine>(); this.fakeBootstrapper = A.Fake<INancyBootstrapper>(); A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine); this.host = new NancyOwinHost(fakeBootstrapper); this.fakeResponseCallback = (status, headers, bodyDelegate) => { }; this.fakeErrorCallback = (ex) => { }; this.environment = new Dictionary<string, object>() { { "owin.RequestMethod", "GET" }, { "owin.RequestPath", "/test" }, { "owin.RequestPathBase", "/root" }, { "owin.RequestQueryString", "var=value" }, { "owin.RequestHeaders", new Dictionary<string, string> { { "Host", "testserver" } } }, { "owin.RequestBody", null }, { "owin.RequestScheme", "http" }, { "owin.Version", "1.0" } }; }
public NancyOwinHostFixture() { this.fakeEngine = A.Fake <INancyEngine>(); this.fakeBootstrapper = A.Fake <INancyBootstrapper>(); A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine); this.host = new NancyOwinHost(fakeBootstrapper); this.fakeResponseCallback = (status, headers, bodyDelegate) => { }; this.fakeErrorCallback = (ex) => { }; var tcs = new TaskCompletionSource <object>(); this.environment = new Dictionary <string, object>() { { "owin.RequestMethod", "GET" }, { "owin.RequestPath", "/test" }, { "owin.RequestPathBase", "/root" }, { "owin.RequestQueryString", "var=value" }, { "owin.RequestBody", Stream.Null }, { "owin.RequestHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) }, { "owin.RequestScheme", "http" }, { "owin.ResponseHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) }, { "owin.ResponseBody", Stream.Null }, { "owin.Version", "1.0" }, { "owin.CallCancelled", CancellationToken.None } }; this.requestHeaders = new Dictionary <string, string[]> { { "Host", new[] { "testserver" } } }; }
public TracingSmokeTests() { this.bootstrapper = new ConfigurableBootstrapper( configuration => configuration.Modules(new Type[] { typeof(RazorWithTracingTestModule) })); this.browser = new Browser(bootstrapper); }
public ModelBindingFixture() { this.bootstrapper = new ConfigurableBootstrapper(with => with.Modules(new[] { typeof(ModelBindingModule), typeof(MixedSourceModelBindingModule) })); this.browser = new Browser(bootstrapper); }
public module_tests_base() { AppDomainAssemblyTypeScanner.LoadAssemblies("*.dll"); _bootstrapper = new ConfigurableBootstrapper(config => config.ViewFactory <TestingViewFactory>()); _browser = new Browser(_bootstrapper); }
/// <summary> /// Initializes a new instance of the <see cref="Browser"/> class. /// </summary> /// <param name="bootstrapper">A <see cref="INancyBootstrapper"/> instance that determines the Nancy configuration that should be used by the browser.</param> /// <param name="defaults">The default <see cref="BrowserContext"/> that should be used in a all requests through this browser object.</param> public Browser(INancyBootstrapper bootstrapper, Action<BrowserContext> defaults = null) { this.bootstrapper = bootstrapper; this.bootstrapper.Initialise(); this.engine = this.bootstrapper.GetEngine(); this.defaultBrowserContext = defaults ?? DefaultBrowserContext; }
public NancyAdapter(AppFunc next, INancyBootstrapper bootstrapper) { bootstrapper.Initialise(); _next = next; _engine = bootstrapper.GetEngine(); }
internal NancyHttpHost(Uri baseUri, string providerName, PactConfig config, bool bindOnAllAdapters) { var loggerName = LogProvider.CurrentLogProvider.AddLogger(config.LogDir, providerName.ToLowerSnakeCase(), "{0}_mock_service.log"); config.LoggerName = loggerName; _baseUri = baseUri; _bootstrapper = new MockProviderNancyBootstrapper(config); _log = LogProvider.GetLogger(config.LoggerName); _config = config; _nancyConfiguration = new HostConfiguration { AllowChunkedEncoding = false }; if (bindOnAllAdapters) { _nancyConfiguration.UrlReservations = new UrlReservations { CreateAutomatically = true }; _nancyConfiguration.RewriteLocalhost = true; } else { _nancyConfiguration.RewriteLocalhost = false; } }
public PartialViewTests() { this.bootstrapper = new ConfigurableBootstrapper( configuration => configuration.Modules(new [] { typeof(RazorTestModule) })); this.browser = new Browser(bootstrapper); }
public SerializeTests() { this.bootstrapper = new ConfigurableBootstrapper( configuration => configuration.Modules(new Type[] { typeof(SerializeTestModule) })); this.browser = new Browser(bootstrapper); }
/// <summary> /// Initializes a new instance of the <see cref="Browser"/> class. /// </summary> /// <param name="bootstrapper">A <see cref="INancyBootstrapper"/> instance that determines the Nancy configuration that should be used by the browser.</param> /// <param name="defaults">The default <see cref="BrowserContext"/> that should be used in a all requests through this browser object.</param> public Browser(INancyBootstrapper bootstrapper, Action <BrowserContext> defaults = null) { bootstrapper.Initialise(); this.engine = bootstrapper.GetEngine(); this.environment = bootstrapper.GetEnvironment(); this.defaultBrowserContext = defaults ?? DefaultBrowserContext; }
public static NancyPack Use(this NancyPack pack, INancyBootstrapper bootstrapper) { Guard.AgainstNullArgument("pack", pack); pack.Boot = bootstrapper; return(pack); }
public NancyEvent2Host(string host, int port, INancyBootstrapper bootstrapper) { _host = host; _port = port; _bootstrapper = bootstrapper; _bootstrapper.Initialise(); _engine = _bootstrapper.GetEngine(); }
public NancyHost(Uri baseUri, INancyBootstrapper bootStrapper) { this.baseUri = baseUri; listener = new HttpListener(); listener.Prefixes.Add(baseUri.ToString()); engine = bootStrapper.GetEngine(); }
/// <summary> /// Initializes a new instance of the <see cref="NancyHost"/> class for the specfied <paramref name="baseUris"/>, using /// the provided <paramref name="bootstrapper"/>. /// Uses the specified configuration. /// </summary> /// <param name="bootstrapper">The bootstrapper that should be used to handle the request.</param> /// <param name="configuration">Configuration to use</param> /// <param name="baseUris">The <see cref="Uri"/>s that the host will listen to.</param> public NancyHost(INancyBootstrapper bootstrapper, HostConfiguration configuration, params Uri[] baseUris) { this.configuration = configuration ?? new HostConfiguration(); this.baseUriList = baseUris; bootstrapper.Initialise(); this.engine = bootstrapper.GetEngine(); }
#pragma warning disable S3994 // NOTE (Cameron): Represents an HTTP URL namespace and may not always be represented as a URI. public NancyWebApi(string apiUrl, INancyBootstrapper bootstrapper) { Guard.Against.Null(() => apiUrl); Guard.Against.Null(() => bootstrapper); this.apiUrl = apiUrl; this.bootstrapper = bootstrapper; }
public CustomNancyHost(INancyBootstrapper bootstrapper, HostConfiguration configuration, params Uri[] baseUris) { _bootstrapper = bootstrapper; _configuration = configuration ?? new HostConfiguration(); _baseUriList = baseUris; bootstrapper.Initialise(); _engine = bootstrapper.GetEngine(); }
public HtmlExporter(string exportPath, IConfiguration configuration, INancyBootstrapper bootStrapper) { _configuration = configuration; _exportPath = exportPath; _basePath = Directory.GetCurrentDirectory(); _bootStrapper = bootStrapper; }
public OnResponseDataTests() { bootstrapper = new ConfigurableBootstrapper(with => { with.Module<UsersModule>(); }); browser = new Browser(bootstrapper); }
public NancyEvent2Host(string host, int port, INancyBootstrapper bootstrapper, int workers) { _host = host; _port = port; _workers = workers; bootstrapper.Initialise(); _engine = bootstrapper.GetEngine(); }
public NancyHost(Uri baseUri, INancyBootstrapper bootStrapper) { this.baseUri = baseUri; listener = new HttpListener(); listener.Prefixes.Add(baseUri.ToString()); bootStrapper.Initialise(); engine = bootStrapper.GetEngine(); }
public HttpServer(ILogger<HttpServer> logger, INancyBootstrapper bootstrapper, IKeyValueStore keyValueStore) { if (logger == null) throw new ArgumentNullException("logger"); if (bootstrapper == null) throw new ArgumentNullException("bootstrapper"); if (keyValueStore == null) throw new ArgumentNullException("keyValueStore"); _logger = logger; _bootstrapper = bootstrapper; _keyValueStore = keyValueStore; }
internal NancyHttpHost(Uri baseUri, string providerName, PactConfig config) { var loggerName = LogProvider.CurrentLogProvider.AddLogger(config.LogDir, providerName.ToLowerSnakeCase(), "{0}_mock_service.log"); config.LoggerName = loggerName; _baseUri = baseUri; _bootstrapper = new MockProviderNancyBootstrapper(config); _log = LogProvider.GetLogger(config.LoggerName); _config = config; }
public JsonpTests() { this.bootstrapper = new ConfigurableBootstrapper( configuration => { configuration.Modules(new Type[] { typeof(JsonpTestModule) }); }); this.browser = new Browser(bootstrapper); }
public TopService(INancyBootstrapper ninjectNancyBootstrapper, ServiceSettings serviceSettings, Logger logger, IScheduler scheduler) { _serviceSettings = serviceSettings; _ninjectNancyBootstrapper = ninjectNancyBootstrapper; _scheduler = scheduler; _logger = logger; logger.Info("Service was created with base url {0}", serviceSettings.BaseUrl); Trace.WriteLine("Service was created with base url: "+serviceSettings.BaseUrl); }
public StaticContentTests() { this.bootstrapper = new ConfigurableBootstrapper( configuration => { configuration.Modules(new Type[] { }); }); this.browser = new Browser(bootstrapper); }
public OnRequestEmbeddedTests() { bootstrapper = new ConfigurableBootstrapper(with => { with.Module<UsersModule>(); with.Dependency<ISchemaConfiguration>(new SchemaConfiguration()); }); browser = new Browser(bootstrapper); }
public SchemaHandlerTests() { bootstrapper = new ConfigurableBootstrapper(with => { with.Module<UsersModule>(); with.Dependency<ISchemaHandler>(typeof(SchemaHandler)); }); browser = new Browser(bootstrapper); }
private void RunServer(INancyBootstrapper nancyBootstrapper, HostConfiguration hostConfiguration) { var hostAddress = new Uri(HostAddress); m_NancyHost = new NancyHost( hostAddress, nancyBootstrapper, hostConfiguration ); m_NancyHost.Start(); }
public WebServer(INancyBootstrapper webBootstrapper, IConfigManager configManager) { _webBootstrapper = webBootstrapper; _logger = Log.ForContext<WebServer>(); BindInterface = configManager.WebServerConfig.BindInterface; Port = configManager.WebServerConfig.Port; if (configManager.WebServerConfig.Enabled) Start(); }
public ManualStaticContentTests() { this.bootstrapper = new ConfigurableBootstrapper( configuration => { configuration.ApplicationStartup((c, p) => StaticContent.Enable(p)); configuration.Modules(ArrayCache.Empty<Type>()); }); this.browser = new Browser(bootstrapper); }
public ManualStaticContentTests() { this.bootstrapper = new ConfigurableBootstrapper( configuration => { configuration.ApplicationStartup((c, p) => StaticContent.Enable(p)); configuration.Modules(new Type[] { }); }); this.browser = new Browser(bootstrapper); }
/// <summary> /// /// </summary> /// <param name="nancyBootstrapper"></param> /// <param name="routeResolver"></param> /// <param name="pipeline"></param> /// <param name="cacheKeyGenerator"></param> /// <param name="cacheStore"></param> public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipeline, ICacheKeyGenerator cacheKeyGenerator, ICacheStore cacheStore) { if (_enabled) return; _enabled = true; _cacheKeyGenerator = cacheKeyGenerator; _cacheStore = cacheStore; _nancyBootstrapper = nancyBootstrapper; _routeResolver = routeResolver; pipeline.BeforeRequest.AddItemToStartOfPipeline(CheckCache); pipeline.AfterRequest.AddItemToEndOfPipeline(SetCache); }
/// <summary> /// /// </summary> /// <param name="nancyBootstrapper"></param> /// <param name="routeResolver"></param> /// <param name="pipeline"></param> /// <param name="varyParams"></param> /// <param name="cacheStore"></param> public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipeline, IEnumerable<string> varyParams, ICacheStore cacheStore) { if (_enabled) return; _enabled = true; _varyParams = varyParams.Select(key => key.ToLower().Trim()).ToArray(); _cacheStore = cacheStore; _nancyBootstrapper = nancyBootstrapper; _routeResolver = routeResolver; pipeline.BeforeRequest.AddItemToStartOfPipeline(CheckCache); pipeline.AfterRequest.AddItemToEndOfPipeline(SetCache); }
public RouteConstraintTests() { Invoked = false; this.bootstrapper = new ConfigurableBootstrapper( configuration => { configuration.ApplicationStartup((c, p) => { }); configuration.Modules(new Type[] { typeof(RouteConstraintsModule) }); configuration.RouteSegmentConstraints(new[] { typeof(UltimateRouteSegmentConstraint), typeof(VersionRouteSegmentConstraint) }); }); this.browser = new Browser(this.bootstrapper); }
public void SetUp() { applicationSettingsMock = MockRepository.GenerateStrictMock <IApplicationSettings>(); fileUploadHandlerMock = MockRepository.GenerateStrictMock <IFileUploadHandler>(); bootstrapper = new Bootstrapper( new TestBootstrapperConfiguration( new InstanceRegistration[] { new InstanceRegistration(typeof(IApplicationSettings), applicationSettingsMock), new InstanceRegistration(typeof(IFileUploadHandler), fileUploadHandlerMock) })); }
/// <summary> /// Initializes a new instance of the <see cref="NancyHost"/> class for the specfied <paramref name="baseUris"/>, using /// the provided <paramref name="bootstrapper"/>. /// </summary> /// <param name="bootstrapper">The boostrapper that should be used to handle the request.</param> /// <param name="baseUris">The <see cref="Uri"/>s that the host will listen to.</param> public NancyHost(INancyBootstrapper bootstrapper, params Uri[] baseUris) { baseUriList = baseUris; listener = new HttpListener(); foreach (var baseUri in baseUriList) { listener.Prefixes.Add(baseUri.ToString()); } bootstrapper.Initialise(); engine = bootstrapper.GetEngine(); }
public WebServer(INancyBootstrapper webBootstrapper, IConfigManager configManager) { _webBootstrapper = webBootstrapper; _logger = Log.ForContext <WebServer>(); BindInterface = configManager.WebServerConfig.BindInterface; Port = configManager.WebServerConfig.Port; if (configManager.WebServerConfig.Enabled) { Start(); } }
/// <summary> /// Initializes a new instance of the <see cref="NancyHost"/> class for the specfied <paramref name="baseUris"/>, using /// the provided <paramref name="bootstrapper"/>. /// </summary> /// <param name="bootstrapper">The boostrapper that should be used to handle the request.</param> /// <param name="baseUris">The <see cref="Uri"/>s that the host will listen to.</param> public NancyHost(INancyBootstrapper bootstrapper, params Uri[] baseUris) { baseUriList = baseUris; listener = new HttpListener(); foreach (var baseUri in baseUriList) { listener.Prefixes.Add(baseUri.ToString().Replace("localhost", "+")); } bootstrapper.Initialise(); engine = bootstrapper.GetEngine(); }
/// <summary> /// /// </summary> /// <param name="nancyBootstrapper"></param> /// <param name="routeResolver"></param> /// <param name="pipeline"></param> /// <param name="varyParams"></param> /// <param name="cacheStore"></param> public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipeline, IEnumerable <string> varyParams, ICacheStore cacheStore) { if (_enabled) { return; } _enabled = true; _varyParams = varyParams.Select(key => key.ToLower().Trim()).ToArray(); _cacheStore = cacheStore; _nancyBootstrapper = nancyBootstrapper; _routeResolver = routeResolver; pipeline.BeforeRequest.AddItemToStartOfPipeline(CheckCache); pipeline.AfterRequest.AddItemToEndOfPipeline(SetCache); }