-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using Verify = | ||
Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerVerifier<Bluehill.Analyzers.BH0002FieldsShouldBeAtTheTopAnalyzer, | ||
Microsoft.CodeAnalysis.Testing.DefaultVerifier>; | ||
|
||
namespace Bluehill.Analyzers.Tests; | ||
|
||
public sealed class BH0002AnalyzerTest { | ||
[Theory] | ||
[InlineData( | ||
""" | ||
public class TestClass { | ||
public TestClass(string name) => this.name = name; | ||
public string GetName() => name; | ||
private readonly string [|name|]; | ||
} | ||
""" | ||
)] | ||
[InlineData( | ||
""" | ||
public class TestClass { | ||
private readonly string name; | ||
public TestClass(string name) => this.name = name; | ||
public string GetName() => name; | ||
} | ||
""" | ||
)] | ||
[InlineData( | ||
""" | ||
public class TestClass { | ||
public TestClass(string name) => this.name = name; | ||
public string GetName() => name; | ||
[System.NonSerialized] | ||
private readonly string [|name|]; | ||
} | ||
""" | ||
)] | ||
[InlineData( | ||
""" | ||
public class TestClass { | ||
[System.NonSerialized] | ||
private readonly string name; | ||
public TestClass(string name) => this.name = name; | ||
public string GetName() => name; | ||
} | ||
""" | ||
)] | ||
[InlineData( | ||
""" | ||
public partial class TestClass { | ||
public TestClass(string name) => this.name = name; | ||
public string GetName() => name; | ||
private readonly string name; | ||
} | ||
""" | ||
)] | ||
[InlineData( | ||
""" | ||
public record class TestClass { | ||
public TestClass(string name) => this.name = name; | ||
public string GetName() => name; | ||
private readonly string name; | ||
} | ||
""" | ||
)] | ||
[InlineData( | ||
""" | ||
public class TestClass(string constructorName) { | ||
public string GetName() => name; | ||
private readonly string [|name|] = constructorName; | ||
} | ||
""" | ||
)] | ||
[InlineData( | ||
""" | ||
public class TestClass(string constructorName) { | ||
private readonly string name = constructorName; | ||
public string GetName() => name; | ||
} | ||
""" | ||
)] | ||
public Task Test(string source) => Verify.VerifyAnalyzerAsync(source); | ||
} |