Browse Source

[Tests] Added helper methods for checking a specific fix to InspectionActionTestBase

newNRvisualizers
Mansheng Yang 14 years ago
parent
commit
23c7dc08d4
  1. 19
      ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/InspectionActionTestBase.cs

19
ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/InspectionActionTestBase.cs

@ -43,10 +43,10 @@ namespace ICSharpCode.NRefactory.CSharp.CodeIssues @@ -43,10 +43,10 @@ namespace ICSharpCode.NRefactory.CSharp.CodeIssues
return new List<CodeIssue> (action.GetIssues (context));
}
protected static void CheckFix (TestRefactoringContext ctx, CodeIssue issue, string expectedOutput)
protected static void CheckFix (TestRefactoringContext ctx, CodeIssue issue, string expectedOutput, int fixIndex = 0)
{
using (var script = ctx.StartScript ())
issue.Actions.First ().Run (script);
issue.Actions[fixIndex].Run (script);
Assert.AreEqual (expectedOutput, ctx.Text);
}
@ -64,7 +64,7 @@ namespace ICSharpCode.NRefactory.CSharp.CodeIssues @@ -64,7 +64,7 @@ namespace ICSharpCode.NRefactory.CSharp.CodeIssues
Assert.AreEqual (expectedOutput, ctx.Text);
}
protected static void Test<T> (string input, int issueCount, string output = null, int fixIndex = -1)
protected static void Test<T> (string input, int issueCount, string output = null, int issueToFix = -1)
where T : ICodeIssueProvider, new ()
{
TestRefactoringContext context;
@ -72,10 +72,19 @@ namespace ICSharpCode.NRefactory.CSharp.CodeIssues @@ -72,10 +72,19 @@ namespace ICSharpCode.NRefactory.CSharp.CodeIssues
Assert.AreEqual (issueCount, issues.Count);
if (issueCount == 0 || output == null)
return;
if (fixIndex == -1)
if (issueToFix == -1)
CheckFix (context, issues, output);
else
CheckFix (context, issues [fixIndex], output);
CheckFix (context, issues [issueToFix], output);
}
protected static void Test<T> (string input, string output, int fixIndex)
where T : ICodeIssueProvider, new ()
{
TestRefactoringContext context;
var issues = GetIssues (new T (), input, out context);
Assert.AreEqual (1, issues.Count);
CheckFix (context, issues[0], output, fixIndex);
}
}

Loading…
Cancel
Save