상속: 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);
        }
예제 #17
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     add(sentence.Name, sentence.Label, Icon.Sentence);
 }
예제 #18
0
 public void WriteSentenceText(OutlineNode node, Sentence sentence, IStep step)
 {
     var writer = new SentenceWriter(node, step);
     sentence.Parts.Each(x => x.AcceptVisitor(writer));
 }
예제 #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));
        }
예제 #20
0
 void IGrammarVisitor.Sentence(Sentence sentence, IStep step)
 {
     _stream.Sentence(sentence, step);
 }
예제 #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>();
        }
예제 #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);
 }
예제 #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));
        }
예제 #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;
        }