From bc46274bc3a34840905d686db0b9ab2d192b7fc5 Mon Sep 17 00:00:00 2001
From: Gabe Stocco <98900+gfs@users.noreply.github.com>
Date: Mon, 26 Aug 2024 16:44:44 -0700
Subject: [PATCH] Also test multiline case
---
.../SuppressionsTest.cs | 28 ++++++++++++-------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/DevSkim-DotNet/Microsoft.DevSkim.Tests/SuppressionsTest.cs b/DevSkim-DotNet/Microsoft.DevSkim.Tests/SuppressionsTest.cs
index 92b6a49a..608b2ce1 100644
--- a/DevSkim-DotNet/Microsoft.DevSkim.Tests/SuppressionsTest.cs
+++ b/DevSkim-DotNet/Microsoft.DevSkim.Tests/SuppressionsTest.cs
@@ -290,19 +290,23 @@ public void ExecuteSuppresionsForMultilineFormattedFiles(bool preferMultiLine)
///
/// Test that suppressing an issue doesn't change the line break characters
///
- ///
+ /// Character sequence used for line breaks
+ /// Use multiline comments or not
[DataTestMethod]
- [DataRow("\r\n")]
- [DataRow("\n")]
- public void DontPerturbExtantLineBreaks(string lineBreakSequence)
+ [DataRow("\r\n", true)]
+ [DataRow("\r\n", false)]
+ [DataRow("\n", true)]
+ [DataRow("\n", false)]
+ public void DontPerturbExtantLineBreaks(string lineBreakSequence, bool preferMultiLine)
{
- (string basePath, string sourceFile, string sarifPath) = runAnalysis($"MD5{lineBreakSequence}http://contoso.com{lineBreakSequence}", "c");
+ (string basePath, string sourceFile, string sarifPath) = runAnalysis($"MD5\\{lineBreakSequence}http://contoso.com{lineBreakSequence}", "c");
SuppressionCommandOptions opts = new SuppressionCommandOptions
{
Path = basePath,
SarifInput = sarifPath,
- ApplyAllSuppression = true
+ ApplyAllSuppression = true,
+ PreferMultiline = preferMultiLine
};
int resultCode = new SuppressionCommand(opts).Run();
@@ -314,11 +318,14 @@ public void DontPerturbExtantLineBreaks(string lineBreakSequence)
///
/// Test that files don't change at all when they have findings but those rule ids are not selected for suppression
///
- ///
+ /// Character sequence used for line breaks
+ /// Use multiline comments or not
[DataTestMethod]
- [DataRow("\r\n")]
- [DataRow("\n")]
- public void DontChangeFilesWithoutSelectedFindings(string lineBreakSequence)
+ [DataRow("\r\n", true)]
+ [DataRow("\r\n", false)]
+ [DataRow("\n", true)]
+ [DataRow("\n", false)]
+ public void DontChangeFilesWithoutSelectedFindings(string lineBreakSequence, bool preferMultiline)
{
string originalContent = $"MD5{lineBreakSequence}http://contoso.com{lineBreakSequence}";
(string basePath, string sourceFile, string sarifPath) = runAnalysis(originalContent, "c");
@@ -328,6 +335,7 @@ public void DontChangeFilesWithoutSelectedFindings(string lineBreakSequence)
Path = basePath,
SarifInput = sarifPath,
ApplyAllSuppression = false,
+ PreferMultiline = preferMultiline,
RulesToApplyFrom = new string[] { "NotAValidRuleId" } // Don't apply any rules
};