Inheritance: Node, INodeHolder
        public void section_with_a_single_step_that_only_has_values()
        {
            var section = new Section("Math");
            section.AddStep("Add").With("x", "1").With("y", "2").With("sum", "3");

            Debug.WriteLine(section.ToJson());
        }
        public void section_with_a_single_comment()
        {
            var section = new Section("Math");
            section.AddComment("some foo");

            Debug.WriteLine(section.ToJson());
        }
Example #3
0
        public Section AddCollection(string key)
        {
            var section = new Section(key);
            Collections[key] = section;

            return section;
        }
        public void apply_renumbering()
        {
            var spec = new Specification();
            var c1 = new Comment();
            spec.Children.Add(c1);
            var section1 = new Section("Foo");
            var s1 = section1.AddStep("foo1");
            var s2 = section1.AddStep("foo1");
            var s3 = section1.AddStep("foo1");

            var section2 = s3.AddCollection("rows");
            var s4 = section2.AddStep("r1");
            var s5 = section2.AddStep("r1");
            var s6 = section2.AddStep("r1");

            s4.id = s5.id = s6.id = Guid.NewGuid().ToString();

            spec.Children.Add(section1);
            var c2 = new Comment();
            spec.Children.Add(c2);

            spec.ApplyRenumbering();

            s4.id.ShouldNotBe(s5.id);
            s5.id.ShouldNotBe(s6.id);
            s4.id.ShouldNotBe(s6.id);
        }
        public void ValidateStepsWithinSection(Section section, FixtureModel fixture)
        {
            if (fixture.IsMissing)
            {
                AddError($"Fixture '{fixture.key}' is not implemented");
            }

            var i = 0;
            foreach (var step in section.Children.OfType<Step>())
            {
                i++;

                _locations.Push($"Step #{i}: {step.Key}");

                var grammar = fixture.FindGrammar(step.Key);
                if (grammar == null)
                {
                    AddError($"Unknown Grammar '{step.Key}'");
                }
                else
                {
                    if (grammar.IsMissing)
                    {
                        AddError($"Grammar '{step.Key}' is not implemented");
                    }

                    grammar.PostProcessAndValidate(this, step);
                }

                _locations.Pop();
            }
        }
 public VerificationSetPlan(Section section, ISetMatcher matcher, ISetComparison comparison,
     IEnumerable<StepValues> expected, Cell[] cells)
 {
     _section = section;
     _matcher = matcher;
     _comparison = comparison;
     _expected = expected;
     _cells = cells;
 }
        public void execute_happy_path()
        {
            var wasCalled = false;
            var section = new Section("Math"){id = "4"};
            var action = new SilentAction("Fixture", Stage.setup, x => wasCalled = true, section);
            var context = SpecContext.ForTesting();
            action.Execute(context);

            ShouldBeTestExtensions.ShouldBe(wasCalled, true);

        }
        public void exceptions_are_critical()
        {
            var context = SpecContext.ForTesting();
            var ex = new DivideByZeroException();

            var section = new Section("Math") { id = "5" };
            var action = SilentAction.AsCritical("Fixture", Stage.teardown, x => { throw ex; }, section);

            action.Execute(context);

            ShouldBeTestExtensions.ShouldBe(context.CanContinue(), false);
        }
        public SectionTag(Section section, FixtureGraph fixture)
            : base("div")
        {
            _section = section;
            _fixture = fixture;

            Add("h3").Text(_fixture.Label ?? _fixture.Name).AddClass(HtmlClasses.SECTION_TITLE).Title(fixture.FixtureClassName);

            AddClass("section");

            _body = Add("div").AddClass("section-body");
        }
        private void validateSection(Section section)
        {
            if (!_library.Models.Has(section.Key))
            {
                AddError($"References an unknown Fixture ('{section.Key}')");
                return;
            }

            var fixture = _library.Models[section.Key];


            ValidateStepsWithinSection(section, fixture);
        }
        public SectionTag(Section section, FixtureGraph fixture)
            : base("div")
        {
            _section = section;
            _fixture = fixture;

            AddClass("section");
            AddClass("embedded");

            Add("div").AddClass("section-header")
                .Add("div").AddClass(HtmlClasses.SECTION_TITLE).Text(_fixture.Title);

            _stepHolder = Add("div").Add("div").AddClass("step-holder");
        }
        public void execute_sad_path()
        {
            var context = SpecContext.ForTesting();
            var ex = new DivideByZeroException();

            var section = new Section("Math") {id = "5"};
            var action = new SilentAction("Fixture", Stage.teardown, x => { throw ex; }, section);

            action.Execute(context);

            var result = context.Results.Single().ShouldBeOfType<StepResult>();

            result.id.ShouldBe(section.id);
            result.position.ShouldBe(Stage.teardown.ToString());
            result.status.ShouldBe(ResultStatus.error);
            result.error.ShouldContain("DivideByZeroException");


        }
        public void create_example_test()
        {
            var test = new Test("some test");
            test.Section("a");
            test.Section("b");
            test.Section("c");
            Section section = new Section("Math").WithStep("MultiplyBy").WithStep("step1").WithStep("step2");
            test.Add(section);

            var structure = new StubGrammarStructure
            {
                Name = "MultiplyBy",
                Parent = new FixtureGraph("Math")
            };
            structure.ModifyExampleTest(test);

            test.Parts.Count.ShouldEqual(1);
            var theSection = test.Parts[0].ShouldBeOfType<Section>();

            theSection.Parts.Count.ShouldEqual(1);
            theSection.Parts[0].ShouldBeOfType<IStep>().GrammarKey.ShouldEqual("MultiplyBy");
        }
        public void can_find_all_children()
        {
            var spec = new Specification();
            var c1 = new Comment();
            spec.Children.Add(c1);
            var section1 = new Section("Foo");
            var s1 = section1.AddStep("foo1");
            var s2 = section1.AddStep("foo1");
            var s3 = section1.AddStep("foo1");


            var section2 = s3.AddCollection("rows");
            var s4 = section2.AddStep("r1");
            var s5 = section2.AddStep("r1");
            var s6 = section2.AddStep("r1");

            spec.Children.Add(section1);
            var c2 = new Comment();
            spec.Children.Add(c2);

            var nodes = spec.AllNodes();

            // All comments, steps, sections, and the spec itself
            nodes.Count().ShouldBe(11);

            nodes.ShouldContain(spec);
            nodes.ShouldContain(section1);
            nodes.ShouldContain(section2);
            nodes.ShouldContain(c1);
            nodes.ShouldContain(c2);
            nodes.ShouldContain(s1);
            nodes.ShouldContain(s2);
            nodes.ShouldContain(s3);
            nodes.ShouldContain(s4);
            nodes.ShouldContain(s5);
            nodes.ShouldContain(s6);
        }
        public void serializes_fine()
        {
            var spec = new Specification();
            var c1 = new Comment();
            spec.Children.Add(c1);
            var section1 = new Section("Foo");
            var s1 = section1.AddStep("foo1");
            var s2 = section1.AddStep("foo1");
            var s3 = section1.AddStep("foo1");


            var section2 = s3.AddCollection("rows");
            var s4 = section2.AddStep("r1");
            var s5 = section2.AddStep("r1");
            var s6 = section2.AddStep("r1");

            spec.Children.Add(section1);
            var c2 = new Comment();
            spec.Children.Add(c2);

            var json = JsonSerialization.ToJson(spec, true);

            Debug.WriteLine(json);
        }
        public void read_and_write_a_section_under_a_spec()
        {
            var section = new Section("Math")
            {
                id = Guid.NewGuid().ToString(),
            };

            section.ActiveCells.Add("A", true);
            section.ActiveCells.Add("B", false);

            original.Children.Add(section);

            var persistedSection = persisted.Children.Single().ShouldBeOfType<Section>();
            persistedSection.id.ShouldBe(section.id);
            persistedSection.Key.ShouldBe(section.Key);
            persistedSection.ActiveCells["A"].ShouldBeTrue();
            persistedSection.ActiveCells["B"].ShouldBeFalse();
        }
Example #17
0
 void ITestStream.InvalidSection(Section section)
 {
     ForFixture(section.FixtureName).Mark(_currentTest);
 }
Example #18
0
 void ITestStream.EndSection(Section section)
 {
     _fixtureStack.Pop();
 }
Example #19
0
 void ITestStream.StartSection(Section section, FixtureGraph fixture)
 {
     ForFixture(section.FixtureName).Mark(_currentTest);
     _fixtureStack.Push(fixture);
 }
Example #20
0
 public void EndSection(Section section)
 {
     _nodes.Pop();
 }
Example #21
0
        public void StartSection(Section section, FixtureGraph fixture)
        {
            withNewNode(section, Icon.Section, node =>
            {
                node.AddText(fixture.Label);
                node.ToolTip = fixture.FixtureClassName;

                addRearrangeCommands(node);
                _configurer.ConfigurePartAdders(node, fixture, section);
            });
        }
Example #22
0
 void ITestStream.InvalidSection(Section section)
 {
     _document.Add(new InvalidFixtureTag(section.FixtureName));
 }
 public void SetUp()
 {
     FixtureGraph fixtureGraph = TestRunnerBuilder.ForFixture<MathFixture>().Library.FixtureFor("Math");
     section = fixtureGraph.CreateExample();
 }
Example #24
0
 void ITestStream.EndSection(Section section)
 {
     _document.Pop();
 }
Example #25
0
        void ITestStream.StartSection(Section section, FixtureStructure fixture)
        {
            var sectionTag = new SectionTag(section, fixture);
            sectionTag.WriteResults(_context);

            _document.Add(sectionTag);

            _document.PushWithoutAttaching(sectionTag.Body);
        }
Example #26
0
        public Section AddSection(string key)
        {
            var section = new Section(key) {id = Guid.NewGuid().ToString()};
            Children.Add(section);

            return section;
        }
        public void read_and_write_a_step_with_plain_values_under_a_section()
        {
            var step = new Step("Add").With("x", "1").With("y", "2").With("sum", "3");
            step.id = Guid.NewGuid().ToString();

            var section = new Section("Math");
            section.Children.Add(step);

            original.Children.Add(section);

            var persistedStep = persisted.Children.Single()
                .ShouldBeOfType<Section>().Children
                .Single().ShouldBeOfType<Step>();

            persistedStep.AssertValuesMatch(step);
        }
 public void SetUp()
 {
     FixtureGraph fixtureGraph =
         new TestRunner(x => x.AddFixture<MathFixture>()).Library.FixtureFor("Math");
     section = fixtureGraph.CreateExample();
 }
        public void read_and_write_a_comment_within_a_section()
        {
            var section = new Section("Math") { id = Guid.NewGuid().ToString() };
            original.Children.Add(section);

            var comment = new Comment { id = Guid.NewGuid().ToString(), Text = "something here" };
            section.Children.Add(comment);

            var persistedComment = persisted.Children.Single()
                .ShouldBeOfType<Section>().Children.Single()
                .ShouldBeOfType<Comment>();

            persistedComment.ShouldNotBeTheSameAs(comment);
            persistedComment.id.ShouldBe(comment.id);
            persistedComment.Text.ShouldBe(comment.Text);
        }
        private void addTest(string name, Action<StepLeaf> configure)
        {
            var test = new Test(name);
            var section = new Section(typeof(SampleTableFixture).GetFixtureAlias());
            test.Add(section);
            var step = new Step("Table1");
            section.Add(step);

            var leaf = step.LeafFor("rows");
            configure(leaf);

            AddTest(name, test);
        }