Inheritance: GrammarStructure, IWriter
示例#1
0
        public override GrammarModel ApplyOverrides(GrammarModel grammar)
        {
            var sentence = new Sentence {key = key};

            var over = grammar as Sentence;
            if (over == null)
            {
                sentence.format = format;
                sentence.cells = cells.Select(c => c.ApplyOverrides(null)).ToArray();
                return sentence;
            }

            sentence.format = over.format.IsNotEmpty() ? over.format : format;
            sentence.cells = cells?.Select(c =>
            {
                var match = sentence.cells.FirstOrDefault(x => x.Key == c.Key);
                return c.ApplyOverrides(match);
            }).ToArray();

            var keys = sentence.cells.Select(x => x.Key).ToList();
            var missing = over.cells.Where(x => !keys.Contains(x.Key));
            missing.Each(c =>
            {
                sentence.AddCell(c.ApplyOverrides(null));
            });

            return sentence;
        }
        public void SetUp()
        {
            var runner = new TestRunner(x => { x.AddFixture<LinesOnlyFixture>(); });

            FixtureLibrary library = runner.Library;

            sentence = library.FixtureFor("LinesOnly").GrammarFor("Go").ShouldBeOfType<Sentence>();
        }
示例#3
0
 public SentenceTag(Sentence sentence, IStep step)
     : base("div")
 {
     _sentence = sentence;
     _step = step;
     this.AddSafeClassName(sentence.Name);
     AddClass("sentence");
 }
示例#4
0
        public void call_teh_sentence_method()
        {
            var sentence = new Sentence();
            var visitor = MockRepository.GenerateMock<IGrammarVisitor>();
            var step = new Step();

            sentence.AcceptVisitor(visitor, step);

            visitor.AssertWasCalled(x => x.Sentence(sentence, step));
        }
示例#5
0
        public void SetUp()
        {
            sentence = Sentence.For("{name} is {age}", Cell.For<string>("name"), Cell.For<int>("age"));
            step = new Step().With("name:Max,age:6");
            tag = new SentenceTag(sentence, step);

            context = new TestContext();

            tag.WritePreview(context);
        }
示例#6
0
        public void SetUp()
        {
            sentence = Sentence.For("{x} + {y} should equal {z}", Cell.For<int>("x"), Cell.For<int>("y"),
                                    Cell.For<int>("z"));

            sentence.Name = "Add";
            sentence.Description = "adds x to y";

            theExample = sentence.CreateExample();
        }
示例#7
0
        public void has_the_step_class()
        {
            var sentence = new Sentence
            {
                Name = "ThisGrammar",
            };

            var tag = new GrammarTag(sentence);

            tag.HasClass(GrammarConstants.STEP).ShouldBeTrue();
        }
示例#8
0
        public void has_the_meta_data_tag_for_key()
        {
            var sentence = new Sentence
            {
                Name = "ThisGrammar",
            };

            var tag = new GrammarTag(sentence);

            tag.MetaData(GrammarConstants.KEY).ShouldEqual(sentence.Name);
        }
示例#9
0
        public void read_the_name_and_description()
        {
            var sentence = new Sentence
            {
                Name = "ThisGrammar",
            };

            var tag = new GrammarTag(sentence);

            tag.TagName().ShouldEqual("div");
            tag.HasClass(sentence.Name).ShouldBeTrue();
        }
示例#10
0
        public void adding_a_close_link_adds_to_itself_if_there_is_no_header_tag()
        {
            var sentence = new Sentence
            {
                Name = "ThisGrammar",
                Parent = new FixtureGraph()
            };

            var tag = new GrammarTag(sentence);
            tag.AddDeleteLink();

            tag.Children.Last().ShouldBeOfType<RemoveLinkTag>();
        }
        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);
        }
示例#12
0
        public void SetUp()
        {
            sentence = Sentence.For("{name} is {age}", Cell.For<string>("name"), Cell.For<int>("age"));
            step = new Step().With("name:Max,age:6");
            tag = new SentenceTag(sentence, step);

            context = new TestContext();
            StepResults results = context.ResultsFor(step);
            results.CaptureException("bad stuff");
            results.ExceptionText.ShouldEqual("bad stuff");

            tag.WriteResults(context);
        }
示例#13
0
        public void adding_a_close_link_adds_to_the_header_tag_if_it_exists()
        {
            var sentence = new Sentence
            {
                Name = "ThisGrammar",
                Parent = new FixtureGraph()
            };

            var tag = new GrammarTag(sentence);
            var header = new HeaderTag();
            tag.Append(header);

            tag.AddDeleteLink();

            tag.Children.Count.ShouldEqual(1);

            Debug.WriteLine(tag.ToString());

            header.FirstChild().Children.Count(x => x is RemoveLinkTag).ShouldEqual(1);
        }
示例#14
0
 public void Sentence(Sentence sentence, IStep step)
 {
     withNewLeaf(step, Icon.Sentence, node =>
     {
         _configurer.WriteSentenceText(node, sentence, step);
         addRearrangeCommands(node);
     });
 }
示例#15
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     sentence.Parts.Each(x => x.AcceptVisitor(this));
 }
示例#16
0
        public void SetUp()
        {
            sentence = new Sentence
            {
                Name = "Something"
            };

            var fixture = new FixtureStructure("Math");
            fixture.Policies.Tag(sentence.Name, "abc");
            fixture.Policies.Tag(sentence.Name, "def");
            fixture.Policies.Tag(Guid.NewGuid().ToString(), "tuv");

            fixtureTag = new FixtureTag(fixture);
            grammarTag = fixtureTag.Add(sentence);
        }
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     add(sentence.Name, sentence.Label, Icon.Sentence);
 }
 public void WriteSentenceText(OutlineNode node, Sentence sentence, IStep step)
 {
     var writer = new SentenceWriter(node, step);
     sentence.Parts.Each(x => x.AcceptVisitor(writer));
 }
        public void adding_an_embedded_section_then_a_sentence_under_a_paragraph_should_still_have_adder_commands()
        {
            var embedded = new EmbeddedSection(new FixtureGraph("Embed"), "the label", "embed");
            treeBuilder.StartEmbeddedSection(embedded, step);

            var sentence = new Sentence();
            var sentenceStep = new Step();
            treeBuilder.Sentence(sentence, sentenceStep);

            nodeBuilder.AssertWasCalled(x => x.ConfigureRearrangeCommands(treeBuilder.LastNode, embedded.LeafFor(step), sentenceStep));
        }
示例#20
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     _stream.Sentence(sentence, step);
 }
        protected override void theContextIs()
        {
            sentence = Sentence.For("Add {x} to {y}", Cell.For<int>("x"), Cell.For<int>("y"));
            sentence.Name = "adding";
            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"));

            treeBuilder.Sentence(sentence, step);
        }
        public void SetUp()
        {
            FixtureLibrary library = FixtureGraph.Library;

            sentence = library.FixtureFor("LinesOnly").GrammarFor("Go").ShouldBeOfType<Sentence>();
        }
示例#23
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     // TODO -- extension point for external CellBuilders?
     var writer = new SentenceWriter(grammarTag, new CellBuilderLibrary());
     writer.Write();
 }
        public void SetUp()
        {
            cell = Cell.For<bool>("returnValue");
            cell.IsResult = true;
            cell.IsBooleanResult().ShouldBeTrue();

            sentence = new Sentence("The answer should be true", new[] { cell });
        }
示例#25
0
 void ITestStream.Sentence(Sentence sentence, IStep step)
 {
     var tag = new SentenceTag(sentence, step);
     tag.WriteResults(_context);
     _document.Add(tag);
 }
        public void writing_a_sentence_should_not_add_rearrange_commands()
        {
            var sentence = new Sentence();
            treeBuilder.Sentence(sentence, step);

            nodeBuilder.AssertWasNotCalled(x => x.ConfigureRearrangeCommands(treeBuilder.LastNode, null, step));
        }
示例#27
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     _stream.Sentence(sentence, step);
 }
示例#28
0
        public void SetUp()
        {
            context = new TestContext();
            sentence = new FactFixture()["True"].ToStructure(new FixtureLibrary()).As<Sentence>();
            step = new Step();

            sentence.ResultCell.RecordActual(true, step, context);

            tag = new SentenceTag(sentence, step);
            tag.WriteResults(context);
        }
示例#29
0
 void ITestStream.Sentence(Sentence sentence, IStep step)
 {
     markGrammar(sentence.Name);
 }
示例#30
0
        public bool Equals(Sentence obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;

            if (!Name.Equals(obj.Name)) return false;

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

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

            return true;
        }