-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add approval test for public API changes
- Loading branch information
Showing
5 changed files
with
69 additions
and
1 deletion.
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
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
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,24 @@ | ||
using PublicApiGenerator; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Moniker.ApprovalTests; | ||
|
||
public class ApiApprovalTests | ||
{ | ||
[Fact] | ||
public void PublicApiShouldNotChangeUnintentionally() | ||
{ | ||
var assembly = typeof(NameGenerator).Assembly; | ||
var publicApi = assembly.GeneratePublicApi( | ||
new ApiGeneratorOptions | ||
{ | ||
IncludeAssemblyAttributes = false, | ||
ExcludeAttributes = ["System.Diagnostics.DebuggerDisplayAttribute"], | ||
}); | ||
|
||
publicApi.ShouldMatchApproved(options => | ||
options.WithFilenameGenerator((_, _, fileType, fileExtension) => | ||
$"{assembly.GetName().Name!}.{fileType}.{fileExtension}")); | ||
} | ||
} |
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<DeterministicSourcePaths>false</DeterministicSourcePaths> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all" /> | ||
<PackageReference Include="xunit" Version="2.9.0" /> | ||
<PackageReference Include="Shouldly" Version="4.2.1" /> | ||
<PackageReference Include="PublicApiGenerator" Version="11.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Moniker\Moniker.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,15 @@ | ||
namespace Moniker | ||
{ | ||
public enum MonikerStyle | ||
{ | ||
Moniker = 0, | ||
Moby = 1, | ||
} | ||
public static class NameGenerator | ||
{ | ||
public const string DefaultDelimiter = "-"; | ||
public static string Generate(Moniker.MonikerStyle monikerStyle, string delimiter = "-") { } | ||
public static string GenerateMoby(string delimiter = "-") { } | ||
public static string GenerateMoniker(string delimiter = "-") { } | ||
} | ||
} |