Skip to content

Commit 8565a27

Browse files
fredrikhrjonsequitur
authored andcommitted
Construct test environment variable in test-constructor
1 parent 121754f commit 8565a27

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/System.CommandLine.Tests/EnvironmentVariableDirectiveTests.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ namespace System.CommandLine.Tests
1313
public class EnvironmentVariableDirectiveTests
1414
{
1515
private static readonly Random randomizer = new Random(Seed: 456476756);
16+
private readonly string test_variable = $"TEST_ENVIRONMENT_VARIABLE{randomizer.Next()}";
1617

1718
[Fact]
18-
public static async Task Sets_environment_variable_to_value()
19+
public async Task Sets_environment_variable_to_value()
1920
{
2021
bool asserted = false;
21-
string variable = $"TEST_ENVIRONMENT_VARIABLE{randomizer.Next()}";
22+
string variable = test_variable;
2223
const string value = "This is a test";
2324
var rootCommand = new RootCommand
2425
{
@@ -39,10 +40,10 @@ public static async Task Sets_environment_variable_to_value()
3940
}
4041

4142
[Fact]
42-
public static async Task Trims_environment_variable_name()
43+
public async Task Trims_environment_variable_name()
4344
{
4445
bool asserted = false;
45-
string variable = $"TEST_ENVIRONMENT_VARIABLE{randomizer.Next()}";
46+
string variable = test_variable;
4647
const string value = "This is a test";
4748
var rootCommand = new RootCommand
4849
{
@@ -63,10 +64,10 @@ public static async Task Trims_environment_variable_name()
6364
}
6465

6566
[Fact]
66-
public static async Task Trims_environment_variable_value()
67+
public async Task Trims_environment_variable_value()
6768
{
6869
bool asserted = false;
69-
string variable = $"TEST_ENVIRONMENT_VARIABLE{randomizer.Next()}";
70+
string variable = test_variable;
7071
const string value = "This is a test";
7172
var rootCommand = new RootCommand
7273
{
@@ -87,10 +88,10 @@ public static async Task Trims_environment_variable_value()
8788
}
8889

8990
[Fact]
90-
public static async Task Sets_environment_variable_value_containing_equals_sign()
91+
public async Task Sets_environment_variable_value_containing_equals_sign()
9192
{
9293
bool asserted = false;
93-
string variable = $"TEST_ENVIRONMENT_VARIABLE{randomizer.Next()}";
94+
string variable = test_variable;
9495
const string value = "This is = a test containing equals";
9596
var rootCommand = new RootCommand
9697
{
@@ -111,10 +112,10 @@ public static async Task Sets_environment_variable_value_containing_equals_sign(
111112
}
112113

113114
[Fact]
114-
public static async Task Ignores_environment_directive_without_equals_sign()
115+
public async Task Ignores_environment_directive_without_equals_sign()
115116
{
116117
bool asserted = false;
117-
string variable = $"TEST_ENVIRONMENT_VARIABLE{randomizer.Next()}";
118+
string variable = test_variable;
118119
var rootCommand = new RootCommand
119120
{
120121
Handler = CommandHandler.Create(() =>

0 commit comments

Comments
 (0)