From e5cc355dfe9ef876875fe649014bf0813d75b7e9 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Fri, 5 Apr 2019 13:39:14 +0100 Subject: [PATCH] unit tests --- src/Ombi.Helpers.Tests/HtmlHelperTests.cs | 41 +++++++++++++++++++++++ src/Ombi.Helpers/HtmlHelper.cs | 1 - 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/Ombi.Helpers.Tests/HtmlHelperTests.cs diff --git a/src/Ombi.Helpers.Tests/HtmlHelperTests.cs b/src/Ombi.Helpers.Tests/HtmlHelperTests.cs new file mode 100644 index 000000000..e03e409b3 --- /dev/null +++ b/src/Ombi.Helpers.Tests/HtmlHelperTests.cs @@ -0,0 +1,41 @@ +using NUnit.Framework; +using System.Collections.Generic; + +namespace Ombi.Helpers.Tests +{ + [TestFixture] + public class HtmlHelperTests + { + [TestCaseSource(nameof(HtmlData))] + public string RemoveHtmlTests(string input) + { + return HtmlHelper.RemoveHtml(input); + } + + public static IEnumerable HtmlData + { + get + { + yield return new TestCaseData("

hi

").Returns("hi").SetName("Simple Html"); + yield return new TestCaseData("

hi

").Returns("hi").SetName("Nested text inside Html"); + yield return new TestCaseData("there is no html here").Returns("there is no html here").SetName("No Html"); + yield return new TestCaseData("there is some html here").Returns("there is some html here").SetName("Html in middle"); + yield return new TestCaseData("there is lots html here").Returns("there is lots html here").SetName("Html in everywhere"); + yield return new TestCaseData("there is some html here").Returns("there is some html here").SetName("Html in with classes"); + yield return new TestCaseData("there is some html here").Returns("there is some html here").SetName("Html in with attribute"); + yield return new TestCaseData("there is some html here").Returns("there is some html here").SetName("Html in with attribute and class"); + } + } + public static IEnumerable OtherData + { + get + { + foreach (var data in HtmlData) + { + yield return data; + } + yield return new TestCaseData("xyz").Returns("xyz").SetName("More Tests"); + } + } + } +} diff --git a/src/Ombi.Helpers/HtmlHelper.cs b/src/Ombi.Helpers/HtmlHelper.cs index 3047fd055..85ca56492 100644 --- a/src/Ombi.Helpers/HtmlHelper.cs +++ b/src/Ombi.Helpers/HtmlHelper.cs @@ -14,6 +14,5 @@ namespace Ombi.Helpers var step2 = Regex.Replace(step1, @"\s{2,}", " "); return step2; } - } } \ No newline at end of file