using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace ScrewTurn.Wiki.Tests {
[TestFixture]
public class ReverseFormatterTests {
[Test]
[TestCase("text", "'''text'''")]
[TestCase("text", "'''text'''")]
[TestCase("text", "''text''")]
[TestCase("
", "* prova '''pippo'''\n* riga2\n")]
[TestCase("text", "''text''")]
[TestCase("text", "__text__")]
[TestCase("text", "--text--")]
[TestCase("Cells x.1 | Cells x.2 |
---|
Cell 1.1 | Cell 1.2 |
Cell 2.1 | Cell 2.2 |
", "{| border=\"1\" bgcolor=\"LightBlue\" \n|- \n! Cells x.1\n! Cells x.2\n|- \n| Cell 1.1\n| Cell 1.2\n|- \n| Cell 2.1\n| Cell 2.2\n|}\n")]
[TestCase("- try
- www.secondtry.com
","# [^www.try.com|try]\n# [^www.secondtry.com|www.secondtry.com]\n")]
[TestCase("Styled Cell | Normal cell |
Normal cell | Styled cell |
", "{| \n|- \n| bgcolor=\"Blue\" | Styled Cell\n| Normal cell\n|- \n| Normal cell\n| bgcolor=\"Yellow\" | Styled cell\n|}\n")]
[TestCase("text
", "==text==\n")]
[TestCase("text
", "===text===\n")]
[TestCase("text
", "====text====\n")]
[TestCase("text", "=====text=====\n")]
[TestCase("inline code - monospace font
", "{{inline code - monospace font}}")]
[TestCase("", "----\n")]
[TestCase("
", "----\n")]
[TestCase("text", "text")]
[TestCase("text", "text")]
[TestCase("text
", "@@text@@")]
[TestCase("
text
", ": text\n")]
[TestCase("Help.Wiki", "[c:Help.Wiki|Help.Wiki]")]
[TestCase("text
", "{{'''text'''}}")]
[TestCase("text
", "(((text)))\n")]
[TestCase("text
", "text\n")]
[TestCase("riga1\nriga2\nriga3", "riga1\n'''riga2'''\nriga3")]
[TestCase("- 1
- 2
- 3
- 3.1
- 3.2
- 3.2.1
- 3.3
- 4 ciao
", "# 1\n# 2\n# 3\n## 3.1\n## 3.2\n### 3.2.1\n## 3.3\n# 4 ciao\n\n")]
[TestCase("- 1
- 2
", "# 1\n# 2\n")]
[TestCase("", "* [image|Image|{UP}/AmanuensMicro.png]\n* [imageleft||{UP}/DownloadButton.png]\n* [imageright|guihojk|{UP}/Checked.png|^www.tututu.tu]\n* [imageauto|auto|{UP}/Alert.png]\n\n")]
[TestCase("", "* 1\n* 2\n")]
[TestCase("
description
", "[imageright|description|{UP}/Help/Desktop/image.png]\n")]
[TestCase("- Punto 1
- Punto 2
- Punto 3
- Punto 4
- Punto 5
", "* Punto 1\n* Punto 2\n* Punto 3\n* Punto 4\n* Punto 5\n")]
[TestCase("", "* it 1\n** 1.1\n** 1.2\n* it2\n")]
[TestCase("", "* it 1\n*# 1.1\n*# 1.2\n* it2\n")]
[TestCase("", "* '''1'''\n* 2\n")]
[TestCase("I'm an anchor", "[anchor|#init]I'm an anchor")]
[TestCase("This recall an anchor", "[#init|This recall an anchor]")]
[TestCase("BIG TITLE", "[^google.com|BIG TITLE]")]
[TestCase("try to esc tag", "try to esc tag")]
[TestCase("
leftalign
", "[imageleft|leftalign|{UP(MainPage)}image.png|^www.link.com]\n")]
[TestCase("
", "[image|inlineimage|{UP(MainPage)}image.png]\n")]
[TestCase("
", "[image|description|{UP(MainPage)}image.png|^www.google.it]\n")]
[TestCase(" autoalign |
", "[imageauto|autoalign|{UP(MainPage)}image.png]\n")]
[TestCase(" Auto align |
", "[imageauto|Auto align|{UP(MainPage)}image.png|www.link.com]\n")]
[TestCase("Styled TableThis is a cell | This is a cell | This is a cell |
Styled cell | Styled cell | Normal cell |
Normal | Normal | Download |
","{| cellspacing=\"0\" cellpadding=\"2\" style=\"background-color: #EEEEEE; margin: 0px auto;\" \n|+ Styled Table\n|- style=\"background-color: #990000; color: #FFFFFF;\" \n| This is a cell\n| This is a cell\n| This is a cell\n|- \n| style=\"background-color: #000000; color: #CCCCCC;\" | Styled cell\n| style=\"border: solid 1px #FF0000;\" | Styled cell\n| '''Normal cell'''\n|- \n| Normal\n| Normal\n| [Download.ashx|Download]\n|}\n")]
[TestCase("block code - [WikiMarkup] is ignored
", "@@block code - [WikiMarkup] is ignored@@")]
public void PlainTest(string input, string output) {
Assert.AreEqual(output, ReverseFormatter.ReverseFormat(input));
}
}
}