[Fact]
public void GetStatus_WhenLocalMachine_ReturnsLocalhostValue()
{
// Arrange
Environment.SetEnvironmentVariable("Localhost", true);
var service = new Service(_configuration.Object);
// Act
var status = service.GetStatus();
Environment.SetEnvironmentVariable("Localhost", null);
// Assert
status.Hash.Should().Be(DeploymentService.Hash);
}
I have this method which works correctly only when there is env variable Localhost: true
. I also have some other tests that do not work because this env variable makes them read the wrong settings. (They actually work because I am resetting this value in test) Is there a way to set env variable specifically for one test? And avoid resetting them?