Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Add tests
support2bd854f3e536
diff --git a/src/Core/Grand.SharedKernel/Extensions/FormatText.cs b/src/Core/Grand.SharedKernel/Extensions/FormatText.csindex 28e36b350..48fb93d32 100644--- a/src/Core/Grand.SharedKernel/Extensions/FormatText.cs+++ b/src/Core/Grand.SharedKernel/Extensions/FormatText.cs@@ -12,10 +12,7 @@ namespace Grand.SharedKernel.Extensionstext = WebUtility.HtmlEncode(text);text = text.Replace("\r\n", "<br />");- text = text.Replace("\r", "<br />");- text = text.Replace("\n", "<br />");text = text.Replace("\t", " ");- text = text.Replace(" ", " ");return text;}diff --git a/src/Tests/Grand.SharedKernel.Tests/Extensions/ExtendedLinqTests.cs b/src/Tests/Grand.SharedKernel.Tests/Extensions/ExtendedLinqTests.csnew file mode 100644index 000000000..34f7fd661--- /dev/null+++ b/src/Tests/Grand.SharedKernel.Tests/Extensions/ExtendedLinqTests.cs@@ -0,0 +1,28 @@+using Microsoft.VisualStudio.TestTools.UnitTesting;+using Grand.SharedKernel.Extensions;+using System;+using System.Collections.Generic;+using System.Linq;+using System.Text;+using System.Threading.Tasks;+using Grand.SharedKernel.Tests;++namespace Grand.SharedKernel.Extensions.Tests+{+ [TestClass()]+ public class ExtendedLinqTests+ {+ [TestMethod()]+ public void CartesianProductTest()+ {+ var sampleList = new List<SampleObject>() {+ new SampleObject() { Id = "1", Name = "name1" },+ new SampleObject() { Id = "1", Name = "name2" },+ new SampleObject() { Id = "3", Name = "name3" }+ };++ var cartesianProduct = sampleList.GroupBy(x=>x.Id).CartesianProduct().ToList();+ Assert.AreEqual(2, cartesianProduct.Count);+ }+ }+}\ No newline at end of filediff --git a/src/Tests/Grand.SharedKernel.Tests/Extensions/FormatTextTests.cs b/src/Tests/Grand.SharedKernel.Tests/Extensions/FormatTextTests.csnew file mode 100644index 000000000..2387545ba--- /dev/null+++ b/src/Tests/Grand.SharedKernel.Tests/Extensions/FormatTextTests.cs@@ -0,0 +1,25 @@+using Microsoft.VisualStudio.TestTools.UnitTesting;+using Grand.SharedKernel.Extensions;+using System;+using System.Collections.Generic;+using System.Linq;+using System.Text;+using System.Threading.Tasks;++namespace Grand.SharedKernel.Extensions.Tests+{+ [TestClass()]+ public class FormatTextTests+ {++ [TestMethod()]+ [DataRow("sample <br /> sample ")]+ [DataRow(" sample <br /> sample ")]+ public void ConvertTextTest(string text)+ {+ Assert.IsFalse(FormatText.ConvertText(text).Contains("<br"));+ Assert.IsFalse(FormatText.ConvertText(text).Contains(" "));+ }++ }+}\ No newline at end of filediff --git a/src/Tests/Grand.SharedKernel.Tests/SampleObject.cs b/src/Tests/Grand.SharedKernel.Tests/SampleObject.csnew file mode 100644index 000000000..a323abe3e--- /dev/null+++ b/src/Tests/Grand.SharedKernel.Tests/SampleObject.cs@@ -0,0 +1,8 @@+namespace Grand.SharedKernel.Tests;++public class SampleObject+{+ public string Id { get; set; }+ public string Name { get; set; }++}