Skip to content

Commit

Permalink
Also test multiline case
Browse files Browse the repository at this point in the history
  • Loading branch information
gfs committed Aug 26, 2024
1 parent 52cf205 commit bc46274
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions DevSkim-DotNet/Microsoft.DevSkim.Tests/SuppressionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,19 +290,23 @@ public void ExecuteSuppresionsForMultilineFormattedFiles(bool preferMultiLine)
/// <summary>
/// Test that suppressing an issue doesn't change the line break characters
/// </summary>
/// <param name="lineBreakSequence"></param>
/// <param name="lineBreakSequence">Character sequence used for line breaks</param>
/// <param name="preferMultiLine">Use multiline comments or not</param>
[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();
Expand All @@ -314,11 +318,14 @@ public void DontPerturbExtantLineBreaks(string lineBreakSequence)
/// <summary>
/// Test that files don't change at all when they have findings but those rule ids are not selected for suppression
/// </summary>
/// <param name="lineBreakSequence"></param>
/// <param name="lineBreakSequence">Character sequence used for line breaks</param>
/// <param name="preferMultiLine">Use multiline comments or not</param>
[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");
Expand All @@ -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
};

Expand Down

0 comments on commit bc46274

Please sign in to comment.