Skip to content

Commit a193c3e

Browse files
committed
Use ModuleInitializer to configure Verify
1 parent 965b596 commit a193c3e

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

test/CommandGroupRunnerTests.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ namespace RunScript;
99
[UsesVerify]
1010
public class CommandGroupRunnerTests
1111
{
12-
static CommandGroupRunnerTests()
13-
{
14-
VerifierSettings.AddExtraSettings(settings => settings.Converters.Add(new ConsoleConverter()));
15-
}
16-
1712
[Theory]
1813
[InlineData(true)]
1914
[InlineData(false)]

test/GlobalCommandsTests.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ namespace RunScript;
99
[UsesVerify]
1010
public class GlobalCommandsTests
1111
{
12-
static GlobalCommandsTests()
13-
{
14-
VerifierSettings.AddExtraSettings(settings => settings.Converters.Add(new ConsoleConverter()));
15-
}
16-
1712
[Fact]
1813
public async Task Should_log_all_available_scripts()
1914
{

test/Integration/CommandBuilderTests.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ namespace RunScript.Integration;
77

88
public static class CommandBuilderTests
99
{
10-
static CommandBuilderTests()
11-
{
12-
VerifierSettings.AddExtraSettings(settings => settings.Converters.Add(new ConsoleConverter()));
13-
}
14-
1510
// Passing `bash` works locally, but not on CI due to no WSL so the next best thing is using git bash
1611
[Trait("category", "integration")]
1712
[UsesVerify]

test/ModuleInitializer.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace RunScript;
2+
3+
using System.Runtime.CompilerServices;
4+
5+
public static class ModuleInitializer
6+
{
7+
[ModuleInitializer]
8+
public static void Init()
9+
{
10+
VerifierSettings.AddExtraSettings(settings => settings.Converters.Add(new ConsoleConverter()));
11+
}
12+
}

test/ModuleInitializerAttribute.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#if !NET5_0_OR_GREATER
2+
namespace System.Runtime.CompilerServices;
3+
4+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
5+
internal sealed class ModuleInitializerAttribute : Attribute
6+
{
7+
}
8+
#endif

0 commit comments

Comments
 (0)