Beispiel #1
0
        public void AddElement_DefaultConfiguration_ThrowIncompatibleNumberOfColumns()
        {
            var tabular  = new Tabular();
            var row      = new TabularRow <ILatexElement>();
            var emptyRow = new TabularRow <ILatexElement>();

            row.AddElement(new SimpleText("New element"));
            tabular.AddElement(row);

            Assert.Throws <IncompatibleNumberOfColumnsException>(() => tabular.AddElement(emptyRow));
        }
Beispiel #2
0
        public void GetLatex_TabularWithMultipleRows_CorrectGenerateLatexCode()
        {
            var tabular = new Tabular();
            var row     = new TabularRow <ILatexElement>();

            row.AddElement(new SimpleText("New element"));
            tabular.AddElement(row);
            tabular.AddElement(row);

            AssertExtensions.CompareLatex(tabular.GetLatex(),
                                          @"\begin{tabular}{|c|}
                                                \hline
                                                    New element \\
                                                \hline
                                                    New element \\
                                                \hline
                                            \end{tabular}");
        }
Beispiel #3
0
        public void GetLatex_TabularWithMultipleColumn_DefaultConfiguration()
        {
            var tabular = new Tabular();
            var row     = new TabularRow <ILatexElement>();

            row.AddElement(new SimpleText("New element v1"));
            row.AddElement(new SimpleText("New element v2"));
            tabular.AddElement(row);
            tabular.AddElement(row);

            AssertExtensions.CompareLatex(tabular.GetLatex(),
                                          @"\begin{tabular}{|c|c|}
                                                \hline
                                                    New element v1 & New element v2 \\
                                                \hline
                                                    New element v1 & New element v2 \\
                                                \hline
                                            \end{tabular}");
        }
Beispiel #4
0
        public void AddElement_CustomConfiguration_ThrowIncompatibleNumberOfColumns()
        {
            var configuration = new List <Alligment>()
            {
                Alligment.Left, Alligment.Right
            };

            var tabular = new Tabular(configuration);
            var row     = new TabularRow <ILatexElement>();

            row.AddElement(new SimpleText("New element"));

            Assert.Throws <IncompatibleNumberOfColumnsException>(() => tabular.AddElement(row));
        }
Beispiel #5
0
        public void GetLatex_TabularWithMultipleColumn_CustomConfiguration()
        {
            var configuration = new List <Alligment>()
            {
                Alligment.Left, Alligment.Right
            };

            var tabular = new Tabular(configuration);
            var row     = new TabularRow <ILatexElement>();

            row.AddElement(new SimpleText("New element v1"));
            row.AddElement(new SimpleText("New element v2"));
            tabular.AddElement(row);
            tabular.AddElement(row);

            AssertExtensions.CompareLatex(tabular.GetLatex(),
                                          @"\begin{tabular}{|l|r|}
                                                \hline
                                                    New element v1 & New element v2 \\
                                                \hline
                                                    New element v1 & New element v2 \\
                                                \hline
                                            \end{tabular}");
        }
Beispiel #6
0
        public static string ToLatex <T>(this IEnumerable <T> collection)
        {
            var latexTable   = new Table();
            var latexTabular = new Tabular();

            foreach (var element in collection)
            {
                var latexRow = new TabularRow <ILatexElement>();
                foreach (var property in typeof(T).GetProperties())
                {
                    var latexElement = new SimpleText(property.GetValue(element).ToString());
                    latexRow.AddElement(latexElement);
                }

                latexTabular.AddElement(latexRow);
            }
            latexTable.AddElement(latexTabular);

            return(latexTable.GetLatex());
        }