Esempio n. 1
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 = FubuApplication.For(registry).StructureMap().RunInMemory())
            {
                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>");
                });
            }
        }
Esempio n. 2
0
 protected void Application_Start(object sender, EventArgs e)
 {
     FubuApplication
     .For <FubuExampleRegistry>()
     .StructureMapObjectFactory(x => x.AddRegistry <FubuExampleWebCoreRegistry>())
     .Bootstrap(RouteTable.Routes);
 }
        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>();
        }
Esempio n. 4
0
        public void PersistedLoginAuditor_is_registered()
        {
            var container   = new Container(new InMemoryPersistenceRegistry());
            var application = FubuApplication.For <FubuRepoWithPersistedMembership>().StructureMap(container).Bootstrap();

            application.Factory.Get <ILoginAuditor>().ShouldBeOfType <PersistedLoginAuditor>();
        }
        public void chain_is_on_the_endpoint()
        {
            var runtime  = FubuApplication.For <SomeRegistry>().StructureMap(new Container()).Bootstrap();
            var endpoint = runtime.Factory.Get <IEndpointService>().EndpointFor <SomeEndpoint>(x => x.get_hello());

            endpoint.Chain.Calls.Single().HandlerType.ShouldEqual(typeof(SomeEndpoint));
        }
Esempio n. 6
0
        public MonitoredNodeGroup()
        {
            _port = PortFinder.FindPort(5500);

            AlterSettings <KatanaSettings>(_ => {
                _.AutoHostingEnabled = true;
                _.Port = _port;
            });

            Services(_ => {
                _.ReplaceService <ISchedulePersistence, RavenDbSchedulePersistence>();
                _.ReplaceService <ISubscriptionPersistence, RavenDbSubscriptionPersistence>();
            });


            ReplaceSettings(RavenDbSettings.InMemory());

            Import <MonitoredTransportRegistry>();

            container = new Container(_ =>
            {
                _.ForSingletonOf <MonitoredNodeGroup>().Use(this);
            });

            _runtime = FubuApplication.For(this).StructureMap(container).Bootstrap();

            _runtime.Factory.Get <ChannelGraph>().Name = "Monitoring";
            _subscriptions = _runtime.Factory.Get <ISubscriptionPersistence>();
            _schedules     = _runtime.Factory.Get <ISchedulePersistence>();
            _store         = _runtime.Factory.Get <IDocumentStore>();
        }
        public void SetUp()
        {
            theContainer = new Container();
            theContainer.Configure(x =>
            {
                x.For <IHttpWriter>().Use(new NulloHttpWriter());

                x.For <ICurrentHttpRequest>().Use(new StubCurrentHttpRequest {
                    TheApplicationRoot = "http://server"
                });

                x.For <IStreamingData>().Use(MockRepository.GenerateMock <IStreamingData>());

                x.For <ICurrentChain>().Use(new CurrentChain(null, null));
            });

            theRoutes = FubuApplication.For(() => new FubuRegistry(x =>
            {
                x.Actions.IncludeType <DiagnosticController>();
                x.IncludeDiagnostics(true);
            }))
                        .StructureMap(() => theContainer)
                        .Bootstrap().Routes;

            theContainer.Configure(x => x.For <HttpContextBase>().Use(new FakeHttpContext()));
        }
Esempio n. 8
0
        public void SetUp()
        {
            registry = new FubuRegistry(x =>
            {
                x.Route("area/sub/{Name}/{Age}")
                .Calls <TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub2/prop")
                .Calls <TestController>(c => c.SomeAction(null)).OutputToJson();

                x.Route("area/sub2/{Name}/{Age}")
                .Calls <TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub2/{Name}")
                .Calls <TestController>(c => c.ThirdAction(null)).OutputToJson();

                x.Route("area/sub3/{Name}/{Age}")
                .Calls <TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub4/some_pattern")
                .Calls <TestController>(c => c.AnotherAction(null)).OutputToJson();
            });

            container = new Container();

            routes = FubuApplication.For(registry).StructureMap(container).Bootstrap().Where(r => !r.As <Route>().Url.StartsWith("_content")).ToList();

            container.Configure(x => x.For <IOutputWriter>().Use(new InMemoryOutputWriter()));
            Debug.WriteLine(container.WhatDoIHave());
        }
Esempio n. 9
0
        public FubuApplication BuildApplication()
        {
            var container = new Container(x => { x.ForSingletonOf <INumberCache>().Use <NumberCache>(); });

            return(FubuApplication.For <FubuHarnessRegistry>().StructureMap(container));
            //return FubuTransport.For<HarnessRegistry>().StructureMap(container);
        }
Esempio n. 10
0
        public void a_basic_test()
        {
            var registry = new FubuRegistry(x =>
            {
                x.HtmlConvention <DefaultHtmlConventions>();
            });
            var container = new Container();

            FubuApplication.For(registry).StructureMap(container).Bootstrap();

            var tags = container.GetInstance <TagGenerator <AddressViewModel> >();

            tags.Model = new AddressViewModel()
            {
                ShouldShow = true
            };

            var form = new SimpleForm <AddressViewModel, DefinitionListLabelAndField>(tags);

            theRenderedFormLine = form.Display(p => p.ShouldShow);

            var xx = theRenderedFormLine.Render();

            xx.ShouldContain(tags.LabelFor(x => x.ShouldShow).ToString());
            xx.ShouldContain(tags.DisplayFor(x => x.ShouldShow).ToString());
        }
Esempio n. 11
0
 protected void Application_Start(object sender, EventArgs e)
 {
     FubuApplication
     .For(() => new FubuRegistry())
     .StructureMap(new Container())
     .Bootstrap();
 }
Esempio n. 12
0
 protected void Application_Start(object sender, EventArgs e)
 {
     FubuApplication
     .For <AdnugContinuationsFubuRegistry>()
     .StructureMapObjectFactory(x => x.AddRegistry <AdnugContinuationsRegistry>())
     .Bootstrap();
 }
Esempio n. 13
0
 protected void Application_Start(object sender, EventArgs e)
 {
     FubuApplication
     .For <AspNetApplicationFubuRegistry>()
     .StructureMapObjectFactory()
     .Bootstrap();
 }
        public static void Start()
        {
            setupLoggingConfigurationWatchFile();

            // FubuApplication "guides" the bootstrapping of the FubuMVC
            // application
            FubuApplication.For <ConfigureFubuMVC>()            // ConfigureFubuMVC is the main FubuRegistry

            // for this application.  FubuRegistry classes
            // are used to register conventions, policies,
            // and various other parts of a FubuMVC application


            // FubuMVC requires an IoC container for its own internals.
            // In this case, we're using a brand new StructureMap container,
            // but FubuMVC just adds configuration to an IoC container so
            // that you can use the native registration API's for your
            // IoC container for the rest of your application
            .StructureMap(() =>
            {
                ObjectFactory.Initialize(cfg => cfg.AddRegistry <WebRegistry>());

                return(ObjectFactory.Container);
            })
            .Bootstrap();

            // Ensure that no errors occurred during bootstrapping
            PackageRegistry.AssertNoFailures();
        }
Esempio n. 15
0
        public void SetUp()
        {
            var container = new Container();

            FubuApplication.For(new FubuRegistry()).StructureMap(container).Bootstrap();
            registry = container.GetInstance <BindingRegistry>();
        }
 public void FixtureSetUp()
 {
     _host = FubuApplication
             .For <JsonSerializationFubuRegistry>()
             .StructureMap()
             .RunInMemory();
 }
        public void hydrate_through_container_facility_smoke_test()
        {
            AssetContentEndpoint.Latched = false;

            var container = new Container(x =>
            {
                x.For <IStreamingData>().Use(MockRepository.GenerateMock <IStreamingData>());
                x.For <IHttpWriter>().Use(new NulloHttpWriter());
                x.For <ICurrentChain>().Use(new CurrentChain(null, null));
                x.For <ICurrentHttpRequest>().Use(new StubCurrentHttpRequest {
                    TheApplicationRoot = "http://server"
                });

                x.For <IResourceHash>().Use(MockRepository.GenerateMock <IResourceHash>());
            });

            FubuApplication.For(() => registry).StructureMap(container).Bootstrap();

            container.Model.InstancesOf <IActionBehavior>().Count().ShouldBeGreaterThan(3);

            var behaviors = container.GetAllInstances <IActionBehavior>().ToArray();

            // The first behavior is an InputBehavior
            behaviors[1].As <BasicBehavior>().InsideBehavior.ShouldBeOfType
            <ConditionallyWrapBehaviorChainsWithTester.FakeUnitOfWorkBehavior>().Inner.
            ShouldNotBeNull();
            behaviors[2].As <BasicBehavior>().InsideBehavior.ShouldNotBeOfType
            <ConditionallyWrapBehaviorChainsWithTester.FakeUnitOfWorkBehavior>();
            behaviors[3].As <BasicBehavior>().InsideBehavior.ShouldNotBeOfType
            <ConditionallyWrapBehaviorChainsWithTester.FakeUnitOfWorkBehavior>();
        }
        public static IContainerFacilityExpression For(FubuTransportRegistry extension)
        {
            var registry = new FubuRegistry();

            extension.As <IFubuRegistryExtension>().Configure(registry);
            return(FubuApplication.For(registry));
        }
Esempio n. 19
0
        public void posts_are_committed()
        {
            var container = new Container(new RavenDbRegistry());

            container.Inject(new RavenDbSettings {
                RunInMemory = true
            });

            using (var application = FubuApplication.For <NamedEntityRegistry>().StructureMap(container).RunEmbedded())
            {
                application.Endpoints.PostJson(new NamedEntity {
                    Name = "Jeremy"
                }).StatusCode.ShouldEqual(HttpStatusCode.OK);
                application.Endpoints.PostJson(new NamedEntity {
                    Name = "Josh"
                }).StatusCode.ShouldEqual(HttpStatusCode.OK);
                application.Endpoints.PostJson(new NamedEntity {
                    Name = "Vyrak"
                }).StatusCode.ShouldEqual(HttpStatusCode.OK);

                application.Services.GetInstance <ITransaction>().Execute <IDocumentSession>(session => {
                    session.Query <NamedEntity>()
                    .Customize(x => x.WaitForNonStaleResults())
                    .Each(x => Debug.WriteLine(x.Name));
                });

                application.Endpoints.Get <FakeEntityEndpoint>(x => x.get_names()).ReadAsJson <NamesResponse>()
                .Names.ShouldHaveTheSameElementsAs("Jeremy", "Josh", "Vyrak");
            }
        }
Esempio n. 20
0
        private EmbeddedFubuMvcServer serverFor(Action <OwinSettings> action)
        {
            var registry = new FubuRegistry();

            registry.AlterSettings(action);
            return(FubuApplication.For(registry).StructureMap().RunEmbedded(port: 0));
        }
Esempio n. 21
0
 public FubuApplication BuildApplication()
 {
     return(FubuApplication
            .For <FubuTestApplicationRegistry>()
            .StructureMap(new Container())
            .Packages(x => x.Assembly(typeof(TestPackage1.JsonSerializedMessage).Assembly)));
 }
Esempio n. 22
0
 public static void Scenario <T>(Action <Scenario> configuration) where T : FubuRegistry, new()
 {
     using (var host = FubuApplication.For <T>().StructureMap().RunInMemory())
     {
         host.Scenario(configuration);
     }
 }
Esempio n. 23
0
        public void SetUp()
        {
            registry = new FubuRegistry(x => {
                x.Actions.IncludeType <TestController>();
            });



            container = new Container(x =>
            {
                x.For <ICurrentChain>().Use(new CurrentChain(null, null));
                x.For <IHttpRequest>().Use(OwinHttpRequest.ForTesting());
            });

            FubuMvcPackageFacility.PhysicalRootPath = AppDomain.CurrentDomain.BaseDirectory;

            routes = FubuApplication.For(registry)
                     .StructureMap(container)
                     .Bootstrap()
                     .Routes
                     .Where(r => !r.As <Route>().Url.StartsWith("_content"))
                     .ToList();

            container.Configure(x => x.For <IOutputWriter>().Use(new InMemoryOutputWriter()));
        }
        public void IClock_should_be_a_singleton_just_by_usage_of_the_IsSingleton_property()
        {
            var container = new Container();

            FubuApplication.For(new FubuRegistry()).StructureMap(container).Bootstrap();

            container.Model.For <IClock>().Lifecycle.ShouldBeOfType <SingletonLifecycle>();
        }
Esempio n. 25
0
        public static IContainer GetBasicFubuContainer(Action <ConfigurationExpression> containerConfiguration)
        {
            var container = new Container(containerConfiguration);

            FubuApplication.For(() => new FubuRegistry()).StructureMap(container).Bootstrap();

            return(container);
        }
Esempio n. 26
0
        public void SetUp()
        {
            _runtime  = FubuApplication.For <ApplicationRegistry>().StructureMap().Bootstrap();
            behaviors = _runtime.Factory.Get <BehaviorGraph>();

            appChain = behaviors.BehaviorFor <ApplicationActions>(x => x.get_app_action());
            pakChain = behaviors.BehaviorFor <PackageActions>(x => x.get_pak_action());
        }
Esempio n. 27
0
        public FubuApplication BuildApplication()
        {
            var registry = new FubuRegistry();

            registry.Import <LightningQueuesDiagnosticsTransportRegistry>();

            return(FubuApplication.For(registry).StructureMap());
        }
 public void should_be_applied_to_all()
 {
     using (var runtime = FubuApplication.For <AuthorizedRegistry>().StructureMap().Bootstrap())
     {
         runtime.Behaviors.BehaviorFor <FubuDiagnosticsEndpoint>(x => x.get__fubu()).Authorization.AllowedRoles().ShouldContain("admin");
         runtime.Behaviors.BehaviorFor <EndpointExplorerFubuDiagnostics>(x => x.get_endpoints()).Authorization.AllowedRoles().ShouldContain("admin");
     }
 }
Esempio n. 29
0
        protected void Application_Start(object sender, EventArgs e)
        {
            FubuApplication.For <ConfigureFubuMVC>()
            .StructureMap(new Container())
            .Bootstrap();

            PackageRegistry.AssertNoFailures();
        }
Esempio n. 30
0
        public static void Start()
        {
            FubuMvcPackageFacility.PhysicalRootPath = GetRootDirectory();

            _server =
                FubuApplication.For <HarnessRegistry>()
                .StructureMap(new Container())
                .RunEmbedded(GetRootDirectory(), PortFinder.FindPort(5500));
        }