34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace Json2CSharpCodeGenerator.Tests;
|
|
|
|
public static class TestUtility
|
|
{
|
|
private static readonly Regex _SpaceRegex = new("( +)", RegexOptions.Compiled);
|
|
|
|
public static string NormalizeOutput(this string testData)
|
|
{
|
|
string testDataCleaned = testData
|
|
.Replace("\r", "")
|
|
.Replace("\n", " ")
|
|
// .Replace(" ", " ")
|
|
.Replace("\t", " ")
|
|
|
|
#if DEBUG
|
|
.Replace(",", ",\r\n") // Parameters/arguments
|
|
.Replace("{", "\r\n{\r\n")
|
|
.Replace("}", "\r\n}\r\n")
|
|
.Replace(";", ";\r\n")
|
|
|
|
.Replace("\r\n\r\n", "\r\n")
|
|
.Replace("\r\n\r\n", "\r\n")
|
|
#endif
|
|
;
|
|
|
|
testDataCleaned = _SpaceRegex.Replace(input: testDataCleaned, m => " "); // i.e.: replace runs of 2-or-more space characters (0x20) with a single space character.
|
|
|
|
testDataCleaned = testDataCleaned.Trim();
|
|
|
|
return "\r\n" + testDataCleaned + "\r\n"; // The outer line-breaks are added because VS's Test Explorer's Actual vs. Expected comparison is harder to read without them.
|
|
}
|
|
} |