Skip to content

Commit

Permalink
dotnet#1638: add unit test to find both issues from sample code from …
Browse files Browse the repository at this point in the history
…ticket
  • Loading branch information
jongleur1983 committed Oct 17, 2018
1 parent f23cc6d commit cfd729a
Showing 1 changed file with 25 additions and 0 deletions.
Expand Up @@ -99,6 +99,31 @@ End Class
VerifyBasic(code, expectedDiagnostic);
}

[Fact]
public void FindsBothIssuesInExampleFromTicket()
{
const string code = @"
using System.Text;
public class C
{
public string Append(string text)
{
var sb = new StringBuilder();
sb.Append(text.Substring(0, 6));
sb.Append(text.Substring(2));
return sb.ToString ();
}
}";
var expected1 = new DiagnosticResult(
StringBuilderAppendShouldNotTakeSubstring.RuleReplaceTwoParameter)
.WithLocation("Test0.cs", 9, 9);
var expected2 = new DiagnosticResult(
StringBuilderAppendShouldNotTakeSubstring.RuleReplaceOneParameter)
.WithLocation("Test0.cs", 10, 9);
VerifyCSharp(code, expected1, expected2);
}

protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{
return new StringBuilderAppendShouldNotTakeSubstring();
Expand Down

0 comments on commit cfd729a

Please sign in to comment.