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'''\r\n* riga2\r\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\" \r\n|- \r\n! Cells x.1\r\n! Cells x.2\r\n|- \r\n| Cell 1.1\r\n| Cell 1.2\r\n|- \r\n| Cell 2.1\r\n| Cell 2.2\r\n|}\r\n")]
[TestCase("- try
- www.secondtry.com
","# [^www.try.com|try]\r\n# [^www.secondtry.com|www.secondtry.com]\r\n")]
[TestCase("Styled Cell | Normal cell |
Normal cell | Styled cell |
", "{| \r\n|- \r\n| bgcolor=\"Blue\" | Styled Cell\r\n| Normal cell\r\n|- \r\n| Normal cell\r\n| bgcolor=\"Yellow\" | Styled cell\r\n|}\r\n")]
[TestCase("text
", "\r\n==text==\r\n")]
[TestCase("text
", "\r\n===text===\r\n")]
[TestCase("text
", "\r\n====text====\r\n")]
[TestCase("text", "\r\n=====text=====\r\n")]
[TestCase("text", "text")]
[TestCase("text", "text")]
[TestCase("text
", "@@text@@")]
[TestCase("text
", "{{'''text'''}}")]
[TestCase("
text
", "\r\n(((text)))\r\n")]
[TestCase("text
", "\r\ntext\r\n")]
[TestCase("riga1\r\nriga2\r\nriga3", "riga1\r\n'''riga2'''\r\nriga3")]
[TestCase("- 1
- 2
- 3
- 3.1
- 3.2
- 3.2.1
- 3.3
- 4 ciao
", "# 1\r\n# 2\r\n# 3\r\n## 3.1\r\n## 3.2\r\n### 3.2.1\r\n## 3.3\r\n# 4 ciao\r\n\r\n")]
[TestCase("- 1
- 2
", "# 1\r\n# 2\r\n")]
[TestCase("", "* [image|Image|{UP}/AmanuensMicro.png]\r\n* [imageleft||{UP}/DownloadButton.png]\r\n* [imageright|guihojk|{UP}/Checked.png|^www.tututu.tu]\r\n* [imageauto|auto|{UP}/Alert.png]\r\n\r\n")]
[TestCase("", "* 1\r\n* 2\r\n")]
[TestCase("
description
", "[imageright|description|{UP}/Help/Desktop/image.png]\r\n")]
[TestCase("- Punto 1
- Punto 2
- Punto 3
- Punto 4
- Punto 5
", "* Punto 1\r\n* Punto 2\r\n* Punto 3\r\n* Punto 4\r\n* Punto 5\r\n")]
[TestCase("", "* it 1\r\n** 1.1\r\n** 1.2\r\n* it2\r\n")]
[TestCase("", "* it 1\r\n*# 1.1\r\n*# 1.2\r\n* it2\r\n")]
[TestCase("", "* '''1'''\r\n* 2\r\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]\r\n")]
[TestCase("
", "[image|inlineimage|{UP(MainPage)}image.png]\r\n")]
[TestCase("
", "[image|description|{UP(MainPage)}image.png|^www.google.it]\r\n")]
[TestCase(" autoalign |
", "[imageauto|autoalign|{UP(MainPage)}image.png]\r\n")]
[TestCase(" Auto align |
", "[imageauto|Auto align|{UP(MainPage)}image.png|www.link.com]\r\n")]
public void PlainTest(string input, string output) {
Assert.AreEqual(output, ReverseFormatter.ReverseFormat(input));
}
}
}