コード例 #1
0
        public void MultiplicationTableTest()
        {
            var content = "{| class=\"wikitable\" style=\"text-align:center\"" + "\n" +
                          "|+Multiplication table" + "\n" +
                          "|-" + "\n" +
                          "! × !! 1 !! 2 !! 3" + "\n" +
                          "|-" + "\n" +
                          "! 1" + "\n" +
                          "| 1 || 2 || 3" + "\n" +
                          "|-" + "\n" +
                          "! 2" + "\n" +
                          "| 2 || 4 || 6" + "\n" +
                          "|-" + "\n" +
                          "! 3" + "\n" +
                          "| 3 || 6 || 9" + "\n" +
                          "|-" + "\n" +
                          "! 4" + "\n" +
                          "| 4 || 8 || 12" + "\n" +
                          "|-" + "\n" +
                          "! 5" + "\n" +
                          "| 5 || 10 || 15" + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result =
                "<table class=\"wikitable\" style=\"text-align:center\"><caption>Multiplication table</caption><tr><th>&times;</th><th>1</th><th>2</th><th>3</th></tr><tr><th>1</th><td>1</td><td>2</td><td>3</td></tr><tr><th>2</th><td>2</td><td>4</td><td>6</td></tr><tr><th>3</th><td>3</td><td>6</td><td>9</td></tr><tr><th>4</th><td>4</td><td>8</td><td>12</td></tr><tr><th>5</th><td>5</td><td>10</td><td>15</td></tr></table>" +
                "\n";

            Assert.IsTrue(result.Equals(table));
        }
コード例 #2
0
        public void Pre()
        {
            var content   = "{{{{replace me}}}}";
            var formatted = new WikiFormatter().Format(content);
            var result    = "<pre>replace me</pre>" + "\n";

            Assert.IsTrue(result.Equals(formatted));
        }
コード例 #3
0
        public void Striked()
        {
            var content   = "--replace me--";
            var formatted = new WikiFormatter().Format(content);
            var result    = "<strike>replace me</strike>" + "\n";

            Assert.IsTrue(result.Equals(formatted));
        }
コード例 #4
0
        public void Underlined()
        {
            var content   = "__replace me__";
            var formatted = new WikiFormatter().Format(content);
            var result    = "<u>replace me</u>" + "\n";

            Assert.IsTrue(result.Equals(formatted));
        }
コード例 #5
0
        public void Italic()
        {
            var content   = "''replace me''";
            var formatted = new WikiFormatter().Format(content);
            var result    = "<i>replace me</i>" + "\n";

            Assert.IsTrue(result.Equals(formatted));
        }
コード例 #6
0
        public void Box()
        {
            var content   = "(((replace me)))";
            var formatted = new WikiFormatter().Format(content);
            var result    = @"<table class=""box"" cellpadding=""0"" cellspacing=""0""><tr><td>replace me</td></tr></table>" +
                            "\n";

            Assert.IsTrue(result.Equals(formatted));
        }
コード例 #7
0
        public void TableWithCaptionAndTwoRows()
        {
            var content = "{|" + "\n" +
                          "|+ The table's caption" + "\n" +
                          "|-" + "\n" +
                          "|-" + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result = "<table><caption>The table's caption</caption><tr></tr><tr></tr></table>" + "\n";

            Assert.IsTrue(result.Equals(table));
        }
コード例 #8
0
        public void EmptyTableWithCaption()
        {
            var content = "{|" + "\n" +
                          "|+ caption" + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result = "<table>" +
                         "<caption>caption</caption>" +
                         "</table>" + "\n";

            Assert.IsTrue(result.Equals(table));
        }
コード例 #9
0
        /// <summary>
        /// Pulls the http stream through the WikiFormatter filter.
        /// </summary>
        /// <param name="buffer">The content stream</param>
        /// <param name="offset">Start of the stream</param>
        /// <param name="count">Lenght of the stream</param>
        public override void Write(byte[] buffer, int offset, int count)
        {
            if (Closed)
            {
                throw new ObjectDisposedException("WikiTransformFilter");
            }

            var content = Encoding.Default.GetString(buffer, offset, count);

            var wikiFormatter = new WikiFormatter();

            content = wikiFormatter.Format(content);

            var output = Encoding.Default.GetBytes(content);

            BaseStream.Write(output, 0, output.Length);
        }
コード例 #10
0
        public void ColorTest()
        {
            var content = "{|" + "\n" +
                          "| style=\"background:red; color:white\" | abc" + "\n" +
                          "| def" + "\n" +
                          "| bgcolor=\"red\" | <font color=\"white\"> ghi </font>" + "\n" +
                          "| jkl" + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result =
                "<table><tr><td style=\"background:red; color:white\">abc</td><td>def</td><td bgcolor=\"red\"><font color=\"white\"> ghi </font></td><td>jkl</td></tr></table>" +
                "\n";

            Assert.IsTrue(result.Equals(table));
        }
コード例 #11
0
        public void MoreMarkUpTesting()
        {
            var content = "{| style=\"background:yellow; color:green\"" + "\n" +
                          "|- " + "\n" +
                          "| abc || def || ghi" + "\n" +
                          "|- style=\"background:red; color:white\"" + "\n" +
                          "| jkl || mno || pqr" + "\n" +
                          "|-" + "\n" +
                          "| stu || style=\"background:silver\" | vwx || yz" + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result =
                "<table style=\"background:yellow; color:green\"><tr><td>abc</td><td>def</td><td>ghi</td></tr><tr style=\"background:red; color:white\"><td>jkl</td><td>mno</td><td>pqr</td></tr><tr><td>stu</td><td style=\"background:silver\">vwx</td><td>yz</td></tr></table>" +
                "\n";

            Assert.IsTrue(result.Equals(table));
        }
コード例 #12
0
        public void WidthHeightTest()
        {
            var content = "{| style=\"width:75%; height:200px\" border=\"1\"" + "\n" +
                          "|- " + "\n" +
                          "| abc || def || ghi" + "\n" +
                          "|- style=\"height:100px\" " + "\n" +
                          "| jkl || style=\"width:200px\" |mno || pqr" + "\n" +
                          "|-" + "\n" +
                          "| stu || vwx || yz" + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result =
                "<table style=\"width:75%; height:200px\" border=\"1\"><tr><td>abc</td><td>def</td><td>ghi</td></tr><tr style=\"height:100px\"><td>jkl</td><td style=\"width:200px\">mno</td><td>pqr</td></tr><tr><td>stu</td><td>vwx</td><td>yz</td></tr></table>" +
                "\n";

            Assert.IsTrue(result.Equals(table));
        }
コード例 #13
0
        public void ColumnWidthTest()
        {
            var content = "{| border=\"1\" cellpadding=\"2\"" + "\n" +
                          "!width=\"50\"|Name" + "\n" +
                          "!width=\"225\"|Effect" + "\n" +
                          "!width=\"225\"|Games Found In" + "\n" +
                          "|-" + "\n" +
                          "|Poké Ball || Regular Poké Ball || All Versions" + "\n" +
                          "|-" + "\n" +
                          "|Great Ball || Better than a Poké Ball || All Versions" + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result =
                "<table border=\"1\" cellpadding=\"2\"><tr><th width=\"50\">Name</th><th width=\"225\">Effect</th><th width=\"225\">Games Found In</th></tr><tr><td>Poké Ball</td><td>Regular Poké Ball</td><td>All Versions</td></tr><tr><td>Great Ball</td><td>Better than a Poké Ball</td><td>All Versions</td></tr></table>" +
                "\n";

            Assert.IsTrue(result.Equals(table));
        }
コード例 #14
0
        public void TableWithCaptionAndTwoRowsAndCells()
        {
            var content = "{|" + "\n" +
                          "|+ The table's caption" + "\n" +
                          "|-" + "\n" +
                          "|Cell 1 || Cell 2 || Cell 3" + "\n" +
                          "|-" + "\n" +
                          "|Cell A " + "\n" +
                          "|Cell B" + "\n" +
                          "|Cell C" + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result =
                "<table><caption>The table's caption</caption><tr><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td></tr><tr><td>Cell A</td><td>Cell B</td><td>Cell C</td></tr></table>" +
                "\n";

            Assert.IsTrue(result.Equals(table));
        }
コード例 #15
0
        public void TableWithColumnHeadings()
        {
            var content = "{|" + "\n" +
                          "|+ The table's caption" + "\n" +
                          "! Column heading 1 !! Column heading 2 !! Column heading 3" + "\n" +
                          "|-" + "\n" +
                          "|Cell 1 || Cell 2 || Cell 3" + "\n" +
                          "|-" + "\n" +
                          "|Cell A" + "\n" +
                          "|Cell B" + "\n" +
                          "|Cell C" + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result =
                "<table><caption>The table's caption</caption><tr><th>Column heading 1</th><th>Column heading 2</th><th>Column heading 3</th></tr><tr><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td></tr><tr><td>Cell A</td><td>Cell B</td><td>Cell C</td></tr></table>" +
                "\n";

            Assert.IsTrue(result.Equals(table));
        }
コード例 #16
0
        public void VerticalAlignment()
        {
            var content = "{| border=\"1\" cellpadding=\"2\"" + "\n" +
                          "|-valign=\"top\"" + "\n" +
                          "|width=\"10%\"|<b>Row heading</b>" + "\n" +
                          "|width=\"70%\"|A longer piece of text. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." +
                          "\n" +
                          "|width=\"20%\"|A shorter piece of text." + "\n" +
                          "|-valign=\"top\"" + "\n" +
                          "|<b>Row heading</b>" + "\n" +
                          "|A longer piece of text.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." +
                          "\n" +
                          "|A shorter piece of text." + "\n" +
                          "|}";

            var table = new WikiFormatter().Format(content);

            var result =
                "<table border=\"1\" cellpadding=\"2\"><tr valign=\"top\"><td width=\"10%\"><b>Row heading</b></td><td width=\"70%\">A longer piece of text. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</td><td width=\"20%\">A shorter piece of text.</td></tr><tr valign=\"top\"><td><b>Row heading</b></td><td>A longer piece of text.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</td><td>A shorter piece of text.</td></tr></table>" +
                "\n";

            Assert.IsTrue(result.Equals(table));
        }