Skip to content

Commit 7f271fe

Browse files
authored
Add approval tests (#25)
1 parent 6d55a9b commit 7f271fe

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2017 Serilog Contributors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using PublicApiGenerator;
16+
using Shouldly;
17+
using Xunit;
18+
19+
namespace Destructurama.JsonNet.Tests;
20+
21+
/// <summary>Tests for checking changes to the public API.</summary>
22+
public class ApiApprovalTests
23+
{
24+
/// <summary>Check for changes to the public APIs.</summary>
25+
/// <param name="type">The type used as a marker for the assembly whose public API change you want to check.</param>
26+
[Theory]
27+
[InlineData(typeof(LoggerConfigurationAppSettingsExtensions))]
28+
public void PublicApi_Should_Not_Change_Unintentionally(Type type)
29+
{
30+
string publicApi = type.Assembly.GeneratePublicApi(new()
31+
{
32+
IncludeAssemblyAttributes = false,
33+
AllowNamespacePrefixes = ["System", "Microsoft.Extensions.DependencyInjection"],
34+
ExcludeAttributes = ["System.Diagnostics.DebuggerDisplayAttribute"],
35+
});
36+
37+
publicApi.ShouldMatchApproved(options => options.NoDiff().WithFilenameGenerator((testMethodInfo, discriminator, fileType, fileExtension) => $"{type.Assembly.GetName().Name!}.{fileType}.{fileExtension}"));
38+
}
39+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Destructurama
2+
{
3+
public static class LoggerConfigurationAppSettingsExtensions
4+
{
5+
public static Serilog.LoggerConfiguration JsonNetTypes(this Serilog.Configuration.LoggerDestructuringConfiguration configuration) { }
6+
}
7+
}

0 commit comments

Comments
 (0)