Пример #1
0
        public void Should_Write_Table_Cell_With_Custom_Value()
        {
            var expected = new string[]
            {
                "| unit_type | miles |",
                "| unit_type | miles |",
                string.Empty,
                "| my custom table |",
                string.Empty,
            };
            var sb = new StringBuilder();

            using (var subject = new IonWriter(new StringWriter(sb)))
            {
                subject.WriteTableCell((tw) => tw.Write("unit_type"));
                subject.WriteTableCell((tw) => tw.Write("miles"), true);
                subject.WriteTableCell("unit_type");
                subject.WriteTableCell("miles", true);
                Assert.AreEqual(WriterState.TableRow, subject.State);
                subject.WriteEmptyLine();
                Assert.AreEqual(WriterState.None, subject.State);
                subject.WriteTableCell((tw) => tw.Write("my custom table"), true);
                Assert.AreEqual(WriterState.TableRow, subject.State);
            }
            CollectionAssert.AreEquivalent(expected, sb.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
        }
Пример #2
0
        public void IIonWriter_WriteTableCell_Throws_InvalidTableCellDataException()
        {
            var sb = new StringBuilder();

            using (var subject = new IonWriter(new StringWriter(sb)))
            {
                Assert.Throws <InvalidTableCellDataException>(() => subject.WriteTableCell("\n"));
                Assert.Throws <InvalidTableCellDataException>(() => subject.WriteTableCell("|"));

                Assert.Throws <InvalidTableCellDataException>(() => subject.WriteTableCell("\n".ToCharArray(), 0, 1));
                Assert.Throws <InvalidTableCellDataException>(() => subject.WriteTableCell("|".ToCharArray(), 0, 1));
            }
        }