diff --git a/src/Destructurama.JsonNet.Tests/Approval/ApiApprovalTests.cs b/src/Destructurama.JsonNet.Tests/Approval/ApiApprovalTests.cs new file mode 100644 index 0000000..2edf04e --- /dev/null +++ b/src/Destructurama.JsonNet.Tests/Approval/ApiApprovalTests.cs @@ -0,0 +1,39 @@ +// Copyright 2017 Serilog Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using PublicApiGenerator; +using Shouldly; +using Xunit; + +namespace Destructurama.JsonNet.Tests; + +/// Tests for checking changes to the public API. +public class ApiApprovalTests +{ + /// Check for changes to the public APIs. + /// The type used as a marker for the assembly whose public API change you want to check. + [Theory] + [InlineData(typeof(LoggerConfigurationAppSettingsExtensions))] + public void PublicApi_Should_Not_Change_Unintentionally(Type type) + { + string publicApi = type.Assembly.GeneratePublicApi(new() + { + IncludeAssemblyAttributes = false, + AllowNamespacePrefixes = ["System", "Microsoft.Extensions.DependencyInjection"], + ExcludeAttributes = ["System.Diagnostics.DebuggerDisplayAttribute"], + }); + + publicApi.ShouldMatchApproved(options => options.NoDiff().WithFilenameGenerator((testMethodInfo, discriminator, fileType, fileExtension) => $"{type.Assembly.GetName().Name!}.{fileType}.{fileExtension}")); + } +} diff --git a/src/Destructurama.JsonNet.Tests/Approval/Destructurama.JsonNet.approved.txt b/src/Destructurama.JsonNet.Tests/Approval/Destructurama.JsonNet.approved.txt new file mode 100644 index 0000000..0514f10 --- /dev/null +++ b/src/Destructurama.JsonNet.Tests/Approval/Destructurama.JsonNet.approved.txt @@ -0,0 +1,7 @@ +namespace Destructurama +{ + public static class LoggerConfigurationAppSettingsExtensions + { + public static Serilog.LoggerConfiguration JsonNetTypes(this Serilog.Configuration.LoggerDestructuringConfiguration configuration) { } + } +} \ No newline at end of file