Inheritance: GrammarStructure, IWriter
Exemplo n.º 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>();
        }
Exemplo n.º 3
0
 public SentenceTag(Sentence sentence, IStep step)
     : base("div")
 {
     _sentence = sentence;
     _step = step;
     this.AddSafeClassName(sentence.Name);
     AddClass("sentence");
 }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 7
0
        public void has_the_step_class()
        {
            var sentence = new Sentence
            {
                Name = "ThisGrammar",
            };

            var tag = new GrammarTag(sentence);

            tag.HasClass(GrammarConstants.STEP).ShouldBeTrue();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 14
0
 public void Sentence(Sentence sentence, IStep step)
 {
     withNewLeaf(step, Icon.Sentence, node =>
     {
         _configurer.WriteSentenceText(node, sentence, step);
         addRearrangeCommands(node);
     });
 }
Exemplo n.º 15
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     sentence.Parts.Each(x => x.AcceptVisitor(this));
 }
Exemplo n.º 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);
        }
Exemplo n.º 17
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     add(sentence.Name, sentence.Label, Icon.Sentence);
 }
Exemplo n.º 18
0
 public void WriteSentenceText(OutlineNode node, Sentence sentence, IStep step)
 {
     var writer = new SentenceWriter(node, step);
     sentence.Parts.Each(x => x.AcceptVisitor(writer));
 }
Exemplo n.º 19
0
        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));
        }
Exemplo n.º 20
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     _stream.Sentence(sentence, step);
 }
Exemplo n.º 21
0
        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>();
        }
Exemplo n.º 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 });
        }
Exemplo n.º 25
0
 void ITestStream.Sentence(Sentence sentence, IStep step)
 {
     var tag = new SentenceTag(sentence, step);
     tag.WriteResults(_context);
     _document.Add(tag);
 }
Exemplo n.º 26
0
        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));
        }
Exemplo n.º 27
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     _stream.Sentence(sentence, step);
 }
Exemplo n.º 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);
        }
Exemplo n.º 29
0
 void ITestStream.Sentence(Sentence sentence, IStep step)
 {
     markGrammar(sentence.Name);
 }
Exemplo n.º 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;
        }