コード例 #1
0
        public static IContainer GetBasicFubuContainer(Action <ConfigurationExpression> containerConfiguration)
        {
            var container = new Container(containerConfiguration);
            var facility  = new StructureMapContainerFacility(container);

            new FubuBootstrapper(facility, new FubuRegistry()).Bootstrap(
                new List <RouteBase>());

            return(container);
        }
コード例 #2
0
        public void SetUp()
        {
            var registry = new FubuRegistry(x => x.HtmlConvention<TestHtmlConventions>());
            var container = new Container(x => x.For<IFubuRequest>().Singleton());
            var facility = new StructureMapContainerFacility(container);
            new FubuBootstrapper(facility, registry).Bootstrap(new List<RouteBase>());
            var generator = container.GetInstance<TagGenerator<ViewModel>>();

            _page = MockRepository.GenerateMock<IFubuPage<ViewModel>>();
            _page.Expect(p => p.Model).Return(new ViewModel());
            _page.Expect(p => p.Get<TagGenerator<ViewModel>>()).Return(generator);
        }
コード例 #3
0
        public void register_a_service_by_value()
        {
            var myContainer = new Container();
            var myFacility = new StructureMapContainerFacility(myContainer);

            var registry = new UrlRegistry();

            myFacility.Register(typeof (IUrlRegistry), new ObjectDef
            {
                Value = registry
            });

            myFacility.BuildFactory();

            myContainer.GetInstance<IUrlRegistry>().ShouldBeTheSameAs(registry);
        }
コード例 #4
0
        public void SetUp()
        {
            var registry =
                new FubuRegistry(
                    x => { x.StringConversions(s => { s.ForStruct<DateTime>(d => d.ToShortDateString()); }); });

            container = new Container(x => x.For<IFubuRequest>().Singleton());
            var facility = new StructureMapContainerFacility(container);

            new FubuBootstrapper(facility, registry).Bootstrap(new List<RouteBase>());

            var request = container.GetInstance<IFubuRequest>();

            address = new Address();
            request.Set(address);

            request.Get<Address>().ShouldBeTheSameAs(address);

            generator = container.GetInstance<TagGenerator<Address>>();
        }
コード例 #5
0
        public static IContainer GetBasicFubuContainer(Action<ConfigurationExpression> containerConfiguration)
        {
            var container = new Container(containerConfiguration);
            var facility = new StructureMapContainerFacility(container);
            new FubuBootstrapper(facility, new FubuRegistry()).Bootstrap(new List<RouteBase>());

            return container;
        }
コード例 #6
0
        public void SetUp()
        {
            var registry = new FubuRegistry(x => x.HtmlConvention<TestHtmlConventions>());
            var container = new Container(x => x.For<IFubuRequest>().Singleton());
            var facility = new StructureMapContainerFacility(container);
            new FubuBootstrapper(facility, registry).Bootstrap(new List<RouteBase>());

            var generator = container.GetInstance<TagGenerator<ArbitraryModel>>();
            _page = MockRepository.GenerateMock<IFubuPage>();
            _page.Stub(p => p.Get<TagGenerator<ArbitraryModel>>()).Return(generator);
            _givenModel = new ArbitraryModel { City = "Austin" };
        }
コード例 #7
0
        public void SetUp()
        {
            container = new Container();
            graph = new FubuRegistry(x =>
            {
                x.Route<InputModel>("/area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

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

                x.Route<InputModel>("/area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();
                x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>();
            }).BuildGraph();

            facility = new StructureMapContainerFacility(container);
            graph.EachService(facility.Register);

            factory = facility.BuildFactory();
        }
コード例 #8
0
        public void should_register_an_endpoint_authorizor_if_there_are_any_authorization_rules()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<OneController>(x => x.Query(null)));
            chain.Authorization.AddRole("Role 1");
            chain.Prepend(chain.Authorization);

            var container = new Container();
            var facility = new StructureMapContainerFacility(container);

            chain.As<IRegisterable>().Register(DiagnosticLevel.None, facility.Register);

            facility.BuildFactory();

            container.GetInstance<IEndPointAuthorizor>(chain.UniqueId.ToString())
                .ShouldNotBeNull().ShouldBeOfType<EndPointAuthorizor>();
        }
コード例 #9
0
        public void should_not_register_an_endpoint_authorizor_if_there_are_no_authorization_roles()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<OneController>(x => x.Query(null)));
            //chain.Authorization.AddRole("Role 1");

            var container = new Container();
            var facility = new StructureMapContainerFacility(container);

            chain.As<IRegisterable>().Register(facility.Register);

            facility.BuildFactory(DiagnosticLevel.None);

            Debug.WriteLine(chain.UniqueId);
            Debug.WriteLine(container.WhatDoIHave());

            container.GetInstance<IEndPointAuthorizor>(chain.UniqueId.ToString())
                .ShouldBeOfType<NulloEndPointAuthorizor>();
        }
コード例 #10
0
        public void register_a_service_by_value()
        {
            var myContainer = new Container();
            var myFacility = new StructureMapContainerFacility(myContainer);

            var registry = new TypeResolver();

            myFacility.Register(typeof(ITypeResolver), new ObjectDef
            {
                Value = registry
            });

            myFacility.BuildFactory(DiagnosticLevel.None);

            myContainer.GetInstance<ITypeResolver>().ShouldBeTheSameAs(registry);
        }
コード例 #11
0
        public void SetUp()
        {
            container = new Container(x => x.For<IFileSystem>().Use<FileSystem>());

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

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

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

                x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>();

                x.Services(s => s.AddService<IActivator>(new StubActivator()));
                x.Services(s => s.AddService<IActivator>(new StubActivator()));
                x.Services(s => s.AddService<IActivator>(new StubActivator()));

            }).BuildGraph();

            facility = new StructureMapContainerFacility(container);
            graph.As<IRegisterable>().Register(facility.Register);

            factory = facility.BuildFactory(DiagnosticLevel.None);
        }
コード例 #12
0
        public void SetUp()
        {
            var registry = new FubuRegistry(x => x.HtmlConvention<TestHtmlConventions>());
            container = new Container(x => x.For<IFubuRequest>().Singleton());
            var facility = new StructureMapContainerFacility(container);

            new FubuBootstrapper(facility, registry).Bootstrap(new List<RouteBase>());

            var request = container.GetInstance<IFubuRequest>();

            address = new Address();
            request.Set(address);

            request.Get<Address>().ShouldBeTheSameAs(address);

            generator = container.GetInstance<TagGenerator<Address>>();
        }
コード例 #13
0
 public StructureMapBootstrapper(StructureMapContainerFacility facility, FubuRegistry registry)
     : base(facility, registry)
 {
     _smFacility = facility;
 }
コード例 #14
0
        public void SetUp()
        {
            container = new Container(x =>
            {
                x.For<IFileSystem>().Use<FileSystem>();
                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>());
            });

            container.Configure(x => x.For<IContainerFacility>().Use<StructureMapContainerFacility>());

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

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

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

                x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>();

                x.Services(s => s.AddService<IActivator>(new StubActivator()));
                x.Services(s => s.AddService<IActivator>(new StubActivator()));
                x.Services(s => s.AddService<IActivator>(new StubActivator()));
            });

            facility = new StructureMapContainerFacility(container);
            graph.As<IRegisterable>().Register(facility.Register);

            factory = facility.BuildFactory();
        }
コード例 #15
0
        public void SetUp()
        {
            theContainer = new Container();
            theFacility = new StructureMapContainerFacility(theContainer);

            theRequest = new InMemoryFubuRequest();

            theContainer.Inject<IFubuRequest>(theRequest);
        }
コード例 #16
0
        public void Setup()
        {
            var registry = new FubuRegistry(x =>
            {

                x.HtmlConvention<DefaultHtmlConventions>();
            });
            var container = new Container(x => x.For<IFubuRequest>().Singleton());
            var facility = new StructureMapContainerFacility(container);

            new FubuBootstrapper(facility, registry).Bootstrap(new List<RouteBase>());
            Model = new Address
            {
                Address1 = "123 Main St.",
                DateEntered = new DateTime(2010, 5, 25, 11, 30, 0),
                Order = 42
            };
            container.GetInstance<IFubuRequest>().Set(Model);

            Generator = container.GetInstance<TagGenerator<Address>>();
            Generator.Model = Model;
            Tag = createTag();
        }