Relative Content

Tag Archive for c#asp.net-corexunit

Xunit: set env variable specifically for one test

[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 […]