You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

EmphasisTests.cs 4.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using NUnit.Framework;
  6. using MarkdownDeep;
  7. namespace MarkdownDeepTests
  8. {
  9. [TestFixture]
  10. public class EmphasisTests
  11. {
  12. [SetUp]
  13. public void SetUp()
  14. {
  15. f = new SpanFormatter(new Markdown());
  16. }
  17. SpanFormatter f;
  18. [Test]
  19. public void PlainText()
  20. {
  21. Assert.AreEqual("This is plain text",
  22. f.Format("This is plain text"));
  23. }
  24. [Test]
  25. public void em_simple()
  26. {
  27. Assert.AreEqual("This is <em>em</em> text",
  28. f.Format("This is *em* text"));
  29. Assert.AreEqual("This is <em>em</em> text",
  30. f.Format("This is _em_ text"));
  31. }
  32. [Test]
  33. public void strong_simple()
  34. {
  35. Assert.AreEqual("This is <strong>strong</strong> text",
  36. f.Format("This is **strong** text"));
  37. Assert.AreEqual("This is <strong>strong</strong> text",
  38. f.Format("This is __strong__ text"));
  39. }
  40. [Test]
  41. public void em_strong_lead_tail()
  42. {
  43. Assert.AreEqual("<strong>strong</strong>",
  44. f.Format("__strong__"));
  45. Assert.AreEqual("<strong>strong</strong>",
  46. f.Format("**strong**"));
  47. Assert.AreEqual("<em>em</em>",
  48. f.Format("_em_"));
  49. Assert.AreEqual("<em>em</em>",
  50. f.Format("*em*"));
  51. }
  52. [Test]
  53. public void strongem()
  54. {
  55. Assert.AreEqual("<strong><em>strongem</em></strong>",
  56. f.Format("***strongem***"));
  57. Assert.AreEqual("<strong><em>strongem</em></strong>",
  58. f.Format("___strongem___"));
  59. }
  60. [Test]
  61. public void no_strongem_if_spaces()
  62. {
  63. Assert.AreEqual("pre * notem *",
  64. f.Format("pre * notem *"));
  65. Assert.AreEqual("pre ** notstrong **",
  66. f.Format("pre ** notstrong **"));
  67. Assert.AreEqual("pre *Apples *Bananas *Oranges",
  68. f.Format("pre *Apples *Bananas *Oranges"));
  69. }
  70. [Test]
  71. public void em_in_word()
  72. {
  73. Assert.AreEqual("un<em>frigging</em>believable",
  74. f.Format("un*frigging*believable"));
  75. }
  76. [Test]
  77. public void strong_in_word()
  78. {
  79. Assert.AreEqual("un<strong>frigging</strong>believable",
  80. f.Format("un**frigging**believable"));
  81. }
  82. [Test]
  83. public void combined_1()
  84. {
  85. Assert.AreEqual("<strong><em>test test</em></strong>",
  86. f.Format("***test test***"));
  87. }
  88. [Test]
  89. public void combined_2()
  90. {
  91. Assert.AreEqual("<strong><em>test test</em></strong>",
  92. f.Format("___test test___"));
  93. }
  94. [Test]
  95. public void combined_3()
  96. {
  97. Assert.AreEqual("<em>test <strong>test</strong></em>",
  98. f.Format("*test **test***"));
  99. }
  100. [Test]
  101. public void combined_4()
  102. {
  103. Assert.AreEqual("<strong>test <em>test</em></strong>",
  104. f.Format("**test *test***"));
  105. }
  106. [Test]
  107. public void combined_5()
  108. {
  109. Assert.AreEqual("<strong><em>test</em> test</strong>",
  110. f.Format("***test* test**"));
  111. }
  112. [Test]
  113. public void combined_6()
  114. {
  115. Assert.AreEqual("<em><strong>test</strong> test</em>",
  116. f.Format("***test** test*"));
  117. }
  118. [Test]
  119. public void combined_7()
  120. {
  121. Assert.AreEqual("<strong><em>test</em> test</strong>",
  122. f.Format("***test* test**"));
  123. }
  124. [Test]
  125. public void combined_8()
  126. {
  127. Assert.AreEqual("<strong>test <em>test</em></strong>",
  128. f.Format("**test *test***"));
  129. }
  130. [Test]
  131. public void combined_9()
  132. {
  133. Assert.AreEqual("<em>test <strong>test</strong></em>",
  134. f.Format("*test **test***"));
  135. }
  136. [Test]
  137. public void combined_10()
  138. {
  139. Assert.AreEqual("<em>test <strong>test</strong></em>",
  140. f.Format("_test __test___"));
  141. }
  142. [Test]
  143. public void combined_11()
  144. {
  145. Assert.AreEqual("<strong>test <em>test</em></strong>",
  146. f.Format("__test _test___"));
  147. }
  148. [Test]
  149. public void combined_12()
  150. {
  151. Assert.AreEqual("<strong><em>test</em> test</strong>",
  152. f.Format("___test_ test__"));
  153. }
  154. [Test]
  155. public void combined_13()
  156. {
  157. Assert.AreEqual("<em><strong>test</strong> test</em>",
  158. f.Format("___test__ test_"));
  159. }
  160. [Test]
  161. public void combined_14()
  162. {
  163. Assert.AreEqual("<strong><em>test</em> test</strong>",
  164. f.Format("___test_ test__"));
  165. }
  166. [Test]
  167. public void combined_15()
  168. {
  169. Assert.AreEqual("<strong>test <em>test</em></strong>",
  170. f.Format("__test _test___"));
  171. }
  172. [Test]
  173. public void combined_16()
  174. {
  175. Assert.AreEqual("<em>test <strong>test</strong></em>",
  176. f.Format("_test __test___"));
  177. }
  178. [Test]
  179. public void combined_17()
  180. {
  181. var fExtra = new SpanFormatter(new Markdown() { ExtraMode = true });
  182. Assert.AreEqual("<strong>Bold</strong> <em>Italic</em>",
  183. fExtra.Format("__Bold__ _Italic_"));
  184. }
  185. [Test]
  186. public void combined_18()
  187. {
  188. var fExtra = new SpanFormatter(new Markdown() { ExtraMode = true });
  189. Assert.AreEqual("<em>Emphasis</em>, trailing",
  190. fExtra.Format("_Emphasis_, trailing"));
  191. }
  192. }
  193. }