-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from sungam3r/api
Add API approval test
- Loading branch information
Showing
3 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
test/Serilog.Sinks.Console.Tests/Approval/ApiApprovalTests.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,27 @@ | ||
#if NET5_0 | ||
|
||
using PublicApiGenerator; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Serilog.Sinks.Console.Tests.Approval | ||
{ | ||
public class ApiApprovalTests | ||
{ | ||
[Fact] | ||
public void PublicApi_Should_Not_Change_Unintentionally() | ||
{ | ||
var assembly = typeof(ConsoleLoggerConfigurationExtensions).Assembly; | ||
var publicApi = assembly.GeneratePublicApi( | ||
new ApiGeneratorOptions() | ||
{ | ||
IncludeAssemblyAttributes = false, | ||
ExcludeAttributes = new[] { "System.Diagnostics.DebuggerDisplayAttribute" }, | ||
}); | ||
|
||
publicApi.ShouldMatchApproved(options => options.WithFilenameGenerator((_, __, fileType, fileExtension) => $"{assembly.GetName().Name!}.{fileType}.{fileExtension}")); | ||
} | ||
} | ||
} | ||
|
||
#endif |
70 changes: 70 additions & 0 deletions
70
test/Serilog.Sinks.Console.Tests/Approval/Serilog.Sinks.Console.approved.txt
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,70 @@ | ||
namespace Serilog | ||
{ | ||
public static class ConsoleLoggerConfigurationExtensions | ||
{ | ||
public static Serilog.LoggerConfiguration Console(this Serilog.Configuration.LoggerSinkConfiguration sinkConfiguration, Serilog.Formatting.ITextFormatter formatter, Serilog.Events.LogEventLevel restrictedToMinimumLevel = 0, Serilog.Core.LoggingLevelSwitch? levelSwitch = null, Serilog.Events.LogEventLevel? standardErrorFromLevel = default, object? syncRoot = null) { } | ||
public static Serilog.LoggerConfiguration Console(this Serilog.Configuration.LoggerSinkConfiguration sinkConfiguration, Serilog.Events.LogEventLevel restrictedToMinimumLevel = 0, string outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}", System.IFormatProvider? formatProvider = null, Serilog.Core.LoggingLevelSwitch? levelSwitch = null, Serilog.Events.LogEventLevel? standardErrorFromLevel = default, Serilog.Sinks.SystemConsole.Themes.ConsoleTheme? theme = null, bool applyThemeToRedirectedOutput = false, object? syncRoot = null) { } | ||
} | ||
} | ||
namespace Serilog.Sinks.SystemConsole.Themes | ||
{ | ||
public class AnsiConsoleTheme : Serilog.Sinks.SystemConsole.Themes.ConsoleTheme | ||
{ | ||
public AnsiConsoleTheme(System.Collections.Generic.IReadOnlyDictionary<Serilog.Sinks.SystemConsole.Themes.ConsoleThemeStyle, string> styles) { } | ||
public override bool CanBuffer { get; } | ||
protected override int ResetCharCount { get; } | ||
public static Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme Code { get; } | ||
public static Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme Grayscale { get; } | ||
public static Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme Literate { get; } | ||
public static Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme Sixteen { get; } | ||
public override void Reset(System.IO.TextWriter output) { } | ||
public override int Set(System.IO.TextWriter output, Serilog.Sinks.SystemConsole.Themes.ConsoleThemeStyle style) { } | ||
} | ||
public abstract class ConsoleTheme | ||
{ | ||
protected ConsoleTheme() { } | ||
public abstract bool CanBuffer { get; } | ||
protected abstract int ResetCharCount { get; } | ||
public static Serilog.Sinks.SystemConsole.Themes.ConsoleTheme None { get; } | ||
public abstract void Reset(System.IO.TextWriter output); | ||
public abstract int Set(System.IO.TextWriter output, Serilog.Sinks.SystemConsole.Themes.ConsoleThemeStyle style); | ||
} | ||
public enum ConsoleThemeStyle | ||
{ | ||
Text = 0, | ||
SecondaryText = 1, | ||
TertiaryText = 2, | ||
Invalid = 3, | ||
Null = 4, | ||
Name = 5, | ||
String = 6, | ||
Number = 7, | ||
Boolean = 8, | ||
Scalar = 9, | ||
[System.Obsolete("Use ConsoleThemeStyle.Scalar instead")] | ||
Object = 9, | ||
LevelVerbose = 10, | ||
LevelDebug = 11, | ||
LevelInformation = 12, | ||
LevelWarning = 13, | ||
LevelError = 14, | ||
LevelFatal = 15, | ||
} | ||
public class SystemConsoleTheme : Serilog.Sinks.SystemConsole.Themes.ConsoleTheme | ||
{ | ||
public SystemConsoleTheme(System.Collections.Generic.IReadOnlyDictionary<Serilog.Sinks.SystemConsole.Themes.ConsoleThemeStyle, Serilog.Sinks.SystemConsole.Themes.SystemConsoleThemeStyle> styles) { } | ||
public override bool CanBuffer { get; } | ||
protected override int ResetCharCount { get; } | ||
public System.Collections.Generic.IReadOnlyDictionary<Serilog.Sinks.SystemConsole.Themes.ConsoleThemeStyle, Serilog.Sinks.SystemConsole.Themes.SystemConsoleThemeStyle> Styles { get; } | ||
public static Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme Colored { get; } | ||
public static Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme Grayscale { get; } | ||
public static Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme Literate { get; } | ||
public override void Reset(System.IO.TextWriter output) { } | ||
public override int Set(System.IO.TextWriter output, Serilog.Sinks.SystemConsole.Themes.ConsoleThemeStyle style) { } | ||
} | ||
public struct SystemConsoleThemeStyle | ||
{ | ||
public System.ConsoleColor? Background; | ||
public System.ConsoleColor? Foreground; | ||
} | ||
} |
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