Exemple #1
0
        public void importing_test()
        {
            var b1 = new Mock <ITagBuilderPolicy>().Object;
            var b2 = new Mock <ITagBuilderPolicy>().Object;
            var b3 = new Mock <ITagBuilderPolicy>().Object;
            var b4 = new Mock <ITagBuilderPolicy>().Object;
            var b5 = new Mock <ITagBuilderPolicy>().Object;
            var b6 = new Mock <ITagBuilderPolicy>().Object;


            var lib1 = new HtmlConventionLibrary();

            lib1.TagLibrary.Add(b1);
            lib1.TagLibrary.Add(b2);

            var lib2 = new HtmlConventionLibrary();

            lib2.TagLibrary.Add(b3);
            lib2.TagLibrary.Add(b4);
            lib2.TagLibrary.Add(b5);
            lib2.TagLibrary.Add(b6);

            lib1.Import(lib2);

            lib1.TagLibrary.Default.Defaults.Policies.ShouldHaveTheSameElementsAs(b1, b2, b3, b4, b5, b6);
        }
        public void importing_test()
        {
            var b1 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >();
            var b2 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >();
            var b3 = MockRepository.GenerateMock <ITagBuilder <FakeSubject> >();
            var b4 = MockRepository.GenerateMock <ITagBuilder <SecondSubject> >();
            var b5 = MockRepository.GenerateMock <ITagBuilder <SecondSubject> >();
            var b6 = MockRepository.GenerateMock <ITagBuilder <SecondSubject> >();


            var lib1 = new HtmlConventionLibrary();

            lib1.For <FakeSubject>().Add(b1);
            lib1.For <FakeSubject>().Add(b2);

            var lib2 = new HtmlConventionLibrary();

            lib2.For <FakeSubject>().Add(b3);
            lib2.For <SecondSubject>().Add(b4);
            lib2.For <SecondSubject>().Add(b5);
            lib2.For <SecondSubject>().Add(b6);

            lib1.Import(lib2);

            lib1.For <FakeSubject>().Default.Defaults.Builders.ShouldHaveTheSameElementsAs(b1, b2, b3);
            lib1.For <SecondSubject>().Default.Defaults.Builders.ShouldHaveTheSameElementsAs(b4, b5, b6);
        }
Exemple #3
0
        public static void BuildHtmlConventionLibrary(HtmlConventionLibrary library, AccessorRules rules)
        {
            library.Import(new DefaultHtmlConventions().Library);

            var visitor = new Visitor(rules);

            library.For <ElementRequest>().AcceptVisitor(visitor);
        }
        public void services_are_not_overwritten_while_importing()
        {
            var library1 = new HtmlConventionLibrary();
            library1.RegisterService<IFoo, LittleFoo>();

            var library2 = new HtmlConventionLibrary();
            library2.RegisterService<IFoo, BigFoo>();

            library1.Import(library2);

            library1.Get<IFoo>().ShouldBeType<LittleFoo>();
        }
        public void services_are_imported()
        {
            var library1 = new HtmlConventionLibrary();
            library1.RegisterService<IFoo, LittleFoo>();

            var library2 = new HtmlConventionLibrary();
            library2.RegisterService<IFoo, BigFoo>("different");

            library1.Import(library2);

            library1.Get<IFoo>().ShouldBeType<LittleFoo>();
            library1.Get<IFoo>("different").ShouldBeType<BigFoo>();
        }
Exemple #6
0
        public void services_are_not_overwritten_while_importing()
        {
            var library1 = new HtmlConventionLibrary();

            library1.RegisterService <IFoo, LittleFoo>();

            var library2 = new HtmlConventionLibrary();

            library2.RegisterService <IFoo, BigFoo>();

            library1.Import(library2);

            library1.Get <IFoo>().ShouldBeOfType <LittleFoo>();
        }
        public AspNetMvcFubuRegistry(params HtmlConventionRegistry[] registries)
        {
            var htmlConventionLibrary = new HtmlConventionLibrary();

            registries.Select(r => r.Library).Each(library => htmlConventionLibrary.Import(library));
            htmlConventionLibrary.Import(new DefaultAspNetMvcHtmlConventions().Library);
            htmlConventionLibrary.Import(new DefaultHtmlConventions().Library);
            For <HtmlConventionLibrary>().Use(htmlConventionLibrary);

            Scan(x =>
            {
                x.AssemblyContainingType <IFubuRequest>();
                x.AssemblyContainingType <ITypeResolver>();
                x.AssemblyContainingType <ITagGeneratorFactory>();
                x.AssemblyContainingType <FubuMVC.StructureMap.StructureMapFubuRegistry>();
                x.WithDefaultConventions();
                x.LookForRegistries();
            });

            For <IValueSource>().AddInstances(c =>
            {
                c.Type <RequestPropertyValueSource>();
            });
            For <ITagRequestActivator>().AddInstances(c =>
            {
                c.Type <ElementRequestActivator>();
                c.Type <ServiceLocatorTagRequestActivator>();
            });
            For <HttpRequestBase>().Use(c => c.GetInstance <HttpRequestWrapper>());
            For <ITypeResolverStrategy>().Use <TypeResolver.DefaultStrategy>();
            //For<IElementNamingConvention>().Use<AspNetMvcElementNamingConvention>();
            For <IElementNamingConvention>().Use <DefaultElementNamingConvention>();
            For(typeof(ITagGenerator <>)).Use(typeof(TagGenerator <>));
            For(typeof(IElementGenerator <>)).Use(typeof(ElementGenerator <>));
            For <IServiceLocator>().Use(() => ServiceLocator.Current);
            For <ITemplateWriter>().Use <TemplateWriter>();
        }
Exemple #8
0
        public void services_are_imported()
        {
            var library1 = new HtmlConventionLibrary();

            library1.RegisterService <IFoo, LittleFoo>();

            var library2 = new HtmlConventionLibrary();

            library2.RegisterService <IFoo, BigFoo>("different");

            library1.Import(library2);

            library1.Get <IFoo>().ShouldBeOfType <LittleFoo>();
            library1.Get <IFoo>("different").ShouldBeOfType <BigFoo>();
        }
        public AspNetMvcFubuRegistry(params HtmlConventionRegistry[] registries)
        {
            var htmlConventionLibrary = new HtmlConventionLibrary();
            registries.Select(r => r.Library).Each(library => htmlConventionLibrary.Import(library));
            htmlConventionLibrary.Import(new DefaultAspNetMvcHtmlConventions().Library);
            htmlConventionLibrary.Import(new DefaultHtmlConventions().Library);
            For<HtmlConventionLibrary>().Use(htmlConventionLibrary);

            Scan(x =>
            {
                x.AssemblyContainingType<IFubuRequest>();
                x.AssemblyContainingType<ITypeResolver>();
                x.AssemblyContainingType<ITagGeneratorFactory>();
                x.AssemblyContainingType<FubuMVC.StructureMap.StructureMapFubuRegistry>();
                x.WithDefaultConventions();
                x.LookForRegistries();
            });

            For<IValueSource>().AddInstances(c =>
            {
                c.Type<RequestPropertyValueSource>();
            });
            For<ITagRequestActivator>().AddInstances(c =>
            {
                c.Type<ElementRequestActivator>();
                c.Type<ServiceLocatorTagRequestActivator>();
            });
            For<HttpRequestBase>().Use(c => c.GetInstance<HttpRequestWrapper>());
            For<ITypeResolverStrategy>().Use<TypeResolver.DefaultStrategy>();
            //For<IElementNamingConvention>().Use<AspNetMvcElementNamingConvention>();
            For<IElementNamingConvention>().Use<DefaultElementNamingConvention>();
            For(typeof(ITagGenerator<>)).Use(typeof(TagGenerator<>));
            For(typeof(IElementGenerator<>)).Use(typeof(ElementGenerator<>));
            For<IServiceLocator>().Use(() => ServiceLocator.Current);
            For<ITemplateWriter>().Use<TemplateWriter>();
        }
        public void importing_test()
        {
            var b1 = new Mock<ITagBuilderPolicy>().Object;
            var b2 = new Mock<ITagBuilderPolicy>().Object;
            var b3 = new Mock<ITagBuilderPolicy>().Object;
            var b4 = new Mock<ITagBuilderPolicy>().Object;
            var b5 = new Mock<ITagBuilderPolicy>().Object;
            var b6 = new Mock<ITagBuilderPolicy>().Object;


            var lib1 = new HtmlConventionLibrary();
            lib1.TagLibrary.Add(b1);
            lib1.TagLibrary.Add(b2);

            var lib2 = new HtmlConventionLibrary();
            lib2.TagLibrary.Add(b3);
            lib2.TagLibrary.Add(b4);
            lib2.TagLibrary.Add(b5);
            lib2.TagLibrary.Add(b6);

            lib1.Import(lib2);

            lib1.TagLibrary.Default.Defaults.Policies.ShouldHaveTheSameElementsAs(b1, b2, b3, b4, b5, b6);
        }
        public void importing_test()
        {
            var b1 = MockRepository.GenerateMock<ITagBuilderPolicy<FakeSubject>>();
            var b2 = MockRepository.GenerateMock<ITagBuilderPolicy<FakeSubject>>();
            var b3 = MockRepository.GenerateMock<ITagBuilderPolicy<FakeSubject>>();
            var b4 = MockRepository.GenerateMock<ITagBuilderPolicy<SecondSubject>>();
            var b5 = MockRepository.GenerateMock<ITagBuilderPolicy<SecondSubject>>();
            var b6 = MockRepository.GenerateMock<ITagBuilderPolicy<SecondSubject>>();

            var lib1 = new HtmlConventionLibrary();
            lib1.For<FakeSubject>().Add(b1);
            lib1.For<FakeSubject>().Add(b2);

            var lib2 = new HtmlConventionLibrary();
            lib2.For<FakeSubject>().Add(b3);
            lib2.For<SecondSubject>().Add(b4);
            lib2.For<SecondSubject>().Add(b5);
            lib2.For<SecondSubject>().Add(b6);

            lib1.Import(lib2);

            lib1.For<FakeSubject>().Default.Defaults.Policies.ShouldHaveTheSameElementsAs(b1, b2, b3);
            lib1.For<SecondSubject>().Default.Defaults.Policies.ShouldHaveTheSameElementsAs(b4, b5, b6);
        }
Exemple #12
0
 public void Apply(HtmlConventionLibrary library)
 {
     library.Import(Library);
 }