From da8db1590f05c8a4380dd38c953a14fbe697490c Mon Sep 17 00:00:00 2001 From: Simon Cropp <simon.cropp@gmail.com> Date: Sat, 3 Feb 2024 20:52:22 +1100 Subject: [PATCH] add missing scrubbing overloads (#1138) --- src/Directory.Build.props | 2 +- src/Verify/SettingsTask_Scrubbing.cs | 90 ++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7ec3650ca8..82ecd2e09c 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ <Project> <PropertyGroup> <NoWarn>CS1591;CS0649;xUnit1026;xUnit1013;CS1573;VerifyTestsProjectDir;VerifySetParameters</NoWarn> - <Version>23.0.1</Version> + <Version>23.1.0</Version> <ImplicitUsings>enable</ImplicitUsings> <LangVersion>preview</LangVersion> <AssemblyVersion>1.0.0</AssemblyVersion> diff --git a/src/Verify/SettingsTask_Scrubbing.cs b/src/Verify/SettingsTask_Scrubbing.cs index 6de6a58c7c..0826f0be82 100644 --- a/src/Verify/SettingsTask_Scrubbing.cs +++ b/src/Verify/SettingsTask_Scrubbing.cs @@ -32,6 +32,16 @@ public SettingsTask ScrubInlineGuids(ScrubberLocation location = ScrubberLocatio return this; } + /// <summary> + /// Replace inline <see cref="Guid" />s with a placeholder. + /// </summary> + [Pure] + public SettingsTask ScrubInlineGuids(string extension, ScrubberLocation location = ScrubberLocation.First) + { + CurrentSettings.ScrubInlineGuids(extension, location); + return this; + } + /// <summary> /// Disables counting of dates. /// </summary> @@ -86,6 +96,16 @@ public SettingsTask ScrubMachineName(ScrubberLocation location = ScrubberLocatio return this; } + /// <summary> + /// Remove the <see cref="Environment.MachineName" /> from the test results. + /// </summary> + [Pure] + public SettingsTask ScrubMachineName(string extension, ScrubberLocation location = ScrubberLocation.First) + { + CurrentSettings.ScrubMachineName(extension, location); + return this; + } + /// <summary> /// Remove the <see cref="Environment.UserName" /> from the test results. /// </summary> @@ -96,6 +116,16 @@ public SettingsTask ScrubUserName(ScrubberLocation location = ScrubberLocation.F return this; } + /// <summary> + /// Remove the <see cref="Environment.UserName" /> from the test results. + /// </summary> + [Pure] + public SettingsTask ScrubUserName(string extension,ScrubberLocation location = ScrubberLocation.First) + { + CurrentSettings.ScrubUserName(extension, location); + return this; + } + /// <summary> /// Remove any lines containing any of <paramref name="stringToMatch" /> from the test results. /// </summary> @@ -105,6 +135,15 @@ public SettingsTask ScrubLinesContaining(StringComparison comparison, params str CurrentSettings.ScrubLinesContaining(comparison, stringToMatch); return this; } + /// <summary> + /// Remove any lines containing any of <paramref name="stringToMatch" /> from the test results. + /// </summary> + [Pure] + public SettingsTask ScrubLinesContaining(string extension, StringComparison comparison, params string[] stringToMatch) + { + CurrentSettings.ScrubLinesContaining(extension, comparison, stringToMatch); + return this; + } /// <summary> /// Remove any lines containing any of <paramref name="stringToMatch" /> from the test results. @@ -116,6 +155,16 @@ public SettingsTask ScrubLinesContaining(StringComparison comparison, ScrubberLo return this; } + /// <summary> + /// Remove any lines containing any of <paramref name="stringToMatch" /> from the test results. + /// </summary> + [Pure] + public SettingsTask ScrubLinesContaining(string extension, StringComparison comparison, ScrubberLocation location = ScrubberLocation.First, params string[] stringToMatch) + { + CurrentSettings.ScrubLinesContaining(extension, comparison, location, stringToMatch); + return this; + } + /// <summary> /// Remove any lines matching <paramref name="removeLine" /> from the test results. /// </summary> @@ -126,6 +175,16 @@ public SettingsTask ScrubLines(Func<string, bool> removeLine, ScrubberLocation l return this; } + /// <summary> + /// Remove any lines matching <paramref name="removeLine" /> from the test results. + /// </summary> + [Pure] + public SettingsTask ScrubLines(string extension, Func<string, bool> removeLine, ScrubberLocation location = ScrubberLocation.First) + { + CurrentSettings.ScrubLines(extension, removeLine, location); + return this; + } + /// <summary> /// Scrub lines with an optional replace. /// <paramref name="replaceLine" /> can return the input to ignore the line, or return a different string to replace it. @@ -137,6 +196,17 @@ public SettingsTask ScrubLinesWithReplace(Func<string, string?> replaceLine, Scr return this; } + /// <summary> + /// Scrub lines with an optional replace. + /// <paramref name="replaceLine" /> can return the input to ignore the line, or return a different string to replace it. + /// </summary> + [Pure] + public SettingsTask ScrubLinesWithReplace(string extension, Func<string, string?> replaceLine, ScrubberLocation location = ScrubberLocation.First) + { + CurrentSettings.ScrubLinesWithReplace(extension, replaceLine, location); + return this; + } + /// <summary> /// Remove any lines containing only whitespace from the test results. /// </summary> @@ -147,6 +217,16 @@ public SettingsTask ScrubEmptyLines(ScrubberLocation location = ScrubberLocation return this; } + /// <summary> + /// Remove any lines containing only whitespace from the test results. + /// </summary> + [Pure] + public SettingsTask ScrubEmptyLines(string extension, ScrubberLocation location = ScrubberLocation.First) + { + CurrentSettings.ScrubEmptyLines(extension, location); + return this; + } + /// <summary> /// Remove any lines containing any of <paramref name="stringToMatch" /> from the test results. /// </summary> @@ -166,4 +246,14 @@ public SettingsTask ScrubLinesContaining(ScrubberLocation location = ScrubberLoc CurrentSettings.ScrubLinesContaining(location, stringToMatch); return this; } + + /// <summary> + /// Remove any lines containing any of <paramref name="stringToMatch" /> from the test results. + /// </summary> + [Pure] + public SettingsTask ScrubLinesContaining(string extension, ScrubberLocation location = ScrubberLocation.First, params string[] stringToMatch) + { + CurrentSettings.ScrubLinesContaining(extension, location, stringToMatch); + return this; + } } \ No newline at end of file