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: Clean up tests and some simplifications (#499)
* chore: Test cleanup * fix: Fixed `new-project.ps1` --------- Signed-off-by: Martin Stühmer <[email protected]>
- Loading branch information
Showing
116 changed files
with
1,459 additions
and
20 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
28 changes: 28 additions & 0 deletions
28
...olve.Extensions.MSTest.Tests.PublicApi/NetEvolve.Extensions.MSTest.Tests.PublicApi.csproj
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,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>$(NetEvolve_TestTargetFrameworks)</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.msbuild" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="PublicApiGenerator" /> | ||
<PackageReference Include="Verify.Xunit" /> | ||
<PackageReference Include="xunit" /> | ||
<PackageReference Include="xunit.runner.visualstudio"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\NetEvolve.Extensions.MSTest\NetEvolve.Extensions.MSTest.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
29 changes: 29 additions & 0 deletions
29
tests/NetEvolve.Extensions.MSTest.Tests.PublicApi/Predefined.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,29 @@ | ||
namespace NetEvolve.Extensions.MSTest.Tests.PublicApi; | ||
|
||
using System.IO; | ||
using System.Runtime.CompilerServices; | ||
using VerifyTests; | ||
using VerifyXunit; | ||
|
||
internal static class Predefined | ||
{ | ||
[ModuleInitializer] | ||
public static void Init() | ||
{ | ||
Verifier.DerivePathInfo( | ||
(sourceFile, projectDirectory, type, method) => | ||
{ | ||
var directory = Path.Combine( | ||
projectDirectory, | ||
"_snapshots", | ||
Namer.TargetFrameworkNameAndVersion | ||
); | ||
_ = Directory.CreateDirectory(directory); | ||
return new(directory, type.Name, method.Name); | ||
} | ||
); | ||
|
||
VerifierSettings.AutoVerify(includeBuildServer: false); | ||
VerifierSettings.SortPropertiesAlphabetically(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/NetEvolve.Extensions.MSTest.Tests.PublicApi/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,52 @@ | ||
namespace NetEvolve.Extensions.MSTest.Tests.PublicApi; | ||
|
||
using System; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Resources; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.Versioning; | ||
using System.Threading.Tasks; | ||
using PublicApiGenerator; | ||
using Xunit; | ||
|
||
public class PublicApiTests | ||
{ | ||
[Fact] | ||
public Task PublicApi_HasNotChanged_Expected() | ||
{ | ||
var assembly = typeof(AcceptanceTestAttribute).Assembly; | ||
var types = assembly.GetTypes().Where(IsVisibleToIntelliSense).ToArray(); | ||
|
||
var options = new ApiGeneratorOptions | ||
{ | ||
ExcludeAttributes = | ||
[ | ||
typeof(InternalsVisibleToAttribute).FullName!, | ||
"System.Runtime.CompilerServices.IsByRefLikeAttribute", | ||
typeof(TargetFrameworkAttribute).FullName!, | ||
typeof(CLSCompliantAttribute).FullName!, | ||
typeof(AssemblyMetadataAttribute).FullName!, | ||
typeof(NeutralResourcesLanguageAttribute).FullName!, | ||
], | ||
IncludeTypes = types, | ||
}; | ||
|
||
var publicApi = assembly.GeneratePublicApi(options); | ||
|
||
return Verify(publicApi); | ||
} | ||
|
||
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; | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
...blicApi/_snapshots/DotNet6_0/PublicApiTests.PublicApi_HasNotChanged_Expected.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,99 @@ | ||
namespace NetEvolve.Extensions.MSTest | ||
{ | ||
public sealed class AcceptanceTestAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public AcceptanceTestAttribute() { } | ||
} | ||
public sealed class ArchitectureTestAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public ArchitectureTestAttribute() { } | ||
} | ||
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] | ||
public sealed class BugAttribute : NetEvolve.Extensions.MSTest.Internal.TestCategoryWithIdBaseAttribute | ||
{ | ||
public BugAttribute() { } | ||
public BugAttribute(long id) { } | ||
public BugAttribute(string? id) { } | ||
} | ||
public sealed class CodedUITestAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public CodedUITestAttribute() { } | ||
} | ||
public sealed class EndToEndTestAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public EndToEndTestAttribute() { } | ||
} | ||
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] | ||
public sealed class EpicAttribute : NetEvolve.Extensions.MSTest.Internal.TestCategoryWithIdBaseAttribute | ||
{ | ||
public EpicAttribute() { } | ||
public EpicAttribute(long id) { } | ||
public EpicAttribute(string? id) { } | ||
} | ||
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] | ||
public sealed class FeatureAttribute : NetEvolve.Extensions.MSTest.Internal.TestCategoryWithIdBaseAttribute | ||
{ | ||
public FeatureAttribute() { } | ||
public FeatureAttribute(long id) { } | ||
public FeatureAttribute(string? id) { } | ||
} | ||
public sealed class FunctionalTestAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public FunctionalTestAttribute() { } | ||
} | ||
public sealed class IntegrationTestAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public IntegrationTestAttribute() { } | ||
} | ||
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] | ||
public sealed class IssueAttribute : NetEvolve.Extensions.MSTest.Internal.TestCategoryWithIdBaseAttribute | ||
{ | ||
public IssueAttribute() { } | ||
public IssueAttribute(long id) { } | ||
public IssueAttribute(string? id) { } | ||
} | ||
public sealed class PerformanceTestAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public PerformanceTestAttribute() { } | ||
} | ||
public sealed class PostDeploymentAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public PostDeploymentAttribute() { } | ||
} | ||
public sealed class PreDeploymentAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public PreDeploymentAttribute() { } | ||
} | ||
public sealed class UnitTestAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
public UnitTestAttribute() { } | ||
} | ||
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] | ||
public sealed class UserStoryAttribute : NetEvolve.Extensions.MSTest.Internal.TestCategoryWithIdBaseAttribute | ||
{ | ||
public UserStoryAttribute() { } | ||
public UserStoryAttribute(long id) { } | ||
public UserStoryAttribute(string? id) { } | ||
} | ||
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] | ||
public sealed class WorkItemAttribute : NetEvolve.Extensions.MSTest.Internal.TestCategoryWithIdBaseAttribute | ||
{ | ||
public WorkItemAttribute() { } | ||
public WorkItemAttribute(long id) { } | ||
public WorkItemAttribute(string? id) { } | ||
} | ||
} | ||
namespace NetEvolve.Extensions.MSTest.Internal | ||
{ | ||
public abstract class TestCategoryWithIdBaseAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute | ||
{ | ||
protected TestCategoryWithIdBaseAttribute(string categoryName, string? id = null) { } | ||
public string? Id { get; } | ||
} | ||
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)] | ||
public abstract class TestTraitBaseAttribute : Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryBaseAttribute | ||
{ | ||
protected TestTraitBaseAttribute(string categoryName) { } | ||
public override System.Collections.Generic.IList<string> TestCategories { get; } | ||
} | ||
} |
Oops, something went wrong.