Inheritance: GrammarModel
Esempio n. 1
0
        public override GrammarModel ApplyOverrides(GrammarModel grammar)
        {
            var table = new Table {key = key, hasAfterStep = hasAfterStep, hasBeforeStep = hasBeforeStep};

            var over = grammar as Table;
            if (over == null)
            {
                table.title = title;
                table.collection = collection;
                table.cells = cells?.Select(c => c.ApplyOverrides(null)).ToArray();

                return table;
            }

            table.title = over.title.IsNotEmpty() ? over.title : title;
            table.collection = over.collection.IsNotEmpty() ? over.collection : collection;

            var matchedCells = cells?.Select(c =>
            {
                var match = over.cells.FirstOrDefault(x => x.Key == c.Key);
                return c.ApplyOverrides(match);
            }).ToList() ?? new List<Cell>();

            var keys = cells.Select(x => x.Key).ToList();

            var missingCells = over.cells.Where(x => !keys.Contains(x.Key)).Select(x => x.ApplyOverrides(null));
            table.cells = matchedCells.Concat(missingCells).ToArray();

            return table;
        }
        public void SetUp()
        {
            var runner = TestRunnerBuilder.ForFixture<TableOnlyFixture>();
            FixtureLibrary library = runner.Library;

            table = library.FixtureFor("TableOnly").GrammarFor("Go").ShouldBeOfType<Table>();
        }
        public void SetUp()
        {
            var library = FixtureGraph.Library;
            table = (Table)library.FixtureFor("SampleTable").GrammarFor("Table1");

            tag = new TableTemplateTag(table, new CellBuilderLibrary());
        }
        public void SetUp()
        {
            var runner = new TestRunner(x => { x.AddFixture<TableOnlyFixture>(); });

            FixtureLibrary library = runner.Library;

            table = library.FixtureFor("TableOnly").GrammarFor("Go").ShouldBeOfType<Table>();
        }
Esempio n. 5
0
 public ColumnSelectionTag(Table table)
     : base("span")
 {
     AddClass(GrammarConstants.COLUMN_SELECTOR);
     Add("b").Text(GrammarConstants.ADDITIONAL_COLUMNS_HEADER_TEXT);
     table.Cells
         .Where(x => x.HasDefault())
         .Each(cell => Child(new OptionalColumnTag(cell)));
 }
Esempio n. 6
0
        public void SetUp()
        {
            table = new Table("The Label", "rows", new List<Cell>
            {
                Cell.For<string>("name"),
                Cell.For<int>("age")
            });

            step = table.CreateExample();
        }
Esempio n. 7
0
        public void call_the_correct_method()
        {
            var visitor = MockRepository.GenerateMock<IGrammarVisitor>();
            var step = new Step("grammar");

            var table = new Table();

            table.AcceptVisitor(visitor, step);

            visitor.AssertWasCalled(x => x.Table(table, step));
        }
        public StoryTellerTableTag(Table table, IStep step)
        {
            _table = table;
            _step = step;
            AddClass("table");
            Attr("cellpadding", "0").Attr("cellspacing", "0");

            CaptionText(_table.Label);
            AddHeaderRow(x =>
            {
                _headerRow = x;
                _table.Cells.Each(cell => x.Header(cell.Header));
            });
        }
        public StoryTellerTableTag(Table table, IStep step)
        {
            AddClass("table");
            this.AddSafeClassName(table.GetType().Name.ToLower());

            _table = table;
            _step = step;

            _writer = table.GetWriter(_step);

            Attr("cellpadding", "0").Attr("cellspacing", "0");

            AddHeaderRow(x =>
            {
                _headerRow = x;

                _writer.DisplayCells.Each(cell => x.Header(cell.Header));
            });
        }
Esempio n. 10
0
        public ColumnSelectionTag(Table table)
            : base("p")
        {
            AddClass(GrammarConstants.COLUMN_SELECTOR);
            Add("span").Text(GrammarConstants.ADDITIONAL_COLUMNS_HEADER_TEXT);

            var count = 1;
            table.Cells.Where(x => x.HasDefault()).Each(cell =>
            {
                Append(new OptionalColumnTag(cell));
                count++;

                if (count == 5)
                {
                    Add("br");
                    count = 0;
                }
            });
        }
Esempio n. 11
0
        public TableTemplateTag(Table table, ICellBuilderLibrary builders)
        {
            Style("display", "none");
            AddClass(GrammarConstants.TEMPLATES);

            AddHeaderRow(x =>
            {
                x.Header(" ").AddClass("command");
                table.Cells.Each(cell =>
                {
                    x.Append(new CellHeaderTag(cell));
                });
            });

            AddBodyRow(x =>
            {
                x.Cell().AddClass("command").Add<DeleteIconTag>().AddClass("remover");
                table.Cells.Each(cell => x.Cell().AddSafeClassName(cell.Key).Append(builders.BuildTag(cell)));
            });
        }
        public void with_table_child()
        {
            theParagraph.AddChild(new Sentence { format = "Go left" });
            theParagraph.AddChild(new Sentence { format = "Go right" });

            var table = new Table
            {
                title = "Some Table",
                cells = new Cell[] {new Cell {Key = "One"}, new Cell { Key = "Two" }, new Cell { Key = "Three" }, }
            };


            theParagraph.AddChild(table);

            var code = theParagraph.ToMissingCode();

            code.ShouldContain(@"
        [StoryTeller.Hidden]
        [StoryTeller.Grammars.Tables.ExposeAsTable(""Some Table"")]
");
        }
Esempio n. 13
0
        public TableTemplateTag(Table table, ICellBuilderLibrary builders)
        {
            Style("display", "none");
            AddClass(GrammarConstants.TEMPLATES);

            AddHeaderRow(x =>
            {
                x.Header(" ").AddClass("command");
                table.Cells.Each(cell =>
                {
                    x.Child(new CellHeaderTag(cell));
                });
            });

            AddBodyRow(x =>
            {
                x.Cell().AddClass("command").Child(new LinkTag("remove", "#", "remover"));
                table.Cells.Each(cell =>
                {
                    x.Cell().AddClass(cell.Key).Child(builders.BuildTag(cell));
                });
            });
        }
Esempio n. 14
0
        void ITestStream.Table(Table table, IStep step)
        {
            var tag = new StoryTellerTableTag(table, step);
            tag.WriteResults(_context);

            _document.Add(tag);
        }
Esempio n. 15
0
 public void Table(Table table, IStep step)
 {
     withNewLeaf(step, Icon.Table, node =>
     {
         node.AddText(table.Label);
         addRearrangeCommands(node);
     });
 }
Esempio n. 16
0
 void IGrammarVisitor.Table(Table table, IStep step)
 {
     _link.Label(table.Label);
 }
Esempio n. 17
0
        public void create_the_Table()
        {
            var cells = new List<Cell>
            {
                new Cell("a", typeof (string)),
                new Cell("b", typeof (int)),
                Cell.For<Address>("address")
            };
            inner.Stub(x => x.GetCells()).Return(cells);

            var table = grammar.ToStructure(new FixtureLibrary()).ShouldBeOfType<Table>();

            var expected = new Table(grammar.LabelName, "record",
                                     new[] {new Cell("a", typeof (string)), new Cell("b", typeof (int))});
            table.ShouldEqual(expected);
        }
Esempio n. 18
0
 void IGrammarVisitor.Table(Table table, IStep step)
 {
     add(table.Name, table.Label, Icon.Table);
 }
        protected override void theContextIs()
        {
            step = new Step().With("x", 1).With("y", 2);

            treeBuilder.StartTest(theTest);

            section = new Section("Math");

            treeBuilder.StartTest(theTest);
            treeBuilder.StartSection(section, new FixtureGraph("Math"));

            table = new Table("the label of this grammar", "leaf1");

            treeBuilder.Table(table, step);
        }
Esempio n. 20
0
        public void SetUp()
        {
            cells = new[]
            {
                Cell.For<int>("a"),
                Cell.For<int>("b"),
                Cell.For<int>("c"),
                Cell.For<int>("d"),
                Cell.For<int>("e"),
            };

            cells[3].DefaultValue = "5";
            cells[4].DefaultValue = "6";

            steps = new List<IStep>
            {
                new Step().With("a:1,b:2,c:3,d:4,e:5"),
                new Step().With("a:2,b:3,c:4,d:6,e:6"),
                new Step().With("a:3,b:4,c:5,d:6,e:7"),
                new Step().With("a:4,b:5,c:6,d:7,e:8"),
            };

            table = new Table("something", "Leaf", cells);
        }
Esempio n. 21
0
        private void writeTable(Table table)
        {
            grammarTag.MetaData(GrammarConstants.LEAF_NAME, table.LeafName);
            grammarTag.AddClass(GrammarConstants.TABLE_EDITOR);
            grammarTag.Child<HeaderTag>().Titled(table.Title);

            var editor = grammarTag.Child<TableTag>();
            editor.Attr("cellpadding", "0").Attr("cellspacing", "0");

            editor.AddFooterRow(x =>
            {
                x.Cell().AddClass("table-add-row").Configure(td =>
                {
                    td.ActionLink("add").AddClass("adder");
                    td.ActionLink("clone").AddClass("cloner");
                });
            })
            .AddFooterRow(x =>
            {
                x.Cell().Child(new ColumnSelectionTag(table));
            })
            .AddClasses("grid", "editor");

            grammarTag.Child(new TableTemplateTag(table, new CellBuilderLibrary()));
        }
Esempio n. 22
0
        public void SetUp()
        {
            leaf = new StepLeaf();
            leaf.AddNewStep();
            leaf.AddNewStep();
            leaf.AddNewStep();
            leaf.AddNewStep();

            Cell b = Cell.For<int>("b");
            b.DefaultValue = "2";
            Cell a = Cell.For<int>("a");
            a.DefaultValue = "3";

            table = new Table("some label", "row", a, b);

            table.SetDefaultValueFor("b", leaf);
        }
        public void writing_a_table_should_not_add_rearrange_commands()
        {
            var table = new Table();
            treeBuilder.Table(table, step);

            nodeBuilder.AssertWasNotCalled(x => x.ConfigureRearrangeCommands(treeBuilder.LastNode, null, step));
        }
Esempio n. 24
0
        public bool Equals(Table obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;

            if (!Equals(obj._leafName, _leafName)) return false;
            if (!Equals(obj._label, _label)) return false;

            if (_cells.Count != obj._cells.Count) return false;

            for (int i = 0; i < _cells.Count; i++)
            {
                if (!_cells[i].Equals(obj._cells[i])) return false;
            }

            return true;
        }
Esempio n. 25
0
        void ITestStream.Table(Table table, IStep step)
        {
            var holder = _document.Current.JoinTagAtEnd<TableContainerTag>();

            var tag = new StoryTellerTableTag(table, step);
            tag.WriteResults(_context);

            holder.Add(table.Label, tag);
        }
Esempio n. 26
0
 public void ConfigureTableColumnSelector(OutlineNode node, Table table, IStep step)
 {
     // no-op
 }
Esempio n. 27
0
 void IGrammarVisitor.Table(Table table, IStep step)
 {
     writeTable(table);
 }
Esempio n. 28
0
 void IGrammarVisitor.Table(Table table, IStep step)
 {
     _stream.Table(table, step);
 }
Esempio n. 29
0
 void ITestStream.Table(Table table, IStep step)
 {
     markGrammar(table.Name);
 }
Esempio n. 30
0
        private void writeTable(Table table)
        {
            grammarTag.MetaData(GrammarConstants.LEAF_NAME, table.LeafName);
            grammarTag.AddClass(GrammarConstants.TABLE_EDITOR);

            var area = new AreaTag(table.Label);
            var container = area.Container.Add("div").AddClass("section-container");

            container.Add<TableEditorTag>();
            container.Append(new ColumnSelectionTag(table));
            container.Append(new TableTemplateTag(table, new CellBuilderLibrary()));

            grammarTag.Append(area);
        }