-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert test to not require the network (#10355)
Co-authored-by: AbdulFattaah Popoola <abdulapopoola@github.com>
- Loading branch information
1 parent
aaa818d
commit c95a0fc
Showing
2 changed files
with
187 additions
and
55 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace NuGetUpdater.Core.Test; | ||
|
||
public class TemporaryEnvironment : IDisposable | ||
{ | ||
private readonly List<(string Name, string? Value)> _originalVariables = new(); | ||
|
||
public TemporaryEnvironment((string Name, string Value)[] variables) | ||
{ | ||
foreach (var (name, value) in variables) | ||
{ | ||
_originalVariables.Add((name, Environment.GetEnvironmentVariable(name))); | ||
Environment.SetEnvironmentVariable(name, value); | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
foreach (var (name, value) in _originalVariables) | ||
{ | ||
Environment.SetEnvironmentVariable(name, value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters