generated from dailydevops/dotnet-template
-
-
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.
chore: Added public api tests (#574)
* chore: Added public api tests * fix: Add direct reference
- Loading branch information
Showing
20 changed files
with
390 additions
and
34 deletions.
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
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
73 changes: 73 additions & 0 deletions
73
tests/NetEvolve.HealthChecks.Tests.Integration/PublicApiTests.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,73 @@ | ||
namespace NetEvolve.HealthChecks.Tests.Integration; | ||
|
||
using System.ComponentModel; | ||
using System.Reflection; | ||
using System.Resources; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.Versioning; | ||
using PublicApiGenerator; | ||
|
||
public class PublicApiTests | ||
{ | ||
private static readonly string[] _excludedAttributes = | ||
[ | ||
typeof(InternalsVisibleToAttribute).FullName!, | ||
"System.Runtime.CompilerServices.IsByRefLikeAttribute", | ||
typeof(TargetFrameworkAttribute).FullName!, | ||
typeof(CLSCompliantAttribute).FullName!, | ||
typeof(AssemblyMetadataAttribute).FullName!, | ||
typeof(NeutralResourcesLanguageAttribute).FullName!, | ||
typeof(AttributeUsageAttribute).FullName!, | ||
]; | ||
|
||
[Theory] | ||
[MemberData(nameof(GetAssemblies))] | ||
public Task PublicApi_HasNotChanged_Theory(Assembly assembly) | ||
{ | ||
Assert.NotNull(assembly); | ||
|
||
var types = assembly.GetTypes().Where(IsVisibleToIntelliSense).ToArray(); | ||
|
||
var options = new ApiGeneratorOptions | ||
{ | ||
ExcludeAttributes = _excludedAttributes, | ||
IncludeTypes = types, | ||
}; | ||
|
||
var publicApi = assembly.GeneratePublicApi(options); | ||
|
||
return Verify(publicApi).UseTypeName(assembly.GetName().Name); | ||
} | ||
|
||
public static TheoryData<Assembly> GetAssemblies | ||
{ | ||
get | ||
{ | ||
var assemblies = Assembly | ||
.GetExecutingAssembly()! | ||
.GetReferencedAssemblies() | ||
.Where(a => | ||
a.Name?.StartsWith("NetEvolve.HealthChecks", StringComparison.OrdinalIgnoreCase) | ||
== true | ||
) | ||
.Select(Assembly.Load) | ||
.ToArray(); | ||
|
||
var data = new TheoryData<Assembly>(); | ||
data.AddRange(assemblies); | ||
return data; | ||
} | ||
} | ||
|
||
private static bool IsVisibleToIntelliSense(Type type) | ||
{ | ||
var browsable = type.GetCustomAttribute<BrowsableAttribute>(); | ||
if (browsable is null || browsable.Browsable) | ||
{ | ||
return true; | ||
} | ||
|
||
var editorBrowsable = type.GetCustomAttribute<EditorBrowsableAttribute>(); | ||
return editorBrowsable is null || editorBrowsable.State != EditorBrowsableState.Never; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...snapshots/NetEvolve.HealthChecks.Apache.Kafka.PublicApi_HasNotChanged_Theory.verified.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,20 @@ | ||
namespace NetEvolve.HealthChecks.Apache.Kafka | ||
{ | ||
public static class DependencyInjectionExtensions | ||
{ | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddKafka([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.Apache.Kafka.KafkaOptions>? options = null, params string[] tags) { } | ||
} | ||
public class KafkaOptions | ||
{ | ||
public KafkaOptions() { } | ||
public Confluent.Kafka.ProducerConfig Configuration { get; set; } | ||
public NetEvolve.HealthChecks.Apache.Kafka.ProducerHandleMode Mode { get; set; } | ||
public int Timeout { get; set; } | ||
public string Topic { get; set; } | ||
} | ||
public enum ProducerHandleMode | ||
{ | ||
ServiceProvider = 0, | ||
Create = 1, | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
..._snapshots/NetEvolve.HealthChecks.Azure.Blobs.PublicApi_HasNotChanged_Theory.verified.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,39 @@ | ||
namespace NetEvolve.HealthChecks.Azure.Blobs | ||
{ | ||
public enum BlobClientCreationMode | ||
{ | ||
ServiceProvider = 0, | ||
DefaultAzureCredentials = 1, | ||
ConnectionString = 2, | ||
SharedKey = 3, | ||
AzureSasCredential = 4, | ||
} | ||
public sealed class BlobContainerAvailableOptions | ||
{ | ||
public BlobContainerAvailableOptions() { } | ||
public string? AccountKey { get; set; } | ||
public string? AccountName { get; set; } | ||
public System.Action<Azure.Storage.Blobs.BlobClientOptions>? ConfigureClientOptions { get; set; } | ||
public string? ConnectionString { get; set; } | ||
public string? ContainerName { get; set; } | ||
public NetEvolve.HealthChecks.Azure.Blobs.BlobClientCreationMode Mode { get; set; } | ||
public System.Uri? ServiceUri { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
public sealed class BlobServiceAvailableOptions | ||
{ | ||
public BlobServiceAvailableOptions() { } | ||
public string? AccountKey { get; set; } | ||
public string? AccountName { get; set; } | ||
public System.Action<Azure.Storage.Blobs.BlobClientOptions>? ConfigureClientOptions { get; set; } | ||
public string? ConnectionString { get; set; } | ||
public NetEvolve.HealthChecks.Azure.Blobs.BlobClientCreationMode Mode { get; set; } | ||
public System.Uri? ServiceUri { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
public static class DependencyInjectionExtensions | ||
{ | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddBlobContainerAvailability([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.Azure.Blobs.BlobContainerAvailableOptions>? options = null, params string[] tags) { } | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddBlobServiceAvailability([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.Azure.Blobs.BlobServiceAvailableOptions>? options = null, params string[] tags) { } | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...snapshots/NetEvolve.HealthChecks.Azure.Queues.PublicApi_HasNotChanged_Theory.verified.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,39 @@ | ||
namespace NetEvolve.HealthChecks.Azure.Queues | ||
{ | ||
public static class DependencyInjectionExtensions | ||
{ | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddQueueClientAvailability([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.Azure.Queues.QueueClientAvailableOptions>? options = null, params string[] tags) { } | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddQueueServiceAvailability([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.Azure.Queues.QueueServiceAvailableOptions>? options = null, params string[] tags) { } | ||
} | ||
public sealed class QueueClientAvailableOptions | ||
{ | ||
public QueueClientAvailableOptions() { } | ||
public string? AccountKey { get; set; } | ||
public string? AccountName { get; set; } | ||
public System.Action<Azure.Storage.Queues.QueueClientOptions>? ConfigureClientOptions { get; set; } | ||
public string? ConnectionString { get; set; } | ||
public NetEvolve.HealthChecks.Azure.Queues.QueueClientCreationMode Mode { get; set; } | ||
public string? QueueName { get; set; } | ||
public System.Uri? ServiceUri { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
public enum QueueClientCreationMode | ||
{ | ||
ServiceProvider = 0, | ||
DefaultAzureCredentials = 1, | ||
ConnectionString = 2, | ||
SharedKey = 3, | ||
AzureSasCredential = 4, | ||
} | ||
public sealed class QueueServiceAvailableOptions | ||
{ | ||
public QueueServiceAvailableOptions() { } | ||
public string? AccountKey { get; set; } | ||
public string? AccountName { get; set; } | ||
public System.Action<Azure.Storage.Queues.QueueClientOptions>? ConfigureClientOptions { get; set; } | ||
public string? ConnectionString { get; set; } | ||
public NetEvolve.HealthChecks.Azure.Queues.QueueClientCreationMode Mode { get; set; } | ||
public System.Uri? ServiceUri { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...snapshots/NetEvolve.HealthChecks.Azure.Tables.PublicApi_HasNotChanged_Theory.verified.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,39 @@ | ||
namespace NetEvolve.HealthChecks.Azure.Tables | ||
{ | ||
public static class DependencyInjectionExtensions | ||
{ | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTableClientAvailability([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.Azure.Tables.TableClientAvailableOptions>? options = null, params string[] tags) { } | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTableServiceAvailability([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.Azure.Tables.TableServiceAvailableOptions>? options = null, params string[] tags) { } | ||
} | ||
public sealed class TableClientAvailableOptions | ||
{ | ||
public TableClientAvailableOptions() { } | ||
public string? AccountKey { get; set; } | ||
public string? AccountName { get; set; } | ||
public System.Action<Azure.Data.Tables.TableClientOptions>? ConfigureClientOptions { get; set; } | ||
public string? ConnectionString { get; set; } | ||
public NetEvolve.HealthChecks.Azure.Tables.TableClientCreationMode Mode { get; set; } | ||
public System.Uri? ServiceUri { get; set; } | ||
public string? TableName { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
public enum TableClientCreationMode | ||
{ | ||
ServiceProvider = 0, | ||
DefaultAzureCredentials = 1, | ||
ConnectionString = 2, | ||
SharedKey = 3, | ||
AzureSasCredential = 4, | ||
} | ||
public sealed class TableServiceAvailableOptions | ||
{ | ||
public TableServiceAvailableOptions() { } | ||
public string? AccountKey { get; set; } | ||
public string? AccountName { get; set; } | ||
public System.Action<Azure.Data.Tables.TableClientOptions>? ConfigureClientOptions { get; set; } | ||
public string? ConnectionString { get; set; } | ||
public NetEvolve.HealthChecks.Azure.Tables.TableClientCreationMode Mode { get; set; } | ||
public System.Uri? ServiceUri { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../_snapshots/NetEvolve.HealthChecks.ClickHouse.PublicApi_HasNotChanged_Theory.verified.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,14 @@ | ||
namespace NetEvolve.HealthChecks.ClickHouse | ||
{ | ||
public sealed class ClickHouseOptions : NetEvolve.HealthChecks.Abstractions.ISqlCheckOptions | ||
{ | ||
public ClickHouseOptions() { } | ||
public string Command { get; } | ||
public string ConnectionString { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
public static class DependencyInjectionExtensions | ||
{ | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddClickHouse([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.ClickHouse.ClickHouseOptions>? options = null, params string[] tags) { } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...pshots/NetEvolve.HealthChecks.MySql.Connector.PublicApi_HasNotChanged_Theory.verified.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,14 @@ | ||
namespace NetEvolve.HealthChecks.MySql.Connector | ||
{ | ||
public static class DependencyInjectionExtensions | ||
{ | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddMySql([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.MySql.Connector.MySqlOptions>? options = null, params string[] tags) { } | ||
} | ||
public sealed class MySqlOptions : NetEvolve.HealthChecks.Abstractions.ISqlCheckOptions | ||
{ | ||
public MySqlOptions() { } | ||
public string Command { get; } | ||
public string ConnectionString { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ation/_snapshots/NetEvolve.HealthChecks.MySql.PublicApi_HasNotChanged_Theory.verified.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,14 @@ | ||
namespace NetEvolve.HealthChecks.MySql | ||
{ | ||
public static class DependencyInjectionExtensions | ||
{ | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddMySql([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.MySql.MySqlOptions>? options = null, params string[] tags) { } | ||
} | ||
public sealed class MySqlOptions : NetEvolve.HealthChecks.Abstractions.ISqlCheckOptions | ||
{ | ||
public MySqlOptions() { } | ||
public string Command { get; } | ||
public string ConnectionString { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...tion/_snapshots/NetEvolve.HealthChecks.Npgsql.PublicApi_HasNotChanged_Theory.verified.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,14 @@ | ||
namespace NetEvolve.HealthChecks.Npgsql | ||
{ | ||
public static class DependencyInjectionExtensions | ||
{ | ||
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddPostgreSql([System.Diagnostics.CodeAnalysis.NotNull] this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, [System.Diagnostics.CodeAnalysis.NotNull] string name, System.Action<NetEvolve.HealthChecks.Npgsql.NpgsqlOptions>? options = null, params string[] tags) { } | ||
} | ||
public sealed class NpgsqlOptions : NetEvolve.HealthChecks.Abstractions.ISqlCheckOptions | ||
{ | ||
public NpgsqlOptions() { } | ||
public string Command { get; } | ||
public string ConnectionString { get; set; } | ||
public int Timeout { get; set; } | ||
} | ||
} |
Oops, something went wrong.