public DevelopmentModeAssetTagBuilder(IAssetFinder finder, IHttpRequest request, FubuRuntime runtime) { _finder = finder; _runtime = runtime; _inner = new AssetTagBuilder(finder, request, runtime); }
public static AppFunc ToAppFunc(FubuRuntime runtime, OwinSettings settings = null) { settings = settings ?? runtime.Factory.Get<OwinSettings>(); var host = new FubuOwinHost(runtime.Routes); AppFunc inner = host.Invoke; AppFunc appFunc = settings.BuildAppFunc(inner, runtime.Factory); return appFunc; }
public static AppFunc ToAppFunc(FubuRuntime runtime, OwinSettings settings = null) { settings = settings ?? runtime.Get<OwinSettings>(); var host = new FubuOwinHost(runtime.Routes); AppFunc inner = host.Invoke; AppFunc appFunc = settings.BuildAppFunc(inner, runtime.Get<IServiceFactory>()); var diagnostics = runtime.Get<DiagnosticsSettings>(); return diagnostics.WrapAppFunc(runtime, appFunc); }
public FubuDiagnosticsEndpoint(IAssetTagBuilder tags, IHttpResponse response, IDiagnosticAssets assets, JavascriptRouteWriter routeWriter, DiagnosticJavascriptRoutes routes, IHttpRequest request, FubuRuntime runtime) { _tags = tags; _response = response; _assets = assets; _routeWriter = routeWriter; _routes = routes; _request = request; _runtime = runtime; }
public static string WriteDescription(IActivationDiagnostics diagnostics, FubuRuntime runtime) { var writer = new System.IO.StringWriter(); writeProperties(writer, runtime); writeErrors(writer, diagnostics); writeAssemblies(writer); writeLogs(writer, diagnostics); return writer.ToString(); }
public void SetUp() { FubuTransport.AllQueuesInMemory = true; container = new Container(); container.Inject(new TransportSettings { DelayMessagePolling = Int32.MaxValue, ListenerCleanupPolling = Int32.MaxValue }); theServiceBus = MockRepository.GenerateMock <IServiceBus>(); var registry = new FubuRegistry(); registry.Actions.IncludeType <MessageOnePublisher>(); theRuntime = FubuApplication.For(registry).StructureMap(container).Bootstrap(); theGraph = theRuntime.Factory.Get <BehaviorGraph>(); chain = theGraph.BehaviorFor <MessageOnePublisher>(x => x.post_message1(null)); container.Inject(theServiceBus); }
public void SetUp() { InMemoryQueueManager.ClearAll(); theSettings = new ConfiguredSettings { Upstream = "memory://foo".ToUri(), Outbound = "memory://bar".ToUri() }; theContainer = new Container(x => { x.For <ConfiguredSettings>().Use(theSettings); }); var registry = new ConfiguredFubuRegistry(); registry.StructureMap(theContainer); theRuntime = registry.ToRuntime(); theGraph = theContainer.GetInstance <ChannelGraph>(); }
public void build_application_with_persisted_membership() { using (var runtime = FubuRuntime .For <FubuRepoWithPersistedMembership>(_ => { _.Features.Authentication.Enable(true); _.Services.IncludeRegistry <InMemoryPersistenceRegistry>(); }) ) { var container = runtime.Get <IContainer>(); container.GetInstance <IMembershipRepository>() .ShouldBeOfType <MembershipRepository <FubuMVC.RavenDb.Membership.User> >(); container.GetInstance <IPasswordHash>().ShouldBeOfType <PasswordHash>(); container.GetAllInstances <IAuthenticationStrategy>() .OfType <MembershipAuthentication>() .Any(x => x.Membership is MembershipRepository <FubuMVC.RavenDb.Membership.User>).ShouldBeTrue(); } }
public IEnumerable <T> ReadFile(string fileName) { _list.Clear(); var file = FileLocation.RootPath.AppendPath(fileName); if (!File.Exists(file)) { file = FubuRuntime.DefaultApplicationPath().AppendPath("bin", fileName); } if (!File.Exists(file)) { file = FubuRuntime.DefaultApplicationPath().AppendPath("bin\\release", fileName); } using (var stream = File.OpenRead(file)) { Load(stream); } return(_list); }
public void invoking_a_chain_will_execute_completely_with_cascading_immediate_continuations_even_if_the_continuation_messages_fail() { using (var runtime = FubuRuntime.For <ChainInvokerTransportRegistry>()) { var recorder = runtime.Get <MessageRecorder>(); var invoker = runtime.Get <IChainInvoker>(); MessageHistory.WaitForWorkToFinish(() => { invoker.InvokeNow(new TriggerImmediate { Text = "First", ContinueText = "Bad message" }); }); // Should process all the cascading messages that bubble up // and their cascaded messages recorder.Messages.ShouldContain("First"); AssertCascadedMessages(recorder); } }
public void can_find_chain_for_input_type() { using (var runtime = FubuRuntime.BasicBus(x => { x.Handlers.Include <OneHandler>(); x.Handlers.Include <TwoHandler>(); x.Handlers.DisableDefaultHandlerSource(); })) { var graph = runtime.Behaviors; var invoker = new ChainInvoker(null, new ChainResolutionCache(graph), null, null, null); invoker.FindChain(new Envelope { Message = new OneMessage() }) .OfType <HandlerCall>().Single() .HandlerType.ShouldBe(typeof(OneHandler)); } }
public void send_now_is_handled_right_now() { using (var runtime = FubuRuntime.For <FubuRegistry>(x => { x.ServiceBus.Enable(true); x.ServiceBus.EnableInMemoryTransport(); x.Handlers.DisableDefaultHandlerSource(); x.Handlers.Include <SimpleHandler <OneMessage> >(); })) { var serviceBus = runtime.Get <IServiceBus>(); TestMessageRecorder.Clear(); var message = new OneMessage(); serviceBus.Consume(message); TestMessageRecorder.ProcessedFor <OneMessage>().Single().Message .ShouldBeTheSameAs(message); } }
public void create_with_html_head_injection() { var html = new HtmlTag("script").Attr("foo", "bar").ToString(); using (var runtime = FubuRuntime.Basic(_ => { _.Mode = "development"; _.AlterSettings <OwinSettings>(x => { x.AddMiddleware <HtmlHeadInjectionMiddleware>().Arguments.With(new InjectionOptions { Content = c => html }); }); })) { var settings = runtime.Get <OwinSettings>(); settings.Middleware.OfType <MiddlewareNode <HtmlHeadInjectionMiddleware> >() .Any().ShouldBeTrue(); } }
public void SetUp() { var node = new OutputNode(typeof(Address)); node.Add(new NewtonsoftJsonFormatter()); node.Add(new XmlFormatter()); node.Add(new FakeAddressWriter()); using (var runtime = FubuRuntime.Basic()) { var container = runtime.Get <IContainer>(); container.Configure(x => { // Need a stand in value x.For <IHttpRequest>().Use(MockRepository.GenerateMock <IHttpRequest>()); }); theInputBehavior = container.GetInstance <OutputBehavior <Address> >(node.As <IContainerModel>().ToInstance()); } }
public EmbeddedFubuMvcServer(FubuRuntime runtime, string physicalPath = null, int port = 5500, StartParameters parameters = null) { _runtime = runtime; parameters = parameters ?? new StartParameters(); parameters.Port = port; FubuMvcPackageFacility.PhysicalRootPath = physicalPath ?? AppDomain.CurrentDomain.BaseDirectory; //_server = WebApplication.Start<Starter>(port: port, verbosity: 1); var context = new StartContext { Parameters = parameters, }; var settings = new KatanaSettings { LoaderFactory = () => (s => builder => { var host = new FubuOwinHost(_runtime.Routes); builder.Run(host); }), }; var engine = new KatanaEngine(settings); _server = engine.Start(context); _baseAddress = "http://localhost:" + port; _urls = _runtime.Factory.Get <IUrlRegistry>(); _urls.As <UrlRegistry>().RootAt(_baseAddress); UrlContext.Stub(_baseAddress); _services = _runtime.Factory.Get <IServiceLocator>(); _endpoints = new EndpointDriver(_urls); }
public void should_move_message_to_error_queue() { using (var runtime = FubuRuntime.BasicBus(x => { x.Handlers.DisableDefaultHandlerSource(); x.Handlers.Include <OneHandler>(); x.Handlers.Include <TwoHandler>(); x.Handlers.Include <ThreeHandler>(); x.Handlers.Include <FourHandler>(); })) { Services.Inject(runtime.Behaviors); MockFor <IEnvelopeHandler>().Stub(x => x.Handle(null)).IgnoreArguments().Return(Task.FromResult <IContinuation>(null)); var envelope = ObjectMother.Envelope(); envelope.Message = new Message1(); ClassUnderTest.Invoke(envelope, new TestEnvelopeContext()).GetAwaiter().GetResult(); // we don't have a handler for this type envelope.Callback.AssertWasCalled(x => x.MoveToErrors( new ErrorReport(envelope, new NoHandlerException(typeof(Message1))))); } }
public void SetUp() { container = new Container(); container.Inject(new TransportSettings { DelayMessagePolling = Int32.MaxValue, ListenerCleanupPolling = Int32.MaxValue }); theServiceBus = MockRepository.GenerateMock <IServiceBus>(); var registry = new FubuRegistry(); registry.ServiceBus.Enable(true); registry.Actions.IncludeType <MessageOnePublisher>(); registry.StructureMap(container); registry.AlterSettings <LightningQueueSettings>(x => x.DisableIfNoChannels = true); theRuntime = registry.ToRuntime(); theGraph = theRuntime.Get <BehaviorGraph>(); chain = theGraph.ChainFor <MessageOnePublisher>(x => x.post_message1(null)); container.Inject(theServiceBus); }
public void FixtureSetUp() { fileSystem.DeleteDirectory(Folder); fileSystem.CreateDirectory(Folder); fileSystem.CreateDirectory(Folder.AppendPath(Application)); _streams.Each(x => x.DumpContents()); Thread.Sleep(100); // let the file system cool off a bit first var registry = determineRegistry(); registry.RootPath = _applicationDirectory; _host = registry.ToRuntime(); _views = new Lazy <ViewBag>(() => { return(_host.Get <ConnegSettings>().Views); }); }
public void can_write_the_javascript_routes_for_all_methods() { using (var host = FubuRuntime.Basic()) { host.Scenario(x => { x.Get.Action <JavascriptRoutesEndpoint>(e => e.get_js_router()); x.ContentShouldContain("myRoutes = {"); x.ContentShouldContain("\"m1\":{\"name\":\"m1\",\"method\":\"GET\",\"url\":\"/js/method1/{Name}\""); x.ContentShouldContain("\"m2\":{\"name\":\"m2\",\"method\":\"GET\",\"url\":\"/js/method2\"}"); x.ContentShouldContain("\"m3\":{\"name\":\"m3\",\"method\":\"POST\",\"url\":\"/js/method3\"}"); x.ContentShouldContain("\"m4\":{\"name\":\"m4\",\"method\":\"PUT\",\"url\":\"/js/method3\"}"); x.ContentShouldContain("\"m5\":{\"name\":\"m5\",\"method\":\"DELETE\",\"url\":\"/js/method3\"}"); x.StatusCodeShouldBe(HttpStatusCode.OK); }); } }
public void invoking_a_chain_will_execute_completely_with_cascading_messages() { using (var runtime = FubuRuntime.For <ChainInvokerTransportRegistry>()) { var recorder = runtime.Get <MessageRecorder>(); var invoker = runtime.Get <IChainInvoker>(); MessageHistory.WaitForWorkToFinish(() => { invoker.InvokeNow(new WebMessage { Text = "I'm good" }); }); // Should process all the cascading messages that bubble up // and their cascaded messages recorder.Messages.ShouldContain("I'm good"); recorder.Messages.ShouldContain("I'm good-2"); recorder.Messages.ShouldContain("I'm good-2-4"); recorder.Messages.ShouldContain("I'm good-2-3"); recorder.Messages.ShouldContain("Traced: I'm good"); } }
static ObjectMother() { FubuMvcPackageFacility.PhysicalRootPath = ".".ToFullPath().ParentDirectory().ParentDirectory(); var registry = new FubuRegistry(); registry.Import <FubuDocsExtension>(); FubuRuntime app = FubuApplication .For(registry) .StructureMap(new Container()) .Bootstrap(); TopicGraph = TopicGraph.AllTopics; Behaviors = app.Factory.Get <BehaviorGraph>(); ProjectRoot = TopicGraph.AllTopics.ProjectFor("FubuMVC"); Topics = new Cache <string, Topic>(); Topics[ProjectRoot.Index.Key] = ProjectRoot.Index; ProjectRoot.Index.Descendents().Each(x => Topics[x.Key] = x); Files = Topics.Select(x => x.File).ToArray(); }
public void can_swap_out_the_javascript_route_data() { using (var host = FubuRuntime.Basic(x => x.Services.For <IJavascriptRouteData>().Use <FakeJavascriptRouteData>())) { host.Scenario(x => { x.Get.Action <JavascriptRoutesEndpoint>(e => e.get_js_router()); x.ContentShouldContain("myRoutes = {"); x.ContentShouldContain( "\"m1\":{\"name\":\"m1\",\"method\":\"GET\",\"url\":\"/fake/js/method1/{Name}\""); x.ContentShouldContain("\"m2\":{\"name\":\"m2\",\"method\":\"GET\",\"url\":\"/fake/js/method2\"}"); x.ContentShouldContain("\"m3\":{\"name\":\"m3\",\"method\":\"POST\",\"url\":\"/fake/js/method3\"}"); x.StatusCodeShouldBe(HttpStatusCode.OK); }); } }
public void invoking_a_chain_will_execute_with_failure_does_not_send_off_cascading_messages() { using (var runtime = FubuRuntime.For <ChainInvokerTransportRegistry>()) { var recorder = runtime.Get <MessageRecorder>(); var invoker = runtime.Get <IChainInvoker>(); MessageHistory.WaitForWorkToFinish(() => { // The handler for WebMessage is rigged to throw exceptions // if it contains the text 'Bad' invoker.InvokeNow(new WebMessage { Text = "Bad message" }); }); // NO MESSAGES SHOULD GET OUT WITH THE ORIGINAL 'Bad Message' recorder.Messages.Any(x => x.Contains("Bad message")).ShouldBeFalse(); AssertCascadedMessages(recorder); } }
public SelfHostHttpMessageHandler(FubuRuntime runtime) { ReplaceRuntime(runtime); }
protected void Application_Start(object sender, EventArgs e) { _runtime = FubuRuntime.For <AppFubuRegistry>(); //ViewEngines.Engines.Add(new SparkViewFactory()); }
public static IFubuApplicationFiles ForDefault() { return(new FubuApplicationFiles(FubuRuntime.DefaultApplicationPath())); }
public static IFubuFile Load(string relativePath) { return(new FubuApplicationFiles(FubuRuntime.DefaultApplicationPath()).Find(relativePath)); }
public AssetTagBuilder(IAssetFinder finder, IHttpRequest request, FubuRuntime runtime) { _finder = finder; _request = request; _runtime = runtime; }
public PackageLogFubuDiagnostics(FubuRuntime runtime) { _runtime = runtime; }
public void SetUp() { runtime = FubuApplication.DefaultPolicies().StructureMap().Bootstrap(); model = runtime.Factory.Get <FubuDiagnosticsEndpoint>().get__fubu(); }
public AboutFubuDiagnostics(AppReloaded reloaded, BehaviorGraph graph, FubuRuntime runtime) { _reloaded = reloaded; _graph = graph; _runtime = runtime; }
public static void Bootstrap(FubuRegistry registry) { Runtime = registry.ToRuntime(); var settings = Runtime.Get <DiagnosticsSettings>(); if (settings.TraceLevel == TraceLevel.None) { return; } var executionLogger = Runtime.Get <IExecutionLogger>(); var logger = Runtime.Get <ILogger>(); _startRequest = () => { try { if (!HttpContext.Current.Items.Contains("owin.Environment")) { HttpContext.Current.Items.Add("owin.Environment", new Dictionary <string, object>()); } var log = new ChainExecutionLog(); HttpContext.Current.Response.AppendHeader(HttpRequestExtensions.REQUEST_ID, log.Id.ToString()); HttpContext.Current.Items.Add(AspNetServiceArguments.CHAIN_EXECUTION_LOG, log); } catch (Exception e) { try { logger.Error("Error in request logging", e); } catch (Exception exception) { Console.WriteLine(exception); Console.WriteLine(e); } } }; _endRequest = () => { try { if (!HttpContext.Current.Items.Contains(AspNetServiceArguments.CHAIN_EXECUTION_LOG)) { return; } var log = HttpContext.Current.Items[AspNetServiceArguments.CHAIN_EXECUTION_LOG].As <ChainExecutionLog>(); log.MarkFinished(); executionLogger.Record(log, new AspNetDictionary()); } catch (Exception e) { try { logger.Error("Error in request logging", e); } catch (Exception exception) { Console.WriteLine(exception); Console.WriteLine(e); } } }; }
public ApplicationUnderTest(FubuRuntime runtime, ApplicationSettings settings, IBrowserLifecycle browser) : this(settings.Name, settings.RootUrl, browser, () => runtime.Factory) { }
protected void Application_Start(object sender, EventArgs e) { _runtime = FubuApplication.BootstrapApplication <AspNetApplication>(); }
public void StartServer() { _server = FubuRuntime.Basic(); }
public void UseParallelServiceDirectory(string directory) { var path = FubuRuntime.DefaultApplicationPath(); ServiceDirectory = path.ParentDirectory().AppendPath(directory); }
private static void writeProperties(StringWriter writer, FubuRuntime runtime) { var report = new TextReport(); report.StartColumns(2); if (runtime.Restarted.HasValue) report.AddColumnData("Restarted", runtime.Restarted.ToString()); report.AddColumnData("Application Path", runtime.Files.RootPath); report.Write(writer); writer.WriteLine(); }