From ca23d83b1f7bc81c1ec58f1f15c7b7ad7a778f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=9Fra=C5=9F=20Erg=C3=BCn?= <96827714+ugras-ergun-sonarsource@users.noreply.github.com> Date: Fri, 3 Nov 2023 14:47:56 +0100 Subject: [PATCH] fixed the tests --- .../XamlGenerator/RuleXamlBuilderSmokeTest.cs | 22 ++++++------------- .../HtmlXmlCompatibilityHelperTests.cs | 4 ++-- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/Education.UnitTests/XamlGenerator/RuleXamlBuilderSmokeTest.cs b/src/Education.UnitTests/XamlGenerator/RuleXamlBuilderSmokeTest.cs index 50ca9c3ff0..5b70f4ab9b 100644 --- a/src/Education.UnitTests/XamlGenerator/RuleXamlBuilderSmokeTest.cs +++ b/src/Education.UnitTests/XamlGenerator/RuleXamlBuilderSmokeTest.cs @@ -52,29 +52,21 @@ public void Create_CheckAllEmbedded() Console.WriteLine("Checking xaml creation. Count = " + resourceNames.Count()); string[] failures; - using(new AssertIgnoreScope()) // the product code can assert if it encounters an unrecognised tag + using (new AssertIgnoreScope()) // the product code can assert if it encounters an unrecognised tag { failures = resourceNames.Where(x => !ProcessResource(x)) .ToArray(); } - + failures.Should().BeEquivalentTo(new[] { // introduced in sonar-cpp 6.48 "SonarLint.VisualStudio.Rules.Embedded.cpp.S1232.json", - // introduced in dotnet analyzer 9.5 - "SonarLint.VisualStudio.Rules.Embedded.csharpsquid.S4433.json", - // possible issues with EnsureHtmlIsXml regexp in rich rule description, need to investigate (same issue for all 5332 rules) - "SonarLint.VisualStudio.Rules.Embedded.cpp.S5332.json", - "SonarLint.VisualStudio.Rules.Embedded.c.S5332.json", - "SonarLint.VisualStudio.Rules.Embedded.csharpsquid.S5332.json", - "SonarLint.VisualStudio.Rules.Embedded.javascript.S5332.json", - "SonarLint.VisualStudio.Rules.Embedded.typescript.S5332.json", // some issue with diff highlighting "SonarLint.VisualStudio.Rules.Embedded.csharpsquid.S6640.json", }); } - + private static bool ProcessResource(string fullResourceName) { var xamlWriterFactory = new XamlWriterFactory(); @@ -82,14 +74,14 @@ private static bool ProcessResource(string fullResourceName) var xamlGeneratorHelperFactory = new XamlGeneratorHelperFactory(ruleHelpXamlTranslatorFactory); var ruleInfoTranslator = new RuleInfoTranslator(ruleHelpXamlTranslatorFactory, new TestLogger()); var staticXamlStorage = new StaticXamlStorage(ruleHelpXamlTranslatorFactory); - + var simpleXamlBuilder = new SimpleRuleHelpXamlBuilder(ruleHelpXamlTranslatorFactory, xamlGeneratorHelperFactory, xamlWriterFactory); var richXamlBuilder = new RichRuleHelpXamlBuilder(ruleInfoTranslator, xamlGeneratorHelperFactory, staticXamlStorage, xamlWriterFactory); - + try { bool res = false; - + var data = ReadResource(fullResourceName); var jsonRuleInfo = LocalRuleMetadataProvider.RuleInfoJsonDeserializer.Deserialize(data); @@ -104,7 +96,7 @@ private static bool ProcessResource(string fullResourceName) Res(richXamlBuilder.Create(jsonRuleInfo, null)); res = true; } - + return res; // simple || rich should be true } catch (Exception ex) diff --git a/src/Rules.UnitTests/HtmlXmlCompatibilityHelperTests.cs b/src/Rules.UnitTests/HtmlXmlCompatibilityHelperTests.cs index 95c75111e1..ef0a7ae0e0 100644 --- a/src/Rules.UnitTests/HtmlXmlCompatibilityHelperTests.cs +++ b/src/Rules.UnitTests/HtmlXmlCompatibilityHelperTests.cs @@ -29,7 +29,7 @@ public class HtmlXmlCompatibilityHelperTests [TestMethod] public void EnsureHtmlIsXml_ClosesBr() { - HtmlXmlCompatibilityHelper.EnsureHtmlIsXml("Lalala
< br >Hi
").Should().BeEquivalentTo("Lalala
< br />Hi"); + HtmlXmlCompatibilityHelper.EnsureHtmlIsXml("Lalala
< br >Hi").Should().BeEquivalentTo("Lalala
< br />Hi"); } [TestMethod] @@ -45,7 +45,7 @@ public void EnsureHtmlIsXml_ClosesCol() { HtmlXmlCompatibilityHelper.EnsureHtmlIsXml("LalalaHi < col > hello") .Should() - .BeEquivalentTo("LalalaHi < col /> hello "); + .BeEquivalentTo("LalalaHi < col /> hello"); } [TestMethod]