Exemplo n.º 1
0
        public void SetUp()
        {
            TagBuilder textboxes  = request => new TextboxTag().Attr("value", request.RawValue);
            TagBuilder checkboxes = request => new CheckboxTag(request.Value <bool>());

            TagModifier setName     = (def, tag) => tag.Attr("name", def.ElementId);
            TagModifier setRequired = (def, tag) => tag.AddClass("required");

            factory = new TagFactory();
            factory.AddBuilder(new LambdaElementBuilder(def => def.Is <string>(), def => textboxes));
            factory.AddBuilder(new LambdaElementBuilder(def => def.Is <bool>(), def => checkboxes));

            factory.AddModifier(new LambdaElementModifier(def => true, def => setName));
            factory.AddModifier(new LambdaElementModifier(def => def.Accessor.HasAttribute <FakeRequiredAttribute>(),
                                                          def => setRequired));

            address = new Address();
        }
Exemplo n.º 2
0
        public void merge_testing()
        {
            var secondFactory = new TagFactory();

            secondFactory.AddBuilder(new LambdaElementBuilder(def => def.Is <int>(),
                                                              def => request => new TextboxTag().AddClass("integer")));
            secondFactory.AddModifier(new LambdaElementModifier(def => true, def => (r, t) => t.AddClass("editor")));

            factory.Merge(secondFactory);

            HtmlTag tag = For(x => x.Order);

            tag.ShouldHaveClass("integer");
            tag.ShouldHaveClass("editor");
        }