public void reads_sentence_cells_with_quoted_options() { var result = FixtureReader.ReadFrom(@" ## a key ### a title |cell|default|options| |first|default|hello, ""goodbye, friend"", ciao|"); result.grammars.ShouldNotBeNull(); result.grammars.Length.ShouldBe(1); result.grammars[0].ShouldBeOfType <Sentence>(); var sentence = result.grammars[0].As <Sentence>(); sentence.cells.ShouldNotBeNull(); sentence.cells.Length.ShouldBe(1); var cell = sentence.cells[0]; cell.Key.ShouldBe("first"); cell.options.ShouldNotBeNull(); cell.options.Length.ShouldBe(3); cell.options[0].value.ShouldBe("hello"); cell.options[1].value.ShouldBe("goodbye, friend"); cell.options[2].value.ShouldBe("ciao"); }
public void reads_table_multiple_columns() { var result = FixtureReader.ReadFrom(@" ## a key ### a title |table|column 1|column 2| |default|one|two| |editor|text||"); result.grammars.ShouldNotBeNull(); result.grammars.Length.ShouldBe(1); result.grammars[0].ShouldBeOfType <Table>(); var table = result.grammars[0].As <Table>(); table.cells.ShouldNotBeNull(); table.cells.Length.ShouldBe(2); var cell = table.cells[0]; cell.Key.ShouldBe("column 1"); cell.DefaultValue.ShouldBe("one"); cell.editor.ShouldBe("text"); cell = table.cells[1]; cell.Key.ShouldBe("column 2"); cell.DefaultValue.ShouldBe("two"); }
private void roundTrip <T>() where T : Fixture, new() { var fixture = new T(); var model = fixture.Compile(CellHandling.Basic()); var markdown1 = FixtureWriter.Write(model); Console.WriteLine("Fixture " + typeof(T).Name); Console.WriteLine("----------------------------------------------------------------"); Console.WriteLine(markdown1); Console.WriteLine("----------------------------------------------------------------"); Console.WriteLine(); Console.WriteLine(); var model2 = FixtureReader.ReadFrom(markdown1); var markdown2 = FixtureWriter.Write(model2); var grammars1 = model.grammars.Where(x => x.key != "TODO").OrderBy(x => x.key).Select(x => x.key); var grammars2 = model2.grammars.OrderBy(x => x.key).Select(x => x.key); grammars2.ShouldHaveTheSameElementsAs(grammars1.ToArray()); markdown2.ShouldBe(markdown1); }
public void reads_sentence_cells_with_options() { var result = FixtureReader.ReadFrom(@" ## a key |sentence|first | |default |somthing | |options |hello, goodbye, ciao|"); result.grammars.ShouldNotBeNull(); result.grammars.Length.ShouldBe(1); result.grammars[0].ShouldBeOfType <Sentence>(); var sentence = result.grammars[0].As <Sentence>(); sentence.cells.ShouldNotBeNull(); sentence.cells.Length.ShouldBe(1); var cell = sentence.cells[0]; cell.Key.ShouldBe("first"); cell.options.ShouldNotBeNull(); cell.options.Length.ShouldBe(3); cell.options[0].value.ShouldBe("hello"); cell.options[1].value.ShouldBe("goodbye"); cell.options[2].value.ShouldBe("ciao"); }
public void can_derive_a_title_from_the_key() { var result = FixtureReader.ReadFrom(@" ## SomeKindOfKey "); result.grammars.Single().ShouldBeOfType <Sentence>() .format.ShouldBe("Some Kind Of Key"); }
public void reads_sentence() { var result = FixtureReader.ReadFrom(@" ## a key ### a title"); result.grammars.ShouldNotBeNull(); result.grammars.Length.ShouldBe(1); result.grammars[0].ShouldBeOfType <Sentence>(); result.grammars[0].As <Sentence>().format.ShouldBe("a title"); result.grammars[0].As <Sentence>().key.ShouldBe("a key"); }
public void can_fix_up_a_key_with_spaces() { var result = FixtureReader.ReadFrom(@" ## Some Kind Of Key "); var sentence = result.grammars.Single().ShouldBeOfType <Sentence>(); sentence .format.ShouldBe("Some Kind Of Key"); sentence.key.ShouldBe("SomeKindOfKey"); }
public void reads_table() { var result = FixtureReader.ReadFrom(@" ## a key ### a title |table|col1|"); result.grammars.ShouldNotBeNull(); result.grammars.Length.ShouldBe(1); result.grammars[0].ShouldBeOfType <Table>(); var table = result.grammars[0].As <Table>(); table.cells.ShouldNotBeNull(); table.cells.Length.ShouldBe(1); var cell = table.cells[0]; cell.Key.ShouldBe("col1"); }
public void reads_sentence_cells() { var result = FixtureReader.ReadFrom(@" ## a key |cell|default| |first|default|"); result.grammars.ShouldNotBeNull(); result.grammars.Length.ShouldBe(1); result.grammars[0].ShouldBeOfType <Sentence>(); var sentence = result.grammars[0].As <Sentence>(); sentence.cells.ShouldNotBeNull(); sentence.cells.Length.ShouldBe(1); var cell = sentence.cells[0]; cell.Key.ShouldBe("first"); cell.DefaultValue.ShouldBe("default"); }
public void reads_sentence_cells_with_result() { var result = FixtureReader.ReadFrom(@" ## a key ### a title |cell|result| |first|result|"); result.grammars.ShouldNotBeNull(); result.grammars.Length.ShouldBe(1); result.grammars[0].ShouldBeOfType <Sentence>(); var sentence = result.grammars[0].As <Sentence>(); sentence.cells.ShouldNotBeNull(); sentence.cells.Length.ShouldBe(1); var cell = sentence.cells[0]; cell.Key.ShouldBe("first"); cell.result.ShouldBe("result"); }
public void reads_sentence_cells_with_editor() { var result = FixtureReader.ReadFrom(@" ## a key ### a title |sentence|first | |editor |bigtext | "); result.grammars.ShouldNotBeNull(); result.grammars.Length.ShouldBe(1); result.grammars[0].ShouldBeOfType <Sentence>(); var sentence = result.grammars[0].As <Sentence>(); sentence.cells.ShouldNotBeNull(); sentence.cells.Length.ShouldBe(1); var cell = sentence.cells[0]; cell.Key.ShouldBe("first"); cell.editor.ShouldBe("bigtext"); }
public void reads_title() { var result = FixtureReader.ReadFrom(@"# a title"); result.title.ShouldBe("a title"); }