Skip to content

Commit cdca798

Browse files
author
Gonzalo Diaz
committed
An example class to test conditionally run of test methods using BRUTEFORCE environment variable to control behavior.
1 parent 9a8eed8 commit cdca798

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace algorithm_exercises_csharp;
2+
3+
[TestClass]
4+
public class HelloWorldBruteForceTest
5+
{
6+
private static readonly string[] allowedValues = ["TRUE", "YES", "1"];
7+
8+
[TestInitialize]
9+
public void testInitialize()
10+
{
11+
var envValue = Environment.GetEnvironmentVariable("BRUTEFORCE");
12+
envValue = envValue?.ToUpper();
13+
if (!allowedValues.Contains(envValue, StringComparer.OrdinalIgnoreCase))
14+
{
15+
Assert.Inconclusive($"Skipping BRUTEFORCE test because environment variable 'BRUTEFORCE' is not one of the expected values.");
16+
}
17+
}
18+
19+
[TestMethod]
20+
public void testHelloBruteForce()
21+
{
22+
string expected = "Hello World!";
23+
string result = HelloWorld.hello();
24+
25+
Assert.AreEqual(expected, result);
26+
}
27+
}

0 commit comments

Comments
 (0)