generated from stripe/.github
-
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.
Merge branch 'refs/heads/generatortests'
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...NetCore.SourceGenerators.Tests/Stripe.Extensions.AspNetCore.SourceGenerators.Tests.csproj
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,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"/> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/> | ||
<PackageReference Include="xunit" Version="2.5.3"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Stripe.Extensions.AspNetCore.SourceGenerators\Stripe.Extensions.AspNetCore.SourceGenerators.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
28 changes: 28 additions & 0 deletions
28
...Stripe.Extensions.AspNetCore.SourceGenerators.Tests/StripeWebhookHandlerGeneratorTests.cs
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,28 @@ | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Stripe.Extensions.AspNetCore.SourceGenerators.Tests; | ||
|
||
public class StripeWebhookHandlerGeneratorTests | ||
{ | ||
[Fact] | ||
public void GeneratorOutputsAspNetCore() | ||
{ | ||
// Run generator using a driver with an empty compilation | ||
var generator = new StripeWebhookHandlerGenerator(); | ||
var driver = CSharpGeneratorDriver.Create(generator); | ||
|
||
var compilation = CSharpCompilation.Create(nameof(StripeWebhookHandlerGeneratorTests)); | ||
driver.RunGeneratorsAndUpdateCompilation(compilation, out var newCompilation, out var diagnostics); | ||
|
||
|
||
// Retrieve all files in the compilation. | ||
var generatedFiles = newCompilation.SyntaxTrees | ||
.Select(t => Path.GetFileName(t.FilePath)) | ||
.ToArray(); | ||
|
||
Assert.Equivalent(new[] { "Stripe.Extensions.AspNetCore.g.cs" }, generatedFiles); | ||
|
||
Assert.Empty(diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error)); | ||
} | ||
} |