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 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 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 needs_renumbering_is_true_because_there_are_duplicate_ids() { 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.NeedsToBeRenumbered().ShouldBeTrue(); }
public void needs_renumbering_negative() { 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); spec.NeedsToBeRenumbered().ShouldBeFalse(); }
public void can_escape_pipe_bar_in_table_data() { original.name = "Some spec"; var section = new Section("Math"); var tableStep = section.AddStep("table"); var rows = tableStep.AddCollection("rows"); rows.AddStep("row").With("a", "1"); rows.AddStep("row").With("a", "2"); rows.AddStep("row").With("a", "1|2|3"); original.Children.Add(section); compare(original, persisted); }
public void can_handle_multi_line_comment_within_a_section() { original.name = "Some spec"; var comment = new Comment { Text = @"hello, how are you today? ** Well, thank you" }; var section = new Section("MyThing"); section.AddStep("Go"); section.Children.Add(comment); section.AddStep("Stop"); original.Children.Add(section); compare(original, persisted); original.Children.Add(new Comment {Text = "Hey\nyou!"}); }