|
| 1 | +// Copyright (c) by DNN Community |
| 2 | +// |
| 3 | +// DNN Community licenses this file to you under the MIT license. |
| 4 | +// |
| 5 | +// See the LICENSE file in the project root for more information. |
| 6 | +// |
| 7 | +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| 8 | +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
| 9 | +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and |
| 10 | +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
| 11 | +// |
| 12 | +// The above copyright notice and this permission notice shall be included in all copies or substantial portions |
| 13 | +// of the Software. |
| 14 | +// |
| 15 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
| 16 | +// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 18 | +// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 19 | +// DEALINGS IN THE SOFTWARE. |
| 20 | + |
| 21 | +namespace DotNetNuke.Modules.ActiveForumsTests |
| 22 | +{ |
| 23 | + using System.Reflection; |
| 24 | + |
| 25 | + using DotNetNuke.Modules.ActiveForums; |
| 26 | + using NUnit.Framework; |
| 27 | + |
| 28 | + [TestFixture] |
| 29 | + public partial class CodeParserTests : DotNetNuke.Modules.ActiveForumsTests.TestBase |
| 30 | + { |
| 31 | + [TestCase("[CODE]test[/CODE]", "<div class=\"afcodeblock\"><pre><code>test</code></pre></div>")] |
| 32 | + [TestCase("No code here", "No code here")] |
| 33 | + public void ParseCode_ReturnsExpectedHtml(string input, string expected) |
| 34 | + { |
| 35 | + var result = CodeParser.ParseCode(input); |
| 36 | + Assert.That(result, Does.Contain(expected)); |
| 37 | + } |
| 38 | + |
| 39 | + [TestCase("[CODE]test[/CODE]", "<pre><code>test</code></pre>")] |
| 40 | + [TestCase("[/CODE]", "</code></pre>")] |
| 41 | + public void ConvertCodeBrackets_ConvertsBrackets(string input, string expected) |
| 42 | + { |
| 43 | + var result = CodeParser.ConvertCodeBrackets(input); |
| 44 | + Assert.That(result, Does.Contain(expected)); |
| 45 | + } |
| 46 | + |
| 47 | + [TestCase("[CODE]", "[CODE]")] |
| 48 | + [TestCase("&#91;CODE&#93;", "[CODE]")] |
| 49 | + [TestCase("]", "]")] |
| 50 | + [TestCase("&#93;", "]")] |
| 51 | + public void HandleBrackets_ReplacesEntities(string input, string expected) |
| 52 | + { |
| 53 | + var method = typeof(CodeParser).GetMethod("HandleBrackets", BindingFlags.NonPublic | BindingFlags.Static); |
| 54 | + var result = method.Invoke(null, new object[] { input }) as string; |
| 55 | + Assert.That(result, Is.EqualTo(expected)); |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments