From 6efaa60e5e46e25319944107fb911c2ca5cee8fd Mon Sep 17 00:00:00 2001 From: Jonghyo Lee Date: Thu, 19 Dec 2024 12:20:48 +0900 Subject: [PATCH] BH0001AnalyzerTest --- .github/workflows/SonarCloud.yml | 2 +- .github/workflows/dotnet.yml | 2 +- .../BH0001AnalyzerTest.cs | 57 +++++++++++++++++++ Bluehill.Analyzers.Tests/BH0001Test.cs | 10 ---- 4 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 Bluehill.Analyzers.Tests/BH0001AnalyzerTest.cs delete mode 100644 Bluehill.Analyzers.Tests/BH0001Test.cs diff --git a/.github/workflows/SonarCloud.yml b/.github/workflows/SonarCloud.yml index f53066e..a9063b8 100644 --- a/.github/workflows/SonarCloud.yml +++ b/.github/workflows/SonarCloud.yml @@ -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: diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index bf842d3..aafb7ab 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -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 diff --git a/Bluehill.Analyzers.Tests/BH0001AnalyzerTest.cs b/Bluehill.Analyzers.Tests/BH0001AnalyzerTest.cs new file mode 100644 index 0000000..c0d2739 --- /dev/null +++ b/Bluehill.Analyzers.Tests/BH0001AnalyzerTest.cs @@ -0,0 +1,57 @@ +using Verify = Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerVerifier; + +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(); + """); +} diff --git a/Bluehill.Analyzers.Tests/BH0001Test.cs b/Bluehill.Analyzers.Tests/BH0001Test.cs deleted file mode 100644 index 239226f..0000000 --- a/Bluehill.Analyzers.Tests/BH0001Test.cs +++ /dev/null @@ -1,10 +0,0 @@ -using VerifyCS = Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerVerifier; - -namespace Bluehill.Analyzers.Tests; - -public sealed class BH0001Test { - [Fact] - public Task TestTest() => VerifyCS.VerifyAnalyzerAsync(""" - public class [|TestClass|]; - """); -}