diff --git a/Tests/Common/CodeFixTestBase.cs b/Tests/Common/CodeFixTestBase.cs index 9744b130..b3e321f6 100644 --- a/Tests/Common/CodeFixTestBase.cs +++ b/Tests/Common/CodeFixTestBase.cs @@ -1,6 +1,7 @@ using NUnit.Framework; using System.Text; using Microsoft.CodeAnalysis.Text; +using RefactoringEssentials.Tests.Common; namespace RefactoringEssentials.Tests { @@ -13,23 +14,7 @@ public virtual void SetUp() internal static string HomogenizeEol(string str) { - var sb = new StringBuilder(); - for (int i = 0; i < str.Length; i++) - { - var ch = str[i]; - var possibleNewline = NewLine.GetDelimiterLength(ch, i + 1 < str.Length ? str[i + 1] : '\0'); - if (possibleNewline > 0) - { - sb.AppendLine(); - if (possibleNewline == 2) - i++; - } - else - { - sb.Append(ch); - } - } - return sb.ToString(); + return Utils.HomogenizeEol(str); } protected static string ParseText(string input, out TextSpan selectedSpan) diff --git a/Tests/Common/CodeRefactoringTestBase.cs b/Tests/Common/CodeRefactoringTestBase.cs index cf113dcc..cffd07df 100644 --- a/Tests/Common/CodeRefactoringTestBase.cs +++ b/Tests/Common/CodeRefactoringTestBase.cs @@ -1,6 +1,7 @@ using NUnit.Framework; using System.Text; using Microsoft.CodeAnalysis.Text; +using RefactoringEssentials.Tests.Common; namespace RefactoringEssentials.Tests { @@ -13,23 +14,7 @@ public virtual void SetUp() internal static string HomogenizeEol(string str) { - var sb = new StringBuilder(); - for (int i = 0; i < str.Length; i++) - { - var ch = str[i]; - var possibleNewline = NewLine.GetDelimiterLength(ch, i + 1 < str.Length ? str[i + 1] : '\0'); - if (possibleNewline > 0) - { - sb.AppendLine(); - if (possibleNewline == 2) - i++; - } - else - { - sb.Append(ch); - } - } - return sb.ToString(); + return Utils.HomogenizeEol(str); } protected static string ParseText(string input, out TextSpan selectedSpan, out TextSpan markedSpan) diff --git a/Tests/Common/DiagnosticTestBase.cs b/Tests/Common/DiagnosticTestBase.cs index 7e0c7897..e1563e6d 100644 --- a/Tests/Common/DiagnosticTestBase.cs +++ b/Tests/Common/DiagnosticTestBase.cs @@ -7,10 +7,10 @@ using System.Threading; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.Host.Mef; using System.Text; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.CodeActions; +using RefactoringEssentials.Tests.Common; namespace RefactoringEssentials.Tests { @@ -292,8 +292,8 @@ protected static void Analyze(Func parseTextFunc, Func(Func parseTextFunc, } var txt = workspace.CurrentSolution.GetProject(projectId).GetDocument(documentId).GetTextAsync().Result.ToString(); - txt = CodeFixTestBase.HomogenizeEol(txt); - output = CodeFixTestBase.HomogenizeEol(output); + txt = Utils.HomogenizeEol(txt); + output = Utils.HomogenizeEol(output); if (output != txt) { Console.WriteLine("expected:"); diff --git a/Tests/Common/Utils.cs b/Tests/Common/Utils.cs new file mode 100644 index 00000000..677c353d --- /dev/null +++ b/Tests/Common/Utils.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RefactoringEssentials.Tests.Common +{ + static class Utils + { + internal static string HomogenizeEol(string str) + { + var sb = new StringBuilder(); + for (int i = 0; i < str.Length; i++) + { + var ch = str[i]; + var possibleNewline = NewLine.GetDelimiterLength(ch, i + 1 < str.Length ? str[i + 1] : '\0'); + if (possibleNewline > 0) + { + sb.AppendLine(); + if (possibleNewline == 2) + i++; + } + else + { + sb.Append(ch); + } + } + return sb.ToString(); + } + } +}