virtualx-engine/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ExportDiagnosticsTests.cs
Paul Joannon 88ad4e6c24
Add tests and fix exports diagnostics
- Add tests for the following diagnostics: GD0101, GD0102, GD0103, GD0104, GD0105, GD0106, GD0107.
- Fix GD0101 not being reported any more (was filtering static classes before reporting).
- Fix GD0107 not preventing `Node` members from being exported from not-`Node` types.
2024-02-20 11:24:41 +01:00

77 lines
2.3 KiB
C#

using Xunit;
namespace Godot.SourceGenerators.Tests;
public class ExportDiagnosticsTests
{
[Fact]
public async void StaticMembers()
{
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify(
"ExportDiagnostics_GD0101.cs",
"ExportDiagnostics_GD0101_ScriptPropertyDefVal.generated.cs"
);
}
[Fact]
public async void TypeIsNotSupported()
{
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify(
"ExportDiagnostics_GD0102.cs",
"ExportDiagnostics_GD0102_ScriptPropertyDefVal.generated.cs"
);
}
[Fact]
public async void ReadOnly()
{
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify(
"ExportDiagnostics_GD0103.cs",
"ExportDiagnostics_GD0103_ScriptPropertyDefVal.generated.cs"
);
}
[Fact]
public async void WriteOnly()
{
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify(
"ExportDiagnostics_GD0104.cs",
"ExportDiagnostics_GD0104_ScriptPropertyDefVal.generated.cs"
);
}
[Fact]
public async void Indexer()
{
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify(
"ExportDiagnostics_GD0105.cs",
"ExportDiagnostics_GD0105_ScriptPropertyDefVal.generated.cs"
);
}
[Fact]
public async void ExplicitInterfaceImplementation()
{
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify(
new string[] { "ExportDiagnostics_GD0106.cs" },
new string[]
{
"ExportDiagnostics_GD0106_OK_ScriptPropertyDefVal.generated.cs",
"ExportDiagnostics_GD0106_KO_ScriptPropertyDefVal.generated.cs",
}
);
}
[Fact]
public async void NodeExports()
{
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify(
new string[] { "ExportDiagnostics_GD0107.cs" },
new string[]
{
"ExportDiagnostics_GD0107_OK_ScriptPropertyDefVal.generated.cs",
"ExportDiagnostics_GD0107_KO_ScriptPropertyDefVal.generated.cs",
}
);
}
}