public void Should_use_default_type_when_no_type_or_instance_overrides_have_been_configured() { // Given var bootstrapper = new ConfigurableBootstrapper(); bootstrapper.Initialise(); // When var engine = bootstrapper.GetEngine(); // Then engine.ShouldBeOfType<NancyEngine>(); }
public void Should_use_default_type_when_no_type_or_instance_overrides_have_been_configured() { // Given var bootstrapper = new ConfigurableBootstrapper(); bootstrapper.Initialise(); // When var engine = bootstrapper.GetEngine(); // Then engine.ShouldBeOfType <NancyEngine>(); }
public void Should_use_type_override_when_it_has_been_configured() { // Given var bootstrapper = new ConfigurableBootstrapper(with => { with.NancyEngine <FakeNancyEngine>(); }); bootstrapper.Initialise(); // When var engine = bootstrapper.GetEngine(); // Then engine.ShouldBeOfType <FakeNancyEngine>(); }
public void Should_run_request_startup_closure() { var date = new DateTime(2112, 10, 31); var bootstrapper = new ConfigurableBootstrapper( with => with.RequestStartup((container, pipelines, context) => context.Items.Add("date", date))); bootstrapper.Initialise(); var engine = bootstrapper.GetEngine(); var request = new Request("GET", "/", "http"); var result = engine.HandleRequest(request); result.Items["date"].ShouldEqual(date); }
public void Should_use_type_override_when_it_has_been_configured() { // Given var bootstrapper = new ConfigurableBootstrapper(with => { with.NancyEngine<FakeNancyEngine>(); }); bootstrapper.Initialise(); // When var engine = bootstrapper.GetEngine(); // Then engine.ShouldBeOfType<FakeNancyEngine>(); }
public void SetUp() { /* I had to tell Nancy which modules to load. You can do this by using the configurable bootstrapper, which gives you an API to configure parts of Nancy yourself. */ //Given bootstrapper = new ConfigurableBootstrapper(with => { with.Module<BlogNancy.Modules.MainModule>(); with.RootPathProvider(new TestRootPathProvider()); }); bootstrapper.Initialise(); _browser = new Browser(bootstrapper); }
public void Should_throw_exceptions_if_any_occur_in_route() { var bootstrapper = new ConfigurableBootstrapper(with => { with.Module<BlowUpModule>(); }); bootstrapper.Initialise(); var engine = bootstrapper.GetEngine(); var request = new Request("GET", "/", "http"); var result = Record.Exception(() => engine.HandleRequest(request)); result.ShouldNotBeNull(); result.ShouldBeOfType<Exception>(); result.ToString().ShouldContain("Oh noes!"); }
public void Should_throw_exceptions_if_any_occur_in_route() { var bootstrapper = new ConfigurableBootstrapper(with => { with.Module <BlowUpModule>(); }); bootstrapper.Initialise(); var engine = bootstrapper.GetEngine(); var request = new Request("GET", "/", "http"); var result = Record.Exception(() => engine.HandleRequest(request)); result.ShouldNotBeNull(); result.ShouldBeOfType <Exception>(); result.ToString().ShouldContain("Oh noes!"); }
public void Should_use_instance_override_when_it_has_been_configured() { // Given var fakeEngine = A.Fake <INancyEngine>(); var bootstrapper = new ConfigurableBootstrapper(with => { with.NancyEngine(fakeEngine); }); bootstrapper.Initialise(); // When var engine = bootstrapper.GetEngine(); // Then engine.ShouldBeSameAs(fakeEngine); }
public void Should_use_instance_override_when_it_has_been_configured() { // Given var fakeEngine = A.Fake<INancyEngine>(); var bootstrapper = new ConfigurableBootstrapper(with => { with.NancyEngine(fakeEngine); }); bootstrapper.Initialise(); // When var engine = bootstrapper.GetEngine(); // Then engine.ShouldBeSameAs(fakeEngine); }
public void Should_run_application_startup_closure() { var date = new DateTime(2112, 10, 31); var bootstrapper = new ConfigurableBootstrapper(with => with.ApplicationStartup((container, pipelines) => { pipelines.BeforeRequest += ctx => { ctx.Items.Add("date", date); return(null); }; })); bootstrapper.Initialise(); var engine = bootstrapper.GetEngine(); var request = new Request("GET", "/", "http"); var result = engine.HandleRequest(request); result.Items["date"].ShouldEqual(date); }
public void Should_run_application_startup_closure() { var date = new DateTime(2112,10,31); var bootstrapper = new ConfigurableBootstrapper(with => with.ApplicationStartup((container, pipelines) => { pipelines.BeforeRequest += ctx => { ctx.Items.Add("date", date); return null; }; })); bootstrapper.Initialise(); var engine = bootstrapper.GetEngine(); var request = new Request("GET", "/", "http"); var result = engine.HandleRequest(request); result.Items["date"].ShouldEqual(date); }