Skip to content

Commit

Permalink
BH0001AnalyzerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
na1307 committed Dec 19, 2024
1 parent a22b31f commit 6efaa60
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/SonarCloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build:
name: SonarCloud
runs-on: windows-latest
runs-on: ubuntu-latest
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
build:
name: .NET
runs-on: windows-latest
runs-on: ubuntu-latest
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
OUTPUT_PATH: output
Expand Down
57 changes: 57 additions & 0 deletions Bluehill.Analyzers.Tests/BH0001AnalyzerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Verify = Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerVerifier<Bluehill.Analyzers.BH0001TypesShouldBeSealedAnalyzer, Microsoft.CodeAnalysis.Testing.DefaultVerifier>;

namespace Bluehill.Analyzers.Tests;

public sealed class BH0001AnalyzerTest {
[Fact]
public Task NonSealedClass() => Verify.VerifyAnalyzerAsync("""
public class [|TestClass|];
""");

[Fact]
public Task NonSealedAndNonSealedDerivedClass() => Verify.VerifyAnalyzerAsync("""
public class TestClass;
public class [|TestClass2|] : TestClass;
""");

[Fact]
public Task NonSealedAndSealedDerivedClass() => Verify.VerifyAnalyzerAsync("""
public class TestClass;
public sealed class TestClass2 : TestClass;
""");

[Fact]
public Task StaticClass() => Verify.VerifyAnalyzerAsync("""
public static class TestClass;
""");

[Fact]
public Task SealedClassWithoutBase() => Verify.VerifyAnalyzerAsync("""
public sealed class TestClass;
""");

[Fact]
public Task AbstractClassWithoutBase() => Verify.VerifyAnalyzerAsync("""
public abstract class TestClass;
""");

[Fact]
public Task Struct() => Verify.VerifyAnalyzerAsync("""
public struct TestStruct;
""");

[Fact]
public Task Enum() => Verify.VerifyAnalyzerAsync("""
public enum TestEnum;
""");

[Fact]
public Task Interface() => Verify.VerifyAnalyzerAsync("""
public interface TestInterface;
""");

[Fact]
public Task Delegate() => Verify.VerifyAnalyzerAsync("""
public delegate void TestDelegate();
""");
}
10 changes: 0 additions & 10 deletions Bluehill.Analyzers.Tests/BH0001Test.cs

This file was deleted.

0 comments on commit 6efaa60

Please sign in to comment.