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>(); }
public SentenceTag(Sentence sentence, IStep step) : base("div") { _sentence = sentence; _step = step; this.AddSafeClassName(sentence.Name); AddClass("sentence"); }
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)); }
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); }
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(); }
public void has_the_step_class() { var sentence = new Sentence { Name = "ThisGrammar", }; var tag = new GrammarTag(sentence); tag.HasClass(GrammarConstants.STEP).ShouldBeTrue(); }
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); }
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(); }
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); }
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); }
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); }
public void Sentence(Sentence sentence, IStep step) { withNewLeaf(step, Icon.Sentence, node => { _configurer.WriteSentenceText(node, sentence, step); addRearrangeCommands(node); }); }
void IGrammarVisitor.Sentence(Sentence sentence, IStep step) { sentence.Parts.Each(x => x.AcceptVisitor(this)); }
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)); }
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>(); }
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 }); }
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)); }
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); }
void ITestStream.Sentence(Sentence sentence, IStep step) { markGrammar(sentence.Name); }
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; }