Skip to content

Commit

Permalink
dotnet#1638: add unit tests for Basic
Browse files Browse the repository at this point in the history
  • Loading branch information
jongleur1983 committed Oct 13, 2018
1 parent 6518c74 commit 967d87b
Showing 1 changed file with 44 additions and 0 deletions.
Expand Up @@ -33,6 +33,29 @@ public string Append(string text)
VerifyCSharp(code, expectedDiagnostic);
}

[Fact]
public void TestFromProposingTicketFirstLineBasic()
{
const string code = @"
Imports System.Text
Public Class C
Public Function Append(ByVal text As String) As String
Dim sb = New StringBuilder()
sb.Append(text.Substring(2))
Return sb.ToString()
End Function
End Class
";

var expectedDiagnostic =
new DiagnosticResult(
StringBuilderAppendShouldNotTakeSubstring.RuleReplaceOneParameter)
.WithLocation("Test0.vb", 7, 9);

VerifyBasic(code, expectedDiagnostic);
}

[Fact]
public void TestFromProposingTicketSecondLine()
{
Expand All @@ -55,6 +78,27 @@ public string Append(string text)
VerifyCSharp(code, expectedDiagnostic);
}

[Fact]
public void TestFromProposingTicketSecondLineBasic()
{
const string code = @"
Imports System.Text
Public Class C
Public Function Append(ByVal text As String) As String
Dim sb = New StringBuilder()
sb.Append(text.Substring(0,6))
Return sb.ToString()
End Function
End Class
";
var expectedDiagnostic = new DiagnosticResult(
StringBuilderAppendShouldNotTakeSubstring.RuleReplaceTwoParameter)
.WithLocation("Test0.vb", 7, 9);

VerifyBasic(code, expectedDiagnostic);
}

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

0 comments on commit 967d87b

Please sign in to comment.