Inheritance: GrammarModel, IModelWithCells
Example #1
0
        public void should_call_the_paragraph_member()
        {
            var visitor = MockRepository.GenerateMock<IGrammarVisitor>();
            var step = new Step();
            var paragraph = new Paragraph();

            paragraph.AcceptVisitor(visitor, step);

            visitor.AssertWasCalled(x => x.Paragraph(paragraph, step));
        }
        public void surfaces_all_the_child_errors()
        {
            var child1 = new Sentence();
            child1.AddError(new GrammarError());
            child1.AddError(new GrammarError());

            var child2 = new Sentence();
            child2.AddError(new GrammarError());
            child2.AddError(new GrammarError());

            var paragraph = new Paragraph(new GrammarModel[] {child1, child2});
            paragraph.errors.Length.ShouldBe(4);
        }
Example #3
0
        public ParagraphTag(Paragraph paragraph, IStep step)
            : base("div")
        {
            _paragraph = paragraph;
            _step = step;

            AddClass("paragraph");
            AddClass(paragraph.Style.ToString());

            if (paragraph.Style == EmbedStyle.TitledAndIndented)
            {
                Add("div").AddClass(HtmlClasses.SECTION_TITLE);
            }
        }
Example #4
0
        public void SetUp()
        {
            paragraph = new Paragraph
            {
                Description = "description",
                Name = "some name"
            };
            Sentence sentence1 = Sentence.For("{x}", Cell.For<int>("x"));
            Sentence sentence2 = Sentence.For("{y}", Cell.For<int>("y"));
            Sentence sentence3 = Sentence.For("{z}", Cell.For<int>("z"));

            paragraph.AddStructure(sentence1);
            paragraph.AddStructure(sentence2);
            paragraph.AddStructure(sentence3);

            theExample = paragraph.CreateExample();
        }
Example #5
0
        public override GrammarModel ApplyOverrides(GrammarModel grammar)
        {
            var @override = grammar as Paragraph;
            if (@override == null) return this;


            var newParagraph = new Paragraph
            {
                key = key
            };

            if (@override.title.IsNotEmpty() && @override.title != key)
                newParagraph.title = @override.title;


            if (@override.children == null || @override.children.Length == 0)
            {
                newParagraph.children = children;
            }
            else
            {
                var nonSilentIndex = 0;

                foreach (var child in children)
                    if (child is Silent)
                    {
                        newParagraph.AddChild(child);
                    }
                    else
                    {
                        if (@override.children.Length > nonSilentIndex)
                        {
                            var overridenChild = @override.children[nonSilentIndex++];
                            newParagraph.AddChild(child.ApplyOverrides(overridenChild));
                        }
                        else
                        {
                            newParagraph.AddChild(child);
                        }
                    }
            }

            return newParagraph;
        }
Example #6
0
 void ITestStream.EndParagraph(Paragraph paragraph, IStep step)
 {
     _document.Pop();
 }
Example #7
0
        void ITestStream.StartParagraph(Paragraph paragraph, IStep step)
        {
            _paragraphResults = _context.ResultsFor(step);
            _paragraphResults.MoveFirst();

            var tag = new ParagraphTag(paragraph, step);
            _document.Push(tag);
        }
 public void EndParagraph(Paragraph paragraph, IStep step)
 {
     _nodes.Pop();
 }
Example #9
0
 void ITestStream.StartParagraph(Paragraph paragraph, IStep step)
 {
     markGrammar(paragraph.Name);
 }
Example #10
0
        void ITestStream.StartParagraph(Paragraph paragraph, IStep step)
        {
            var tag = new ParagraphTag(paragraph, step);

            _document.Push(tag);
        }
 void IGrammarVisitor.Paragraph(Paragraph paragraph, IStep step)
 {
     add(paragraph.Name, paragraph.Label, Icon.Paragraph);
 }
        public void SetUp()
        {
            var library = new FixtureLibrary();

            var grammar1 = MockRepository.GenerateMock<IGrammar>();
            var grammar2 = MockRepository.GenerateMock<IGrammar>();
            var grammar3 = MockRepository.GenerateMock<IGrammar>();

            structure1 = new StubGrammarStructure();
            structure2 = new StubGrammarStructure();
            structure3 = new StubGrammarStructure();

            grammar1.Expect(x => x.Description).Return("something");
            grammar1.Expect(x => x.ToStructure(library)).Return(structure1);
            grammar2.Expect(x => x.ToStructure(library)).Return(structure2);
            grammar3.Expect(x => x.ToStructure(library)).Return(structure3);

            grammar = new ParagraphGrammar("the title").With(grammar1, grammar2, grammar3);
            grammar.Style = EmbedStyle.TitledAndIndented;
            theStructure = grammar.ToStructure(library).ShouldBeOfType<Paragraph>();
        }
Example #13
0
        void IGrammarVisitor.Paragraph(Paragraph paragraph, IStep step)
        {
            grammarTag.AddClasses(GrammarConstants.PARAGRAPH, paragraph.Style.ToString());
            var area = new AreaTag(paragraph.Label);
            var container = area.Container.Add("div")
                .AddClass("paragraph.Style.ToString()")
                .AddClass("section-container")
                .AddClass("in-paragraph");
            grammarTag.Append(area);

            paragraph.ForEachGrammar(g =>
            {
                var tag = new GrammarTag(g);

                container.Append(tag);

                _grammarTags.Do(tag, () => g.AcceptVisitor(this, new Step()));
            });
        }
        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"));

            paragraph = new Paragraph("the label of this paragraph", new List<GrammarStructure>());
            treeBuilder.StartParagraph(paragraph, step);
        }
Example #15
0
        void IGrammarVisitor.Paragraph(Paragraph paragraph, IStep step)
        {
            _stream.StartParagraph(paragraph, step);

            paragraph.ForEachGrammar(g =>
            {
                g.AcceptVisitor(this, step);
                _stream.IncrementParagraphGrammar();
            });

            _stream.EndParagraph(paragraph, step);
        }
Example #16
0
        void IGrammarVisitor.Paragraph(Paragraph paragraph, IStep step)
        {
            grammarTag.AddClasses(GrammarConstants.PARAGRAPH, paragraph.Style.ToString());
            var header = new HeaderTag();
            grammarTag.Child(header);

            if (paragraph.Style == EmbedStyle.TitledAndIndented)
            {
                header.Titled(paragraph.Title);
            }

            paragraph.ForEachGrammar(g =>
            {
                var tag = new GrammarTag(g);
                grammarTag.Child(tag);

                _grammarTags.Do(tag, () => g.AcceptVisitor(this, new Step()));
            });
        }
Example #17
0
 void IGrammarVisitor.Paragraph(Paragraph paragraph, IStep step)
 {
     _link.Label(paragraph.Label);
 }
Example #18
0
 void ITestStream.EndParagraph(Paragraph paragraph, IStep step)
 {
 }
Example #19
0
 public void StartParagraph(Paragraph paragraph, IStep step)
 {
     withNewNode(step, Icon.Paragraph, node =>
     {
         node.AddText(paragraph.Label);
         addRearrangeCommands(node);
     });
 }