コード例 #1
0
        public void Configure(FubuRegistry registry)
        {
            MimeType.New("text/jsx", ".jsx");

            registry.Services<DiagnosticServiceRegistry>();

            registry.AlterSettings<AssetSettings>(x => x.AllowableExtensions.Add(".jsx"));

            registry.AlterSettings<DiagnosticsSettings>(x =>
            {
                x.TraceLevel = TraceLevel.Verbose;
            });

            registry.Configure(graph => {
                var settings = graph.Settings.Get<DiagnosticsSettings>();

                if (settings.TraceLevel == TraceLevel.Verbose)
                {
                    graph.Services.Clear(typeof (IBindingLogger));
                    graph.Services.AddService<IBindingLogger, RecordingBindingLogger>();

                    graph.Services.Clear(typeof (IBindingHistory));
                    graph.Services.AddService<IBindingHistory, BindingHistory>();

                    graph.Services.AddService<ILogListener, RequestTraceListener>();
                }

                if (settings.TraceLevel == TraceLevel.Production)
                {
                    graph.Services.AddService<ILogListener, ProductionModeTraceListener>();
                }
            });
        }
コード例 #2
0
 public void should_start_when_transport_disabled()
 {
     var registry = new FubuRegistry();
     registry.AlterSettings<TransportSettings>(x =>
     {
         x.Enabled = true;
         x.InMemoryTransport = InMemoryTransportMode.Enabled;
     });
     registry.AlterSettings<LightningQueueSettings>(x => x.DisableIfNoChannels = true);
     using (var application = registry.ToRuntime())
     {
     }
 }
コード例 #3
0
        public void is_registered()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<CommonViewNamespaces>(x =>
            {
                x.Add("Foo");
                x.Add("Bar");
            });

            var graph = BehaviorGraph.BuildFrom(registry);
            var useNamespaces = graph.Services.DefaultServiceFor<CommonViewNamespaces>().Value.As<CommonViewNamespaces>();
            useNamespaces.Namespaces.Each(x => Debug.WriteLine(x));

            useNamespaces.Namespaces.ShouldHaveTheSameElementsAs(new[]
            {
                typeof(VirtualPathUtility).Namespace,
                typeof(string).Namespace,
                typeof(FileSet).Namespace,
                typeof(ParallelQuery).Namespace,
                typeof(HtmlTag).Namespace,
                "Foo",
                "Bar",
                "FubuMVC.Tests.Docs.Introduction.Overview",
                "FubuMVC.Tests.Http.Hosting",
            "FubuMVC.Tests.Registration",
            "FubuMVC.Core.Continuations",
            "FubuMVC.Tests.Registration.Conventions",
            "FubuMVC.Core.Resources.PathBased",
            "FubuMVC.Tests.Registration.Policies",
            "FubuMVC.Tests.Urls",

            });
        }
        public void register_with_basic_authentication_disabled()
        {
            var registry = new FubuRegistry();
            registry.Import<Saml2Extensions>();
            registry.Import<ApplyAuthentication>();

            var samlCertificateRepository = MockRepository.GenerateMock<ISamlCertificateRepository>();
            samlCertificateRepository.Stub(x => x.AllKnownCertificates()).Return(new SamlCertificate[0]);

            registry.Services(x =>
            {
                x.SetServiceIfNone<IPrincipalBuilder>(MockRepository.GenerateMock<IPrincipalBuilder>());
                x.AddService<ISamlResponseHandler>(MockRepository.GenerateMock<ISamlResponseHandler>());
                x.SetServiceIfNone<ISamlCertificateRepository>(samlCertificateRepository);
            });

            registry.AlterSettings<AuthenticationSettings>(x => {
                x.MembershipEnabled = MembershipStatus.Disabled;
            });

            var container = new Container();
            var runtime = FubuApplication.For(registry).StructureMap(container).Bootstrap();


            var strategies = container.GetAllInstances<IAuthenticationStrategy>();
            strategies.Single().ShouldBeOfType<SamlAuthenticationStrategy>();

        }
コード例 #5
0
        public void see_tracing_logs_in_verbose_mode_happy_path()
        {
            var registry = new FubuRegistry();
            registry.ServiceBus.Enable(true);
            registry.Features.Diagnostics.Enable(TraceLevel.Verbose);
            registry.ServiceBus.EnableInMemoryTransport();
            registry.AlterSettings<LightningQueueSettings>(x => x.DisableIfNoChannels = true);

            using (var runtime = registry.ToRuntime())
            {
                var bus = runtime.Get<IServiceBus>();

                bus.Consume(new TracedInput());

                var history = runtime.Get<IChainExecutionHistory>();

                var log = history.RecentReports().Single(x => x.RootChain != null && x.RootChain.InputType() == typeof(TracedInput));

                log.Request["headers"].ShouldBeOfType<Dictionary<string, string>>();
                
                log.Steps.Any().ShouldBeTrue();
                log.Steps.Any(x => x.Log is StringMessage).ShouldBeTrue();

                log.Steps.Each(x => Debug.WriteLine(x));
            }
        }
コード例 #6
0
        public void is_registered()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<CommonViewNamespaces>(x =>
            {
                x.Add("Foo");
                x.Add("Bar");
            });

            using (var runtime = registry.ToRuntime())
            {
                var container = runtime.Get<IContainer>();

                var useNamespaces = container.GetInstance<CommonViewNamespaces>();

                useNamespaces.Namespaces.ShouldContain(typeof (VirtualPathUtility).Namespace);
                useNamespaces.Namespaces.ShouldContain(typeof (string).Namespace);
                useNamespaces.Namespaces.ShouldContain(typeof (FileSet).Namespace);
                useNamespaces.Namespaces.ShouldContain(typeof (ParallelQuery).Namespace);
                useNamespaces.Namespaces.ShouldContain(typeof (HtmlTag).Namespace);
                useNamespaces.Namespaces.ShouldContain("FubuMVC.Tests.Http.Hosting");
                useNamespaces.Namespaces.ShouldContain("Foo");
                useNamespaces.Namespaces.ShouldContain("Bar");
            }
        }
コード例 #7
0
        protected virtual void configure(FubuRegistry registry)
        {
            registry.Actions.IncludeType<SampleController>();

            registry.AlterSettings<AuthenticationSettings>(
                _ => _.Strategies.AddToEnd(MembershipNode.For<InMemoryMembershipRepository>()));
        }
コード例 #8
0
        public void register_with_basic_authentication_disabled()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<AuthenticationSettings>(_ =>
            {
                _.Enabled = true;
                _.Saml2.Enabled = true;
            });

            var samlCertificateRepository = MockRepository.GenerateMock<ISamlCertificateRepository>();
            samlCertificateRepository.Stub(x => x.AllKnownCertificates()).Return(new SamlCertificate[0]);
            registry.Services.SetServiceIfNone<ISamlCertificateRepository>(samlCertificateRepository);

            registry.Services.SetServiceIfNone<IPrincipalBuilder>(MockRepository.GenerateMock<IPrincipalBuilder>());
            registry.Services.AddService<ISamlResponseHandler>(MockRepository.GenerateMock<ISamlResponseHandler>());

            registry.AlterSettings<AuthenticationSettings>(x => {
                x.MembershipEnabled = MembershipStatus.Disabled;
            });

            using (var runtime = registry.ToRuntime())
            {
                var container = runtime.Get<IContainer>();

                var strategies = container.GetAllInstances<IAuthenticationStrategy>();
                strategies.Single().ShouldBeOfType<SamlAuthenticationStrategy>();
            }
        }
コード例 #9
0
        public void Start()
        {
            _controller = _input.BuildRemoteController();
            var context = new StorytellerContext(_controller, _input);

            if (_controller.BinPath.IsEmpty())
            {
                throw new Exception("Could not determine any BinPath for the testing AppDomain. Has the Storyteller specification project been compiled, \nor is Storyteller using the wrong compilation target maybe?\n\ntype 'st.exe ? open' or st.exe ? run' to see the command usages\n\n");
            }

            context.Start();

            var registry = new FubuRegistry();


            registry.AlterSettings<DiagnosticsSettings>(_ => _.TraceLevel = TraceLevel.Verbose);
            registry.Mode = "development";
            registry.HostWith<NOWIN>();
            registry.Services.For<IRemoteController>().Use(_controller);
            registry.Services.For<StorytellerContext>().Use(context);
            
            registry.Services.IncludeRegistry<WebApplicationRegistry>();


            _server = registry.ToRuntime();
        }
コード例 #10
0
        public void can_inject_the_right_html_on_GET_for_html_text()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<OwinSettings>(x =>
            {
                x.AddMiddleware<HtmlHeadInjectionMiddleware>().Arguments.With(new InjectionOptions
                {
                    Content = e => new HtmlTag("script").Attr("foo", "bar").ToString()
                });
            });

            using (var server = registry.ToRuntime())
            {
                server.Scenario(_ =>
                {
                    _.Get.Action<SimpleHtmlEndpoint>(x => x.get_html_content());

                    _.ContentShouldContain("<script foo=\"bar\"></script></head>");
                });

                server.Scenario(_ =>
                {
                    _.Get.Action<SimpleHtmlEndpoint>(x => x.get_text_content());

                    _.ContentShouldNotContain("<script foo=\"bar\"></script></head>");
                });
            }
        }
コード例 #11
0
        public void default_namespaces_are_set_including_anything_from_CommonViewNamespaces()
        {
            var registry = new FubuRegistry();
            registry.Import<RazorViewFacility>();
            registry.AlterSettings<CommonViewNamespaces>(x =>
            {
                x.Add("Foo");
                x.Add("Bar");
            });

            var graph = BehaviorGraph.BuildFrom(registry);
            var useNamespaces = graph.Services.DefaultServiceFor<CommonViewNamespaces>().Value.As<CommonViewNamespaces>();

            useNamespaces.Namespaces.ShouldHaveTheSameElementsAs(new[]
            {
            "System.Web",
            "System",
            "FubuCore",
            "System.Linq",
            "HtmlTags",
            "FubuMVC.Core.UI",
            "FubuMVC.Core.UI.Extensions",
            "FubuMVC.Razor",
            "Foo",
            "Bar"
            });
        }
        public void do_nothing_if_tracing_is_off()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<DiagnosticsSettings>(x => x.TraceLevel = TraceLevel.None);
            registry.Configure(graph =>
            {
                chain1 = new BehaviorChain();
                chain1.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain1.AddToEnd(Wrapper.For<DifferentBehavior>());
                chain1.Route = new RouteDefinition("something");
                graph.AddChain(chain1);

                chain2 = new BehaviorChain();
                chain2.IsPartialOnly = true;
                chain2.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain2.AddToEnd(Wrapper.For<DifferentBehavior>());
                graph.AddChain(chain2);
            });


            registry.Policies.Add<ApplyTracing>();

            var notTracedGraph = BehaviorGraph.BuildFrom(registry);
            notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is DiagnosticBehavior).ShouldBeFalse();
            notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is BehaviorTracer).ShouldBeFalse();
        }
コード例 #13
0
        protected override void configure(FubuRegistry registry)
        {
            registry.Actions.IncludeType<ProfileController>();

            // I want the default to work here.
            //registry.Views.TryToAttachWithDefaultConventions();
            registry.AlterSettings<ViewAttachmentPolicy>(x => x.Profile<Mobile>("m."));
        }
コード例 #14
0
ファイル: Application.cs プロジェクト: DarthFubuMVC/fubu
        public FubuApplication BuildApplication()
        {
            //throw new NotImplementedException("You suck!");

            var registry = new FubuRegistry();
            registry.AlterSettings<ConfigurationSettings>(x => {
                x.Include<ColorSettings>();
            });

            return FubuApplication.For(registry).StructureMap(new Container());
        }
コード例 #15
0
        void IFubuRegistryExtension.Configure(FubuRegistry registry)
        {
            registry.ViewFacility(new RazorViewFacility(_templateRegistry, _parsings));
            registry.Services(configureServices);

            registry.AlterSettings<CommonViewNamespaces>(x =>
            {
                x.AddForType<RazorViewFacility>(); // FubuMVC.Razor
                x.AddForType<IPartialInvoker>(); // FubuMVC.Core.UI
            });
        }
コード例 #16
0
        public FubuApplication BuildApplication()
        {
            var registry = new FubuRegistry();
            registry.Import<DiagnosticApplication>();

            registry.AlterSettings<TransportSettings>(x => {
                x.DelayMessagePolling = Int32.MaxValue;
                x.ListenerCleanupPolling = Int32.MaxValue;
            });

            return FubuApplication.For(registry).StructureMap();
        }
コード例 #17
0
        public void Configure(FubuRegistry registry)
        {
            registry.Policies.Global.Add<ApplyJsonBindingPolicy>();

            registry.AlterSettings<ConnegSettings>(x => {
                var @default = x.FormatterFor(MimeType.Json);
                x.Formatters.Remove(@default);

                x.AddFormatter(new NewtonsoftJsonFormatter());
            });

            registry.Services<JsonServiceRegistry>();
        }
コード例 #18
0
        public void service_registrations()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<LightningQueueSettings>(_ => _.DisableIfNoChannels = true);

            using (var runtime = FubuRuntime.Basic())
            {
                var container = runtime.Get<IContainer>();

                container.ShouldHaveRegistration<ITransport, LightningQueuesTransport>();
                container.DefaultRegistrationIs<IPersistentQueues, PersistentQueues>();
            }
        }
コード例 #19
0
        public void Start()
        {
            _controller = _input.BuildRemoteController();
            var context = new StorytellerContext(_controller, _input);

            var container = new Container(new WebApplicationRegistry(_controller, context));

            context.Start();

            var registry = new FubuRegistry();
            registry.AlterSettings<DiagnosticsSettings>(_ => _.TraceLevel = TraceLevel.Verbose);

            _server = FubuApplication.For(registry).StructureMap(container).RunEmbeddedWithAutoPort();
        }
コード例 #20
0
        void IFubuRegistryExtension.Configure(FubuRegistry registry)
        {
            registry.Policies.Add<RegisterAuthenticationStrategies>();

            registry.Services<AuthenticationServiceRegistry>();
            registry.Policies.Add(new ApplyAuthenticationPolicy());
            registry.Policies.Add<FormsAuthenticationEndpointsRegistration>();
            registry.Policies.Add<AttachLoginBehaviorToLoginController>();
            registry.Policies.Add<AttachDefaultLoginView>();

            registry.AlterSettings<AuthenticationSettings>(x => {
                x.Strategies.AddToEnd<MembershipNode>();
            });
        }
コード例 #21
0
        public void application_settings_wins()
        {
            var import = new FubuRegistry();
            import.AlterSettings<FireflySettings>(o=> o.HowManyHaveYouCaught = 5);

            var graph = BehaviorGraph.BuildFrom(x => {
                x.AlterSettings<FireflySettings>(o => o.HowManyHaveYouCaught =11);

                x.Import(import, string.Empty);
            });

            graph.Settings.Get<FireflySettings>()
                .HowManyHaveYouCaught.ShouldEqual(11);
        }
コード例 #22
0
        public void run_in_none_mode()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<DiagnosticsSettings>(x => x.TraceLevel = TraceLevel.None);

            using (var server = FubuApplication.For(registry).StructureMap().RunEmbedded(@"c:\code\FubuMVC.Diagnostics\src\FubuMVC.Diagnostics"))
            {
                server.Endpoints.PostAsForm(new Input { Name = "Jeremy", Age = 39, Direction = "North" })
                    .StatusCode.ShouldEqual(HttpStatusCode.OK);

                Process.Start(server.BaseAddress + "/_fubu");

                Thread.Sleep(60000);
            }
        }
コード例 #23
0
        public void Configure(FubuRegistry registry)
        {
            registry.Policies.Add<TopicUrlPolicy>();

            registry.AlterSettings<CommonViewNamespaces>(x =>
            {
                x.AddForType<FubuWorldRegistry>();
            });

            registry.Services(x =>
            {
                x.AddService<IPropertyBinder, RequestLogPropertyBinder>();
                x.AddService<IActivator, TopicGraphActivator>();
            });
        }
コード例 #24
0
ファイル: ViewExclusionTester.cs プロジェクト: swcomp/fubumvc
        public void do_not_use_the_excluded_views()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<ViewEngines>(x => {
                x.AddFacility(new FakeViewEngine1());
                x.AddFacility(new FakeViewEngine2());

                x.ExcludeViews(v => v.Name().StartsWith("A"));
                x.ExcludeViews(v => v.Name().StartsWith("C"));
            });

            var settings = BehaviorGraph.BuildFrom(registry).Settings;
            var views = settings.Get<ViewEngines>().BuildViewBag(settings);

            views.Result.Views.OrderBy(x => x.Name()).Select(x => x.Name())
                .ShouldHaveTheSameElementsAs("B1", "B2", "B3", "B4", "B5", "B6");
        }
コード例 #25
0
        public void Initialize(Type applicationType, StartApplication message)
        {
            _registry = Activator.CreateInstance(applicationType).As<FubuRegistry>();
            _registry.RootPath = message.PhysicalPath;
            _registry.Port = PortFinder.FindPort(message.PortNumber);
            _registry.Mode = message.Mode;

            _registry.AlterSettings<OwinSettings>(owin =>
            {
                owin.AddMiddleware<HtmlHeadInjectionMiddleware>().Arguments.With(new InjectionOptions
                {
                    Content = c => message.HtmlHeadInjectedText
                });
            });

            if (_registry.Host == null) _registry.HostWith<Katana>();

            StartUp();
        }
コード例 #26
0
        public void public_folder_only()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<AssetSettings>(x =>
            {
                x.Mode = SearchMode.PublicFolderOnly;
                x.Version = null;
            });

            using (var runtime = registry.ToRuntime())
            {
                runtime.Scenario(_ =>
                {
                    _.Get.Action<PublicAssetFolderEndpoint>(x => x.get_public_asset_folder());

                    _.ContentShouldContain("*/public*");
                });
            }
        }
コード例 #27
0
        public void is_registered()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<CommonViewNamespaces>(x =>
            {
                x.Add("Foo");
                x.Add("Bar");
            });

            var graph = BehaviorGraph.BuildFrom(registry);
            var useNamespaces = graph.Services.DefaultServiceFor<CommonViewNamespaces>().Value.As<CommonViewNamespaces>();

            useNamespaces.Namespaces.ShouldContain(typeof(VirtualPathUtility).Namespace);
            useNamespaces.Namespaces.ShouldContain(typeof(string).Namespace);
            useNamespaces.Namespaces.ShouldContain(typeof(FileSet).Namespace);
            useNamespaces.Namespaces.ShouldContain(typeof(ParallelQuery).Namespace);
            useNamespaces.Namespaces.ShouldContain(typeof(HtmlTag).Namespace);
            useNamespaces.Namespaces.ShouldContain("FubuMVC.Tests.Http.Hosting");
            useNamespaces.Namespaces.ShouldContain("Foo");
            useNamespaces.Namespaces.ShouldContain("Bar");
        }
コード例 #28
0
        public void blows_up_with_no_saml_certificate_repository()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<AuthenticationSettings>(_ =>
            {
                _.Enabled = true;
                _.Saml2.Enabled = true;
            });

            var samlCertificateRepository = MockRepository.GenerateMock<ISamlCertificateRepository>();
            samlCertificateRepository.Stub(r => r.AllKnownCertificates())
                                     .Return(new SamlCertificate[0]);

            registry.Services.SetServiceIfNone<IPrincipalBuilder>(MockRepository.GenerateMock<IPrincipalBuilder>());
            registry.Services.AddService<ISamlResponseHandler>(MockRepository.GenerateMock<ISamlResponseHandler>());
            //registry.Services.SetServiceIfNone<ISamlCertificateRepository>(samlCertificateRepository);

            Exception<StructureMapConfigurationException>.ShouldBeThrownBy(() => {
                                                                registry.ToRuntime();
            });
        }
コード例 #29
0
        void IFubuRegistryExtension.Configure(FubuRegistry registry)
        {
            registry.Services<FubuValidationServiceRegistry>();
            registry.Services<FubuMvcValidationServices>();
            registry.Actions.FindWith<RemoteRulesSource>();
            registry.Actions.FindWith<ValidationSummarySource>();
	        registry.Actions.FindWith<ValidationDiagnosticsSource>();

            registry.Import<HtmlConventionRegistry>(x =>
            {
                x.Editors.Add(new FieldValidationElementModifier());
                x.Editors.Add(new RemoteValidationElementModifier());
                x.Editors.Add(new DateElementModifier());
                x.Editors.Add(new NumberElementModifier());
                x.Editors.Add(new MaximumLengthModifier());
                x.Editors.Add(new MinimumLengthModifier());
                x.Editors.Add(new RangeLengthModifier());
                x.Editors.Add(new MinValueModifier());
                x.Editors.Add(new MaxValueModifier());
                x.Editors.Add(new LocalizationLabelModifier());
				x.Editors.Add(new RegularExpressionModifier());
                
                x.Forms.Add(new FormValidationSummaryModifier());
                x.Forms.Add(new FormValidationModifier());
				x.Forms.Add(new FieldEqualityFormModifier());
				x.Forms.Add(new NotificationSerializationModifier());
            });

            registry.Policies.Add<ValidationConvention>();
            registry.Policies.Add<AttachDefaultValidationSummary>();
            registry.Policies.Add<RegisterRemoteRuleQuery>();

            registry.AlterSettings<ValidationSettings>(settings =>
            {
                settings
                    .Remotes
                    .FindWith<RemoteRuleAttributeFilter>()
                    .FindWith<RemoteFieldValidationRuleFilter>();
            });
        }
コード例 #30
0
        public void see_tracing_logs_in_production_mode_happy_path()
        {
            var registry = new FubuRegistry();
            registry.ServiceBus.Enable(true);
            registry.Features.Diagnostics.Enable(TraceLevel.Production);
            registry.ServiceBus.EnableInMemoryTransport();
            registry.AlterSettings<LightningQueueSettings>(x => x.DisableIfNoChannels = true);

            using (var runtime = registry.ToRuntime())
            {
                var bus = runtime.Get<IServiceBus>();

                bus.Consume(new TracedInput());

                var history = runtime.Get<IChainExecutionHistory>();

                var log = history.RecentReports().Single(x => x.RootChain != null && x.RootChain.InputType() == typeof(TracedInput));

                log.Steps.Any(x => x.Log is StringMessage).ShouldBeFalse();

            }
        }